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:
- SystemJS was installed through npm install
I added to the webpack configuration the following lines
node: { fs: 'empty' }
to avoid Module not found: Error: Cannot resolve module 'fs'
- I haven't a SystemJS configuration file yet
How can I get the whole thing working?