I'm creating an angular 7 project with systemjs to load dynamically a module.
When I try to use it, I have this error:
ERROR ReferenceError: SystemJS is not defined
My package.json contain systemjs: 2.1.1
I added systemjs path to section scripts in my angular.json
"./node_modules/systemjs/dist/system.js"
I declared SystemJs to use it in my service:
declare const SystemJS;
and I'm trying to using like this, in this function:
loadModuleSystemJS(moduleInfo: ModuleData): Promise<any> {
const url = this.source + moduleInfo.location;
SystemJS.set('@angular/core', SystemJS.newModule(AngularCore));
SystemJS.set('@angular/common', SystemJS.newModule(AngularCommon));
SystemJS.set('@angular/router', SystemJS.newModule(AngularRouter));
SystemJS.set('@angular/platform-browser/animations', SystemJS.newModule(BrowserAnimations));
// now, import the new module
return SystemJS.import(`${url}`).then((module) => {
return this.compiler.compileModuleAndAllComponentsAsync(module[`${moduleInfo.moduleName}`]).then(compiled => {
return module;
});
});
}
Maybe I've missed something,
Can you help me ?