Angular 如何在运行时使用SystemJS加载的模块中处理外部依赖关系?

Angular 如何在运行时使用SystemJS加载的模块中处理外部依赖关系?,angular,angular6,angular-cli,angular8,systemjs,Angular,Angular6,Angular Cli,Angular8,Systemjs,我试图在运行时使用systemJS在angular中加载外部模块 import { System } from 'systemjs'; declare const SystemJS: System; import * as angularCore from '@angular/core'; // Why do we need to do this? SystemJS.set('@angular/core', SystemJS.newModule(angularCore)); 在运行时加载模

我试图在运行时使用systemJS在angular中加载外部模块

import { System } from 'systemjs';
declare const SystemJS: System;

import * as angularCore from '@angular/core';

// Why do we need to do this?
SystemJS.set('@angular/core', SystemJS.newModule(angularCore));
在运行时加载模块:

SystemJS.import(`${url}`).then((module) => {
        return this.compiler.compileModuleAndAllComponentsAsync(module.externalModule).then(compiled => {
            const factory = compiled.componentFactories[0];
            this.container.createComponent(factory);
        });
如果我的外部模块有一些在我的主应用程序中不可用的依赖项,我将如何加载这些依赖项?

例如, 如果我使用

在我的外部模块中,当“xyz”在我的主应用程序中不作为依赖项出现时,服务器会以
错误404进行响应http://localhost:4200/xyz 找不到
。那么,我如何确保这些依赖项在运行时也可用呢


我正在使用systemjs导入
external.umd.js
,而且,好吧,umd文件不会将依赖项与代码捆绑在一起。

尝试使用webpack捆绑主应用程序中不可用的依赖项。 请参阅链接:

import { abc } from 'xyz';