我有一个使用Angular + Typescript + Webpack2构建的解决方案,我想动态加载一些只在运行时才知道的外部模块。 由于我无法使用webpack来完成这项任务,我正在探索SystemJs。
我试图require
SystemJS,但这导致应用程序失败,因为执行流程命中
let System = require('systemjs');
我收到这个错误
Cannot find module "."
at webpackMissingModule (system.src.js:3893) [angular]
at new SystemJSLoader$1 (system.src.js:3893) [angular]
at index.js:23199:14 [angular]
at Object.<anonymous> (system.src.js:4022) [angular]
at Object.module.exports (system.src.js:4023) [angular]
at __webpack_require__ (bootstrap 1fedc3c…:19) [angular]
at TestComponent.requireSystemJS (test.ts:92) [angular]
at CompiledTemplate.proxyViewClass.View_TestComponent0.handleEvent_12 (/AppModule/TestComponent/component.ngfactory.js:306) [angular]
at CompiledTemplate.proxyViewClass.<anonymous> (vendor.bundle.js:234756) [angular]
at HTMLButtonElement.<anonymous> (vendor.bundle.js:101611) [angular]
at Object.onInvokeTask (vendor.bundle.js:78309) [angular]
at ZoneDelegate.invokeTask (vendor.bundle.js:221403) [angular]
at Zone.runTask (vendor.bundle.js:221203) [<root> => angular]
at HTMLButtonElement.ZoneTask.invoke (vendor.bundle.js:221457) [<root>]
有用的信息:
我在webpack配置中添加了以下几行
node: { fs: 'empty' }
避免Module not found: Error: Cannot resolve module 'fs'
我怎样才能让整个过程发挥作用?