Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Even though I am using target esm2015, ivy is compiles as a esm5 module

Tags:

angular-cli

@angular ivy issue

Description

When I use the ng cli, it compiles the modules as esm2015, my problem is that I have an old system since angular 2 times and I use webpack, but for me it compiles to es5.

How can I change it to compile to esm2015?

🔬 Minimal Reproduction

my tsconfig.aot.json:

{
    "compilerOptions": {
        "rootDir": ".",
        "baseUrl": ".",
        "skipLibCheck": true,
        "outDir": "build/aot",
        "target": "es2015",
        "module": "esnext",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "noImplicitAny": true,
        "suppressImplicitAnyIndexErrors": true,
        "lib": [
            "es2018",
            "dom"
        ],
        "paths": {
            "corifeus-web-material": [
                "build-modules/corifeus-web-material/index.ts"
            ],
            "corifeus-web": [
                "build-modules/corifeus-web/index.ts"
            ],
            "corifeus-web-material/*": [
                "build-modules/corifeus-web-material/*"
            ],
            "corifeus-web/*": [
                "build-modules/corifeus-web/*"
            ]
        }
    },
    "include": [
        "build-modules/**/*",
        "src/angular/**/*",
        "test/angular-webpack/**/*"
    ],
    "exclude": [
        "src-save",
        "*.worker.js",
        "src/angular/bundle.ts",
        "test/angular-webpack/angular/bundle.ts",
        "test/angular-karma",
        "build/browser",
        "node_modules/corifeus-web/test",
        "node_modules/corifeus-web-material/test"
    ],
    "angularCompilerOptions-save": {
        "annotationsAs": "decorators",
        "preserveWhitespaces": false
    },
    "angularCompilerOptions": {
        "enableIvy": true
    }
}
git clone https://github.com/patrikx3/corifeus-app-web-pages
cd corifeus-app-web-pages
npm install
grunt

output:

Running "cory-build-aot" task

Compiling @angular/core : module as esm5

Compiling @angular/common : module as esm5

Compiling @angular/common/http : module as esm5

Compiling @angular/animations : module as esm5

Compiling @angular/animations/browser : module as esm5

Compiling @angular/animations/browser/testing : module as esm5

Compiling @angular/cdk/platform : module as esm5

Compiling @angular/cdk/coercion : module as esm5

Compiling @angular/cdk/bidi : module as esm5

Compiling @angular/cdk/collections : module as esm5

Compiling @angular/cdk/scrolling : module as esm5

Compiling @angular/cdk/drag-drop : module as esm5

Compiling @angular/common/http/testing : module as esm5

Compiling @angular/cdk/keycodes : module as esm5

Compiling @angular/cdk/observers : module as esm5

Compiling @angular/cdk/a11y : module as esm5

Compiling @angular/platform-browser : module as esm5

Compiling @angular/cdk : module as esm5

Compiling @angular/platform-browser/animations : module as esm5

Compiling @angular/material/core : module as esm5

Compiling @angular/cdk/portal : module as esm5

Compiling @angular/cdk/overlay : module as esm5

Compiling @angular/forms : module as esm5

Compiling @angular/material/form-field : module as esm5

Compiling @angular/material/autocomplete : module as esm5

Compiling @angular/material/badge : module as esm5

Compiling @angular/cdk/layout : module as esm5

Compiling @angular/material/bottom-sheet : module as esm5

Compiling @angular/material/button : module as esm5

Compiling @angular/material/button-toggle : module as esm5

Compiling @angular/material/card : module as esm5

Compiling @angular/material/checkbox : module as esm5

Compiling @angular/material/chips : module as esm5

Compiling @angular/material/dialog : module as esm5

Compiling @angular/cdk/text-field : module as esm5

Compiling @angular/material/input : module as esm5

Compiling @angular/material/datepicker : module as esm5

Compiling @angular/material/divider : module as esm5

Compiling @angular/cdk/accordion : module as esm5

Compiling @angular/material/expansion : module as esm5

Compiling @angular/material/grid-list : module as esm5

Compiling @angular/material/icon : module as esm5

Compiling @angular/material/list : module as esm5

Compiling @angular/material/menu : module as esm5

Compiling @angular/material/select : module as esm5

Compiling @angular/material/tooltip : module as esm5

Compiling @angular/material/paginator : module as esm5

Compiling @angular/material/progress-bar : module as esm5

Compiling @angular/material/progress-spinner : module as esm5

Compiling @angular/material/radio : module as esm5

Compiling @angular/material/sidenav : module as esm5

Compiling @angular/material/slide-toggle : module as esm5

Compiling @angular/material/slider : module as esm5

Compiling @angular/material/snack-bar : module as esm5

Compiling @angular/material/sort : module as esm5

Compiling @angular/cdk/stepper : module as esm5

Compiling @angular/material/stepper : module as esm5

Compiling @angular/cdk/table : module as esm5

Compiling @angular/material/table : module as esm5

Compiling @angular/material/tabs : module as esm5

Compiling @angular/material/toolbar : module as esm5

Compiling @angular/cdk/tree : module as esm5

Compiling @angular/material/tree : module as esm5

Compiling @angular/material : module as esm5

Compiling @angular/core/testing : module as esm5

Compiling @angular/platform-browser-dynamic : module as esm5

Compiling @angular/platform-browser/testing : module as esm5

Compiling @angular/compiler/testing : module as esm5

Compiling @angular/platform-browser-dynamic/testing : module as esm5

Compiling @angular/common/testing : module as esm5

Compiling @angular/router : module as esm5

Compiling @angular/router/testing : module as esm5

is it an error? i should be getting esm2015 module compiling.

🔥 Exception or Error

not directly error, but i target for esm2015

🌍 Your Environment

Angular Version: 8.1.2

Anything else relevant?

build error, i am expecting like :

Compiling @angular/core : es2015 as esm2015

Compiling @angular/common : es2015 as esm2015

Compiling @angular/platform-browser : es2015 as esm2015

Compiling @angular/platform-browser-dynamic : es2015 as esm2015

like image 526
Patrik Laszlo Avatar asked Jul 26 '19 12:07

Patrik Laszlo


2 Answers

For me this started showing after upgrading to Angular 9, and adding

"postinstall": "ngcc"

to scripts in package.json fixed it.

like image 130
Unacorn Avatar answered Nov 09 '22 02:11

Unacorn


ok,i, found it, in webpack i had to set [ 'es2015', 'browser', 'module', 'main'],,

https://github.com/angular/angular/issues/31853#issuecomment-515406475

enter image description here

like image 31
Patrik Laszlo Avatar answered Nov 09 '22 02:11

Patrik Laszlo