angular - 使用 SystemJS-builder 捆绑 Angular 2 提前编译器文件

标签 angular deployment module compilation systemjs

我已经使用 angular.io 上的提前编译指令编译了用 typescript 2 编写的 Angular 2 应用程序。 。

ma​​in.ts

platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);

现在我有很多 ngfactory.ts 文件以及 .js 文件。为了进行 tree-shake 和捆绑,我使用简单的 systemjs-builder任务如下:

gulp.task('demo-bundle', function() {
    var builder = new SystemBuilder();

    builder.loadConfig('./systemjs.config.js')
        .then(function(){
            return builder.buildStatic('dev/main.js', 'dist/bundle.js', {
                encodeNames:false,
                mangle: false,
                rollup: true
            });
        })
});

捆绑完成且没有错误,但应用程序在浏览器中失败并出现错误:

Error: No provider for NgZone!

如果我通过引导从提前编译更改为即时编译:

platformBrowserDynamic().bootstrapModule(AppModule);

然后捆绑和应用程序将按预期工作。

关于如何将 AoT 编译与 buildStatic 正确捆绑的任何想法? (在 tsconfig 中,modulees2015,但我也尝试过 systemcommonjs)

@angular/compiler-cli 0.6.3systemjs-builder 0.15.31systemjs 0.19.39

最佳答案

我花了很长时间跟踪这个下载 - 加载 Angular 模块的 umd 包会导致这个错误。更改为在其文件夹中加载 index.js 文件。

关于angular - 使用 SystemJS-builder 捆绑 Angular 2 提前编译器文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39941680/

相关文章:

Angular 5,IE11 中的 URLSearchParams

angular - 它相当于 Blazor 中的 Angular/Vue 事件发射吗?

javascript - Angular 4 : Build to prod: Property is private and only accessible within class

windows - 尝试为Python安装正则表达式

Python 和 py2exe - 隐式导入模块

html - Angular 中的错误 TS2322,错误为 "Type ' string' is not assignable to type '"canvas""when using ng-particles

c++ - 部署时窗口下的qtcreator托盘图标不显示

amazon-web-services - 如何让应用程序长期部署在 EC2 服务器上?

ruby - 提交时在开发/QA 服务器上自动化 git pull 过程

design-patterns - 模块化大型 Grails 应用程序的最佳实践?