Skip to content

Missing imports in ESM .js files do not produce errors (only warnings) #14421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gkalpak opened this issue May 14, 2019 · 1 comment · Fixed by #14435
Closed

Missing imports in ESM .js files do not produce errors (only warnings) #14421

gkalpak opened this issue May 14, 2019 · 1 comment · Fixed by #14435

Comments

@gkalpak
Copy link
Member

gkalpak commented May 14, 2019

🐞 Bug report

Command (mark with an x)

- [x] build

Is this a regression?

N/A

Description

When an esm5/esm2015 .js file is trying to import a non-existing export, there is a warning emitted during ng build, but no hard error. Note this only affects .js files, since missing imports fail in .ts files.

For context:
We ran into this in angular/angular#30362, where esm files in @angular/material ended up trying to import missing exports from @angular/core. The build succeeded (with warnings only), but the app is broken.
(See angular/angular#30362 (comment) for more details.)

🔬 Minimal Reproduction

This is a contrived minimal reproduction that produces the same error as the one seen in angular/angular#30362:

  • Download and unzip test-app.zip.
  • Run npm install.
  • Run npm run build.

The repro project was created with ng new test-app --defaults and the following changes:

  • Change src/main.ts to src/main.js in angular.json.
  • Add src/main.js in tsconfig.json > include.
  • Rename src/main.ts to src/main.js and update its content to import missingExport from @angular/core.

🔥 Exception or Error


WARNING in ./src/main.js 2:12-25
"export 'missingExport' was not found in '@angular/core'

🌍 Your Environment


Angular CLI: 8.0.0-rc.3
Node: 10.15.3
OS: win32 x64
Angular: 8.0.0-rc.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-rc.3
@angular-devkit/build-angular     0.800.0-rc.3
@angular-devkit/build-optimizer   0.800.0-rc.3
@angular-devkit/build-webpack     0.800.0-rc.3
@angular-devkit/core              8.0.0-rc.3
@angular-devkit/schematics        8.0.0-rc.3
@ngtools/webpack                  8.0.0-rc.3
@schematics/angular               8.0.0-rc.3
@schematics/update                0.800.0-rc.3
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.