Using SystemJS and Webpack

不问归期 提交于 2019-12-22 07:55:08

问题


I have a solution built with Angular + Typescript + Webpack2 and I want to load dynamically some external modules that are known only at runtime. Since I can't use webpack to accomplish this task I'm exploring SystemJs.

I was trying to require SystemJS but this causes the application to fail, as the execution flow hit

let System = require('systemjs');

I get this error

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>]

Useful information:

  1. SystemJS was installed through npm install
  2. I added to the webpack configuration the following lines

    node: {
        fs: 'empty'
    }
    

to avoid Module not found: Error: Cannot resolve module 'fs'

  1. I haven't a SystemJS configuration file yet

How can I get the whole thing working?

来源:https://stackoverflow.com/questions/43324865/using-systemjs-and-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!