Skip to content

angular 9: '__importDefault is not defined' error if aot is not explicitly on #16877

@bcmedeiros

Description

@bcmedeiros

🐞 bug report

Affected Package

"@angular/cli": "^9.0.1"
"@angular/compiler": "^9.0.0"
"@angular/core": "^9.0.0"

Is this a regression?

Yes (maybe not if Ivy won't support that)

Description

I have an angular workspace with multiple apps, and after updating to Angular 9 (I started trying with rc.11, same behaviour since then) 2 of those apps were having the following problem right after opening then in the browser: Uncaught ReferenceError: __importDefault is not defined

Configuration file was as below:

        "one-plan-dashboard-app": {
            "projectType": "application",
            "schematics": {
                "@schematics/angular:component": {
                    "style": "scss"
                }
            },
            "root": "projects/one-plan-dashboard-app",
            "sourceRoot": "projects/one-plan-dashboard-app/src",
            "prefix": "dash-op",
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist/one-plan-dashboard-app",
                        "index": "projects/one-plan-dashboard-app/src/index.html",
                        "main": "projects/one-plan-dashboard-app/src/main.ts",
                        "polyfills": "projects/one-plan-dashboard-app/src/polyfills.ts",
                        "tsConfig": "projects/one-plan-dashboard-app/tsconfig.app.json",
                        "aot": false,
                        "assets": [
                            "projects/one-plan-dashboard-app/src/favicon.ico",
                            "projects/one-plan-dashboard-app/src/web.config",
                            "projects/one-plan-dashboard-app/src/assets"
                        ],
                        "styles": [
                            "projects/one-plan-dashboard-app/src/styles.scss"
                        ],
                        "scripts": []
                    },
                    ...
                },
                ...
            }
        },

Same error happens removing "aot": false, but having it as "aot": true does not trigger the issue.

🔬 Minimal Reproduction

EDIT: Please see https://github.com/angular/angular/issues/35208#issuecomment-583259763, it seems to be very hard to find a sequence of steps that reproduce the bug, if possible at all.

I compared a new workspace with mine and realised that "aot": true prevents the issue, but still could not reproduce the issue in an new workspace and changing "aot": false. I'm still working on that as it seems that something else is needed to trigger the problem.

🔥 Exception or Error


app.component.ts:7 Uncaught ReferenceError: __importDefault is not defined
    at Module../src/app/app.component.ts (app.component.ts:7)
    at __webpack_require__ (bootstrap:79)
    at Module../src/app/app.module.ts (app.component.ts:10)
    at __webpack_require__ (bootstrap:79)
    at Module../src/main.ts (environment.ts:19)
    at __webpack_require__ (bootstrap:79)
    at Object.0 (main.ts:12)
    at __webpack_require__ (bootstrap:79)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)

🌍 Your Environment

Angular Version:


Angular CLI: 9.0.1
Node: 12.15.0
OS: win32 x64

Angular: 9.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.20
@angular-devkit/build-angular      0.803.20
@angular-devkit/build-ng-packagr   0.803.20
@angular-devkit/build-optimizer    0.803.20
@angular-devkit/build-webpack      0.803.20
@angular-devkit/core               8.3.20
@angular-devkit/schematics         9.0.1
@angular/cli                       9.0.1
@ngtools/webpack                   8.3.20
@schematics/angular                9.0.1
@schematics/update                 0.900.1
ng-packagr                         5.7.1
rxjs                               6.5.4
typescript                         3.7.5
webpack                            4.39.2

Node version:


node --version
v12.15.0

OS:
Windows 10 Enterprise

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions