Skip to content

Library build not minified #24812

Description

@exoduscloudtech

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Not tried this in previous versions

Description

When performing ng build or ng build --configuration=production, Angular creates a main..js, a polyfills..js, and a runtime.*.js file all of which are flattened and minified.

When performing ng build or ng build --configuration=production on a standalone Angular component, currently the fesm2015 and fesm2020 folders in the destination folder hold *.mjs and *.mjs.map files, where neither file holds "flattened" code. The standalone component code is easily readable. ng build should flatten the output code, and --configuration=production should minify the flattened code.

According to:
https://angular.io/guide/angular-package-format

"To generate a flattened ES Module index file, use the following configuration options in your tsconfig.json file":

"angularCompilerOptions": {
...
"flatModuleOutFile": "my-ui-lib.js",
"flatModuleId": "my-ui-lib"
}

This does not flatten the output from ng build.

2 REQUESTS:

  1. Can ng build flatten the output of standalone component libraries?
  2. Can ng build --configuration=production minify the flattened output, as in the case of any other Angular application?

Minimal Reproduction

Run
ng build my-library-name

Or
ng build my-library-name --configuration=production

Exception or Error

No error to show

Your Environment

Angular CLI: 15.0.0
Node: 16.15.1
Package Manager: npm 8.11.0
OS: win32 x64
Angular: 15.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.0
@angular-devkit/build-angular 15.0.0
@angular-devkit/core 15.0.0
@angular-devkit/schematics 15.0.0
@schematics/angular 15.0.0
ng-packagr 15.0.0
rxjs 7.5.7
typescript 4.8.4

Anything else relevant?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions