Skip to content

Error while using typescript 3.8 export aliases #17231

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
TomTomB opened this issue Mar 14, 2020 · 8 comments
Closed

Error while using typescript 3.8 export aliases #17231

TomTomB opened this issue Mar 14, 2020 · 8 comments

Comments

@TomTomB
Copy link

TomTomB commented Mar 14, 2020

🐞 bug report

Description

Using typescript 3.8 export aliases produces an error while building.
Happens with ivy enabled as well as disabled.

🔬 Minimal Reproduction

  1. Clone the error repo https://github.com/TomTomB/named-exports-issue
  2. Run npm i
  3. Run ng serve
  4. Look inside the terminal output

🔥 Exception or Error

ERROR in ./src/app/stuff/index.ts 1:9
Module parse failed: Unexpected token (1:9)
File was processed with these loaders:
 * ./node_modules/@ngtools/webpack/src/index.js
You may need an additional loader to handle the result of these loaders.
> export * as fromFoo from './foo';

🌍 Your Environment

Angular CLI: 9.1.0-next.3
Node: 12.13.0
OS: win32 x64

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

Package Version

@angular-devkit/architect 0.901.0-next.3
@angular-devkit/build-angular 0.901.0-next.3
@angular-devkit/build-optimizer 0.901.0-next.3
@angular-devkit/build-webpack 0.901.0-next.3
@angular-devkit/core 9.1.0-next.3
@angular-devkit/schematics 9.1.0-next.3
@angular/cli 9.1.0-next.3
@ngtools/webpack 9.1.0-next.3
@schematics/angular 9.1.0-next.3
@schematics/update 0.901.0-next.3
rxjs 6.5.4
typescript 3.8.3
webpack 4.42.0

@JoostK
Copy link
Member

JoostK commented Mar 15, 2020

In your project, the "module" compiler flag in tsconfig.json is configured as "esnext". This means that the export is preserved as is, however some part of the toolchain is unable to process that syntax. If you change "module" to "es2015" instead it will work.

@JoostK
Copy link
Member

JoostK commented Mar 15, 2020

Looks like it's Webpack itself that has to support this syntax so that it can work its magic: webpack/webpack#10460

@TomTomB
Copy link
Author

TomTomB commented Mar 15, 2020

Setting the "module" flag to "es2015" only works, if lazy loading is not used.

Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.

12     loadChildren: () => import('./features/foo/foo.module').then((m) => m.FooModule)

@alan-agius4 alan-agius4 transferred this issue from angular/angular Mar 16, 2020
@ngbot ngbot bot added this to the needsTriage milestone Mar 16, 2020
@alan-agius4 alan-agius4 added the feature Issue that requests a new feature label Mar 16, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 16, 2020
@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely type: bug/fix and removed feature Issue that requests a new feature labels Mar 22, 2020
@ngbot ngbot bot modified the milestones: Backlog, needsTriage Mar 22, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 22, 2020
@troywweber7
Copy link

Is there a workaround for this?

@KingDarBoja
Copy link

Habing same issue as author, setting the module flag as "ES2015" will fix it if not using lazy loading, which does break with this change :/ Subscribing to this issue to know when it is fixed.

@brianpooe
Copy link

Any news yet on this?

@alan-agius4
Copy link
Collaborator

This should be fixed in Webpack 5 (webpack/webpack#11117), which is currently in opt-in preview in Angular CLI 11.

See #18820 for more information on how to opt-in Webpack 5.

@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 Nov 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants