3

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 ?

Karthikeyan
  • 183
  • 1
  • 8
  • 1
    I started a bounty to this, because I have the same issue since I updated from Angular 12 to Angular 14. When I run `ng serve` or `ng build`, I receive - `Generating browser application bundles (phase: setup)...An unhandled exception occurred: Script file node_modules/rxjs/bundles/rxjs.umd.js does not exist. See "C:\Users\...\AppData\Local\Temp\ng-DDRwGT\angular-errors.log" for further details. \ Generating browser application bundles (phase: setup)...` and the build then never finishes, it just gets stuck in generating the setup phase. – Boommeister Sep 14 '22 at 08:00
  • https://github.com/manfredsteyer/ngx-build-plus/issues/314 – Nathan Beck Sep 20 '22 at 21:25

1 Answers1

2

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

The.Wolfgang.Grimmer
  • 1,172
  • 2
  • 9
  • 32
  • 1
    I tried adding `window.ng....` in my webpack.externals.js file and also creating a new file called window.js and added this file to the scripts array in angular.json. But it didn't help at all, I still receive the error: `Script file node_modules/rxjs/bundles/rxjs.umd.js does not exist.` – Boommeister Sep 14 '22 at 07:54
  • There is also a way how to generate umd files for Angular 13 with rollup - here is repo example https://github.com/peterblazejewicz/angular-umd-bundle But I had issue still with generating after that single-file with ngx-build-plus – Oleksandr Poshtaruk Nov 21 '22 at 15:30