标签: ngtools

AOT - Angular 6 - 指令SomeComponent,预期0个参数,但得到1.对于自制组件

当我想在AOT中使用以下包版本编译我当前的项目时,我遇到了问题:

  • @ ngtools/@的WebPack 6.0.3
  • @ angular @ latest(6.0.2)
  • Webpack@4.0.0

我的webpack和tsconfig.json配置可以在这里找到

我面临一些与模板上使用的private/ protectedscope 有关的问题,并且一些提取参数给了一些并不真正需要它的函数(Exemple $ event,它们不用于EventBinding).

现在我有以下列表,我找不到我的问题:

/path/to/app/header/main-header/main-header.component.html(85,7)::指令TableOfContentComponent,期望0参数,但得到1.(1,1)::指令TableOfContentComponent,预期0争论,但得到1.

我的main-header.component.html文件包含:// main-header.component.html

// main-header.component.ts
@ViewChildren('headerItems') public headerItems: QueryList<HeaderItemAbstract>;
mainMenuStates = {
    hamburger: false,
    bookmarks: false,
    search: false,
    toc: false,
    medias: false,
    article: false,
    language: false    
};
Run Code Online (Sandbox Code Playgroud)

而且我TableOfContentComponent不包含任何@Input财产.

@Component({
    selector: 'ps-table-of-content-template',
    templateUrl: './table-of-content.component.html',
    animations: [slideUpAndDownAnimation]
})
export class TableOfContentComponent extends HeaderItemAbstract implements OnInit {

    toc: TableOfContentModel[];

    devices: DevicesModel;

    tocContentHeight: number;
    tocContentMargin: number;
    menuHeight: string;


    constructor(private …
Run Code Online (Sandbox Code Playgroud)

webpack angular angular-aot ngtools

17
推荐指数
2
解决办法
8106
查看次数

ERROR in必须有一个要重构的源文件

webpack编译出现奇怪的错误:

ERROR in必须有一个要重构的源文件.

查看源代码,我发现此消息./node_modules/@ngtools/refactor.js:

...   
if (!sourceFile) {
  throw new Error('Must have a source file to refactor.');
}
Run Code Online (Sandbox Code Playgroud)

@ngtools webpack插件的配置非常简单:

  {
    test: /\.ts$/,
    use: '@ngtools/webpack',
  } 
Run Code Online (Sandbox Code Playgroud)

webpack angular ngtools

11
推荐指数
1
解决办法
1554
查看次数

webpack AngularCompilerPlugin hostReplacementPaths选项不起作用

在我更新到Angular6并@ngtools/webpack从"6.0.0-beta.8" 更新为"6.1.2"后,我发现hostReplacementPaths选项不再起作用.

通常它会替换正确的env文件:

new AngularCompilerPlugin({
  ...
  hostReplacementPaths: {
    'environments/environment.ts': environmentFiles[NODE_ENV]
  },
  ...
})
Run Code Online (Sandbox Code Playgroud)

但现在却没有.

我对@ ngtools/webpack进行了深入的调试,发现normalize这里的函数 https://github.com/angular/angular-cli/blob/master/packages/ngtools/webpack/src/virtual_file_system_decorator.ts#L188 不起作用

这一个 https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/core/src/virtual-fs/path.ts#L199

仍然无法找到它出了什么问题.也许有人已经解决了这个问题?

在angular-cli repo中创建了一个问题 - https://github.com/angular/angular-cli/issues/11801

webpack angular ngtools

7
推荐指数
0
解决办法
382
查看次数

--mode 开发错误:NormalModuleFactory.beforeResolve 不再是一个瀑布钩子

我将 webpack 5 和 @ngtools/webpack 一起使用来构建 angular 应用程序。当我运行时webpack --mode development出现以下错误:

Error: NormalModuleFactory.beforeResolve is no longer a waterfall hook, but a bailing hook instead. Do not return the passed object, but modify it instead. Returning false will ignore the request and results in no module created.
    at /home/alecoder/Projects/JS/ap/node_modules/webpack/lib/NormalModuleFactory.js:543:11
    at eval (eval at create (/home/alecoder/Projects/JS/ap/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:12:1)
(node:17432) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a …
Run Code Online (Sandbox Code Playgroud)

webpack webpack-4 ngtools webpack-cli angular9

6
推荐指数
0
解决办法
1495
查看次数

@ngtools/webpack AngularWebpackPlugin 可以链接部分编译的 ivy 库吗?

我有这个有点旧的 Angular Web 应用程序,它已从 Angular 6 更新到 Angular 12,但是,Angular CLI 并未用于构建它,而是依赖于 Webpack 5、其加载器和来自 @ngtools/webpack 的 AngularWebpackPlugin。

最近,我需要升级到我正在使用的库的最新版本,在生产构建后我收到以下警告:

Uncaught Error: The injectable 'j' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.

The injectable is part of a library that has been partially compiled.
However, the Angular Linker has not processed the library such that JIT compilation is used as fallback.

Ideally, the library is processed using the Angular Linker to become fully AOT compiled.
Alternatively, the …
Run Code Online (Sandbox Code Playgroud)

webpack angular ngtools

4
推荐指数
1
解决办法
2910
查看次数