问题标签 [angular2-aot]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
angular - @input 上的 Angular2 接口不适用于 AoT
我有一个界面:
我在课堂上使用的:
使用 AoT 编译时出现此错误:
Module src/interfaces/IEvent.ts does not export IEvent (imported by src/components/Event/Event.ts)
当我改变@Input
成@Input() data;
没有问题。
有谁知道@Input
在使用 AoT 时如何定义类型?
另请参阅https://forum.ionicframework.com/t/interface-does-not-export-bundle-dev-failed/66225
angular - 使 AoT 兼容 DI
我有一个使用 angular rc4 的工作项目,在将其更新为 angular 2.0.0 后它正在崩溃
我遇到以下错误:
静态解析符号值时遇到错误。调用函数'createStore',不支持函数调用。考虑将函数或 lambda 替换为对导出函数的引用,解析符号 appStore
使用不再有效的代码:
解决这个问题的最佳方法是什么?
这是我在 app.ts 中使用 angular rc4 的根组件的文件
angular - ngfactory 文件本身是否必须在 Angular 2 AOT 编译中编译?
每当我使用 编译 Angular 2 应用程序时ngc
,它都会为每个组件创建.ngfactory.ts
文件,然后将所有打字稿编译为 javascript。
但是,当我第一次运行“ngc”时,它会创建ngfactory
文件,但只会将其他文件编译为 javascript。这意味着不会生成已编译ngfactory
的 javascript 文件。
在第二次运行时,它ngfactory
也会编译文件(可能是因为它们是在与源代码相同的文件夹中生成的)。
我的问题是:ngfactories 本身是否应该被编译?它会以任何方式影响应用程序吗?
angularjs - Webpack + Angular2 AOT: Uncaught SyntaxError: Unexpected token import
在这个设置中,你如何编译从生成的 ngfactory 文件中导入的 angular2 库?
当前的应用程序是基于角度文档的 webpack + aot 食谱的组合
angular.io/docs/ts/latest/cookbook/aot-compiler.html
angular.io/docs/ts/latest/guide/webpack.html
我有一个有效的 POC,您可以在其中复制此 repo 中的问题:
https://github.com/jetlogs/Angular2-AOT-Localization
完成编译/捆绑后,您可以打开 2 个文件:
non-aot.html - 这是同一应用程序的非 aot 版本,它加载正常
aot.html - 此文件失败并显示:
ng_module_factory.js?95b1:13 Uncaught SyntaxError: Unexpected token import
预期行为
预期行为是 aot.html 和 non-aot.html 应该具有相同的行为
使用说明最小化重现问题
克隆 repo,然后在工作目录上运行这些命令:
然后打开 aot.html 重现问题
有什么方法可以修复导入的 angular2 库中的导入语句?谢谢
更新:
我尝试使用 babel-loader 转换 ES2015 中的 angular2 源文件:
它现在编译没有 ES6 不兼容的问题,但是,它现在只遇到一个新错误aot.html
:
core.umd.js?e2a5:3272未捕获错误:NgZone 没有提供程序!
为什么 AOT 编译器引用的转译的 angular2 源代码是 cdausing NgZone 问题?
我已经更新了上面的 repo 以反映我的最新更改
更新 2:2016 年 10 月 13 日
更新到 Angular 2.1
仍然是同样的问题
angular - Ionic2 RC0 加载外部模块时出错
在 Ionic 2 RC0 中,我对 angular2-text-mask "1.0.1" 有问题,但我认为这是 AoT 和大多数外部模块的问题。
在开发模式下,我收到此错误:
bundle dev failed: Module /root/path/node_modules/angular2-text-mask/dist/angular2TextMask.js does not export TextMaskModule (imported by /root/path/src/app/app.module.ts)
所以我修复了这个覆盖rollup.config.js
但是我在尝试构建它时遇到了问题。所以在产品模式下:
ngc: Error: Unexpected value 'TextMaskModule' imported by the module 'AppModule'
我的app.module
代码
任何帮助将不胜感激。
angular - Angular 2 AOT 不起作用。为什么“platformBrowser().bootstrapModuleFactory”会拉取带有附加前缀“/src/linker/ng_module_factory”的链接?
当我使用 JIT 运行我的 Angular 2 应用程序时,一切正常。但是在我切换到 AOT 后,我的应用程序开始使用附加前缀(“/src/linker/ng_module_factory”)提取链接,例如:
JIT 拉取:http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js
AOT 拉扯:http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js/src/linker/ng_module_factory
postfix/src/linker/ng_module_factory
是从哪里来的?
关于应用程序。我正在使用 Java 8 + Spring 4.3.2.RELEASE + Angular 2 + Tomcat 9.0.0.M6。
包.json
索引.html
systemjs.config.js
tsconfig.json
打字.json
app.component.ts
app.module.ts
JIT 配置 main.ts
下一步是使用命令编译tsc
,构建战争和部署。
AOT 配置 main.ts
下一步是安装编译器npm install @angular/compiler-cli
,使用命令'./node_modules/.bin/ngc'编译,构建war和部署。命令后ngc
我得到文件 *.ngfactory.ts, *.ngfactory.js, *.metadata.json, *.shim.ts, *.shim.js
angular - angular2-jwt 和提前编译
在 JiT 编译中一切正常,但是当我尝试使用 AoT 编译时出现以下编译错误。谁能解释发生了什么?
我正在使用 auth0-lock v.10.4.0 和 angular2-jwt v.0.1.24
错误:
我正在使用延迟加载,所以我有一个 AuthService 和 AUTH_PROVIDER 的共享模块,如下所示:
angular - Angular2 CLI:为什么“--prod”的捆绑大小小于“--prod --aot”?
我正在为一个项目使用最新的 angular-cli (beta-18)。我知道 cli 仍处于非常早期的阶段,但我很困惑为什么在没有AoT 的情况下我的最终包大小实际上更小。
当我运行时ng build --prod
,它是 1.08 mb:
当我运行时ng build --prod --aot
,它是 1.26 mb。
对于 tsconfig 看起来像:
angularjs - 提前编译的 Angular 2 出现错误“已创建具有不同配置的平台”。
我试图弄清楚整个编译提前的想法。我被这些好处所推销,但实际这样做的过程让我头疼。
我尽可能地遵循食谱。可能唯一的大区别是他们main.ts
是我的boot.ts
,但我boot.ts
的实际上是他们的main.ts
。我的 package.json 中有他们说要安装的所有内容以及以下任务:
tsconfig-aot.json:
汇总-config.js:
我copy-dist-files.js
只是一个节点脚本,用于将我的 css 和图像移动到位,aot/
并且似乎在所有平台上都可以正常工作。老实说,关于该文件的任何内容都不是特定于角度的。如果您需要它,我会发布它,但我会尽量保持清洁。
在我运行npm run aot
它成功完成并运行http-server aot
以提供文件夹后,我在控制台中收到此错误:
我从未收到过使用 JiT 编译的错误。我不知道这是从哪里来的。每次我用谷歌搜索它时,我都会发现有人问它与测试有关,但这是关于在浏览器中运行的捆绑包。这些问题绕过了实际的错误文本,因为问题在于他们的测试脚手架。我不认为我正在加载任何其他平台,我不知道如何破坏它。特别奇怪的是,该站点似乎完全正常运行和运行。
不丑化 bundle.js 并没有帮助,因为错误似乎在 Angular 的内部被抛出,部分是我没有写的,也不想编辑。
我正在运行 Angular 2.1.1,并且所有浏览器中都显示错误。这里发生了什么?
angular - 使用 Sass 样式和 pug (jade) 模板进行 Angular AoT 编译
有没有人找到在 webpack 中使用 Sass 和 pug 编译 Angular(版本 >= 2)的解决方案?