#Reducing size of node_modules

8 messages · Page 1 of 1 (latest)

rough raft
#

Hi, I noticed the biggest necessary package to build Angular projects is @angular-devkit/build-angular which lets me use the default builders but I'm only targeting browser environments so I only really need @angular-devkit/build-angular:browser-esbuild (ESBuild seems to be smaller than Webpack when installed on it's own, only about 10 MiB).

I'm not sure if the 200 MiB size of @angular-devkit/build-angular with it's 62 dependencies is because it installs all the build targets or that it's just large in general but I thought installing only @angular-devkit/build-angular:browser-esbuild might help. Can this be done? If not, I guess I could always just define a custom builder that does what @angular-devkit/build-angular:browser-esbuild does but I'd have to figure out what it's dependencies are since the @angular-devkit/build-angular package's package.json just lists the dependencies for all builders?

copper zenith
#

The team is actively moving this direction. You can install @angular/build which includes a handful of builders which very explicitly do not depend on Webpack. I think it might require application builder instead of browser-esbuild though.

The main limitation right now is that the Karma builder still requires Webpack, however v19 is adding a dev preview option to switch to esbuild as the main bundler. If you are able to enable that option or use a different test runner, it should be possible to get Webpack out of the install by depending on @angular/build.

Once those changes are stabilized in Karma, an ng update migration will probably do it automatically.

rough raft
#

Thanks, looks like @angular/build pretty much cuts the size in half.

unkempt wigeon
#

The builder inside angular

#

inside your angular.json configuration file

#

you have "@angular-devkit/build-angular:karma"

copper zenith