Search code examples
angulartypescriptng-packagr

Angular library not build to es5 target


I have a Angular library which I need to build for es5 so it can be used in IE. I have followed this guide https://angular.io/guide/creating-libraries

Here´s my file structure:

enter image description here

In the tsconfig.lib.json I have changed to es5:

/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/libb",
    "target": "es5", // <-- HERE
    "declaration": true,
    "declarationMap": true,
    "inlineSources": true,
    "types": [],
    "lib": [
      "dom",
      "es2018"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

A snippet of angular.json

 "projects": {
    "my-lib": {
      "projectType": "library",
      "root": "projects/my-lib",
      "sourceRoot": "projects/my-lib/src",
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "tsConfig": "projects/my-lib/tsconfig.lib.json",
            "project": "projects/my-lib/ng-package.json"
          },

The ng-package.json

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/my-lib",
  "lib": {
    "entryFile": "src/public-api.ts"
  }
}

Finally I build it with this command:

"build-lib": "ng build --project=my-lib"

What I would expect to happen is that i get mo library build in es5, but it seems like it ignores teh tsconfig.lib.jsoncompletely. Here´s the output:

enter image description here

Can someone help me with this?


Solution

  • ESM5 and FESM5 format were deprecated, see this issue: https://github.com/ng-packagr/ng-packagr/issues/1732