ngx-build-plus:externals not working for Angular 13

1.9k Views Asked by At

As Angular 13 is not producing UMD-Bundles any longer

the command

ng g ngx-build-plus:externals --project MY_PROJECT

currently creates an invalid angular.json (pointing to the non-existing UMD-Bundles).

Here is umd bundles referred in angular.json

"scripts": [
              "node_modules/rxjs/bundles/rxjs.umd.js",
              "node_modules/@angular/core/bundles/core.umd.js",
              "node_modules/@angular/common/bundles/common.umd.js",
              "node_modules/@angular/common/bundles/common-http.umd.js",
              "node_modules/@angular/compiler/bundles/compiler.umd.js",
              "node_modules/@angular/elements/bundles/elements.umd.js",
              "node_modules/@angular/platform-browser/bundles/platform-browser.umd.js",
              "node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js"
            ]

What is the alternate files for these above files? Is there any other way to solve this issue ?

1

There are 1 best solutions below

2
On

As specified by the author of the package. Apparently, angular 13 no longer generates umd files; hence, the reason for the error.

He gave some sort of a workaround here by directly adding it to the window object and importing the required files.

window.ng.core = require('@angular/core');
window.ng.common = require('@angular/common');

Maybe we can add a file containing all the direct assignments to window.ng and add that to angular.json.

You can read his response here: https://github.com/manfredsteyer/ngx-build-plus/issues/314#issuecomment-1089107900