使用webpack创建angular1和angular2混合应用程序抛出升级静态错误

时间:2017-02-27 12:41:29

标签: angularjs webpack angular2-routing

我正在尝试使用角度升级路径来使用webpack加载器使用angular1和angular2。当我使用angular1并且只加载angular2时它一切正常,原因是升级静态文件错误,如下所述

我的角度引导程序文件如下:

import 'angular2-universal-polyfills/browser';
import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';
import 'bootstrap';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { UpgradeModule } from '@angular/upgrade/static';


// Enable either Hot Module Reloading or production mode
if (module['hot']) {
    module['hot'].accept();
    module['hot'].dispose(() => { platform.destroy(); });
} else {
    enableProdMode();
}

// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => {
    //platform.bootstrapModule(AppModule);
    platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => {
        console.info("Angular 2 bootstrapping");
        const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
        upgrade.bootstrap(document.documentElement, ["app"], { strictDi: true });
    });
};
if (document.readyState === 'complete') {
    bootApplication();
} else {
    document.addEventListener('DOMContentLoaded', bootApplication);
}

我得到的错误在

之下

./~/@angular/upgrade/static.js出错 模块解析失败:C:\ TFS \ PostAnything \ Postanything.Web.Client \ node_modules \ @angular \ upgrade \ static.js第8行:意外的令牌 您可能需要适当的加载程序来处理此文件类型。 | *在https://angular.io/license的LICENSE文件中找到 | * / |从' ./ src / aot / downgrade_component'中导出{downgradeComponent}; |从' ./ src / aot / downgrade_injectable'中导出{downgradeInjectable}; |从' ./ src / aot / upgrade_component'中导出{UpgradeComponent};  @ ./ClientApp/boot-client.ts 9:15-49

1 个答案:

答案 0 :(得分:1)

我最终通过从其他GitHub repo获取指导并创建了我自己的Web Developer中的Angular1和Angular混合应用程序来解决这个问题。

Click here for Github repo link