angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

Angular 13: Add ability to generate esm5 bundle #22434

Closed danilmoro3 closed 2 years ago

danilmoro3 commented 2 years ago

🐞 Bug report

Command (mark with an x)

Description

As IE11 is no longer supported by Angular 13, there is no way to generate esm5 bundle. Therefore, generated esm2020 bundles is not compatible in the projects with an old version of angular.

πŸ”¬ Minimal Reproduction

Run the following command in any project:

nx build some-lib

πŸ”₯ Exception or Error

See generated bundle, there are no esm5 and lib bundles with .js files inside (not .mjs):


- esm2020
- fesm2015
- fesm2020
- lib
...

🌍 Your Environment

nx report:


  Node : 14.15.0
  OS   : darwin x64
  npm  : 6.14.8

  nx : 13.3.6
  @nrwl/angular : 13.3.6
  @nrwl/cli : 13.3.6
  @nrwl/cypress : 13.3.6
  @nrwl/devkit : 13.1.3
  @nrwl/eslint-plugin-nx : 13.3.6
  @nrwl/express : undefined
  @nrwl/jest : 13.3.6
  @nrwl/linter : 13.3.6
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : undefined
  @nrwl/nx-cloud : 13.0.0
  @nrwl/react : undefined
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.3.6
  @nrwl/web : undefined
  @nrwl/workspace : 13.3.6
  @nrwl/storybook : 13.3.6
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
         @angular/animations: 13.1.1
         @angular/cdk: 13.1.0
         @angular/common: 13.1.1
         @angular/compiler: 13.1.1
         @angular/core: 13.1.1
         @angular/elements: 13.1.1
         @angular/forms: 13.1.1
         @angular/platform-browser: 13.1.1
         @angular/platform-browser-dynamic: 13.1.1
         @angular/router: 13.1.1
         ng-zorro-antd: 12.1.0
         @angular-devkit/build-angular: 13.0.0
         @angular-eslint/builder: 13.0.1
         @angular-eslint/schematics: 13.0.1
         @angular/cli: 13.1.2
         @angular/compiler-cli: 13.1.1
         @angular/language-service: 13.1.1
         @storybook/angular: 6.4.9

tsconfig.base.json


...
"target": "es2015",
"module": "esnext",
"typeRoots": ["node_modules/@types"],
"lib": ["es2015", "es2019", "dom"],
...
JoostK commented 2 years ago

Angular Package Format has not included ES5 sources for quite some time (Angular 10) and this is unrelated to IE11 support. The CLI will automatically downlevel ES2020/ES2015 library code to ES5 when bundling an application that requests an ES5 output format.

Therefore, generated esm2020 bundles is not compatible in the projects with an old version of angular.

A library should never be used in older versions of Angular than they were build in.

angular-automatic-lock-bot[bot] commented 2 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.