angular: Uncaught ReferenceError: __importDefault is not defined

🐞 bug report

Affected Package

The issue is caused by package @angular/…“9.0.0-next.2”

Is this a regression?

Yes, the previous version in which this bug was not present was: @angular/…“8.0.0”

Description

App compiles with ng serve but is not being loaded in the browser with the above error referring to a line in the components metadata: templateUrl: './login.component.html',

🔬 Minimal Reproduction

https://github.com/akolybelnikov/repro-issue-ng-9

🔥 Exception or Error


(In Chrome: )Uncaught ReferenceError: __importDefault is not defined

(In Safari: ) ReferenceError: Can't find variable: __importDefault

🌍 Your Environment

Angular Version: 9.0.0-next.2


Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.0-rc.0
@angular-devkit/build-angular      0.803.0-rc.0
@angular-devkit/build-ng-packagr   0.803.0-rc.0
@angular-devkit/build-optimizer    0.803.0-rc.0
@angular-devkit/build-webpack      0.803.0-rc.0
@angular-devkit/core               8.3.0-rc.0
@angular-devkit/schematics         8.1.1
@angular/cdk                       8.1.3
@angular/cli                       8.3.0-rc.0
@angular/material                  8.1.3
@angular/pwa                       0.803.0-rc.0
@ngtools/webpack                   8.3.0-rc.0
@schematics/angular                8.3.0-rc.0
@schematics/update                 0.803.0-rc.0
ng-packagr                         5.5.0
rxjs                               6.5.2
typescript                         3.7.0-dev.20190820
webpack                            4.39.2

Anything else relevant? MacOS

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 19 (1 by maintainers)

Most upvoted comments

Because my TypeScript version cannot be downgraded, I have overridden this method. by use in my html script tag: var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } and it works, Reference link. See what’s ‘–esModuleInterop’ do.

Happens also with the latest 8.x release ! Downgraded TypeScript to 3.5.3 which fixes it. TypeScript 3.6.x is buggy !

Closing my issue as it is resolved in the latest version.

issue still persist with .rc version.

Angular CLI: 9.0.0-rc.1 Node: 12.8.0 OS: darwin x64 Angular: …

Package Version

@angular-devkit/architect 0.900.0-rc.1 @angular-devkit/core 9.0.0-rc.1 @angular-devkit/schematics 9.0.0-rc.1 @schematics/angular 9.0.0-rc.1 @schematics/update 0.900.0-rc.1 rxjs 6.5.3

and I am using ts v3.6.4

For me, the fix was just downgrade typescript package (3.4.5 works fine)

Updating to

@angular-devkit/build-angular”: “~0.900.0-rc.7”

solved it at my side.

I get the same error with rc6, typescript 3.6.4

ng v9.0.0-rc.0 and ts v3.6.4 not working for me.

I get the same error with 9.0.0-rc.7,typescript 3.6.4…

I had exactly the same issue with the following versions:

"@angular/core": "~9.0.0-rc.3",
"@angular-devkit/build-angular": "~0.900.0-rc.3",
"@angular/compiler-cli": "~9.0.0-rc.3",
"@angular/language-service": "~9.0.0-rc.3",
"typescript": "^3.6.4"

What fixed it for me was the update to the same angular/cli version

"@angular/cli": "~9.0.0-rc.3"

Closing my issue as it is resolved in the latest version.

I have just updated the project to v9.0.0-next.14 / TS v.3.6.4 with ng update and after the CLI linted all files, the issue is not present anymore.

Time to get this one up a tad bit; Angular 9.0.0-next.14 actually requires typescript between 3.6.4 and 3.7.0, causing a huge problem with the template imports as this is caused by TS 3.6.4 or higher. zengpl’s solution, one message up, works but is really ugly.

I just updated package.json such that typescript points to 3.5.3 and did an npm install. That’s it.