Angular project in another angular project: Uncaught (in promise): TypeError: n.e is not a function

Angular project in another angular project: Uncaught (in promise): TypeError: n.e is not a function

我创建了一个 angular 9 应用程序并将 js 文件添加到另一个 angular 应用程序,但在部署在 IIS 上托管应用程序。

问题重现

  1. 在项目a
  2. 中创建一个angular9 web组件
  3. 创建一个angular应用程序项目b
  4. 在项目b中使用在项目a中创建的angular组件 Web组件应用程序的想法是将组件导入其他项目并无缝工作。

错误类型:

main-es2015.75fe17eab98c55742615.js:1 ERROR Error: Uncaught (in promise): TypeError: n.e is not a function
TypeError: n.e is not a function
    at loadChildren (main-es2015.75fe17eab98c55742615.js:1)
    at un.loadModuleFactory (main-es2015.75fe17eab98c55742615.js:1)
    at un.load (main-es2015.75fe17eab98c55742615.js:1)
    at l.project (main-es2015.75fe17eab98c55742615.js:1)
    at l._tryNext (main-es2015.75fe17eab98c55742615.js:1)
    at l._next (main-es2015.75fe17eab98c55742615.js:1)
    at l.next (main-es2015.75fe17eab98c55742615.js:1)
    at d._subscribe (main-es2015.75fe17eab98c55742615.js:1)
    at d._trySubscribe (main-es2015.75fe17eab98c55742615.js:1)
    at d.subscribe (main-es2015.75fe17eab98c55742615.js:1)
    at T (polyfills-es2015.61be2d396988ee9b9963.js:1)
    at T (polyfills-es2015.61be2d396988ee9b9963.js:1)
    at polyfills-es2015.61be2d396988ee9b9963.js:1
    at l.invokeTask (polyfills-es2015.61be2d396988ee9b9963.js:1)
    at Object.onInvokeTask (main-es2015.75fe17eab98c55742615.js:1)
    at l.invokeTask (polyfills-es2015.61be2d396988ee9b9963.js:1)
    at a.runTask (polyfills-es2015.61be2d396988ee9b9963.js:1)
    at _ (polyfills-es2015.61be2d396988ee9b9963.js:1)
Bn @ main-es2015.75fe17eab98c55742615.js:1

您可能只是遇到了冲突 with/within Webpack。如果将 Angular 构建器切换为 @angular-builders/custom-webpack:browser,则可以像这样使用自定义 Webpack 配置:

          "options": {
            "customWebpackConfig": {
              "path": "./extra-webpack.config.js",
              "mergeStrategies": {
                "externals": "replace"
              }
            },
...

而自定义配置只会像这样定义唯一的 jsonpFunction:

module.exports = {
  output: {
    jsonpFunction: 'projecta'
  }
}