Skip to content

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

Description

@gkalpak

🐞 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions