Skip to content

production build failed "Module parse failed" with "export default class" syntax #14769

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
kawamoto opened this issue Jun 14, 2019 · 3 comments · Fixed by #14773
Closed

production build failed "Module parse failed" with "export default class" syntax #14769

kawamoto opened this issue Jun 14, 2019 · 3 comments · Fixed by #14773
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@kawamoto
Copy link

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

build-optimizer: 0.800.1 works fine.

Description

A clear and concise description of the problem...

It seems #14585 breaks below syntax

export default class Foo { .. }

after this change, it converts that code to

export default const Foo = { .. }

export default const is not valid syntax. ng build --prod failed with above code in parsing by acorn cause of that syntax.

🔬 Minimal Reproduction

execute ng build --prod with this project
https://github.com/kawamoto/ng-export-default-class

🔥 Exception or Error





ERROR in ./src/app/foo.js 1:15
Module parse failed: Unexpected token (1:15)
You may need an appropriate loader to handle this file type.
> export default const Foo = /*@__PURE__*/ (() => {
|     class Foo {
|         constructor() {

🌍 Your Environment





Angular CLI: 8.0.2
Node: 11.3.0
OS: darwin x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.2
@angular-devkit/build-angular     0.800.2
@angular-devkit/build-optimizer   0.800.2
@angular-devkit/build-webpack     0.800.2
@angular-devkit/core              8.0.2
@angular-devkit/schematics        8.0.2
@angular/cli                      8.0.2
@ngtools/webpack                  8.0.2
@schematics/angular               8.0.2
@schematics/update                0.800.2
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

@alan-agius4 alan-agius4 added comp: devkit/build-optimizer freq1: low Only reported by a handful of users who observe it rarely severity5: regression labels Jun 14, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jun 14, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Jun 14, 2019
@alan-agius4 alan-agius4 modified the milestones: Backlog, 8.0.x Jun 14, 2019
mgechev pushed a commit that referenced this issue Jun 19, 2019
mgechev pushed a commit that referenced this issue Jun 19, 2019
@sazalihisham88
Copy link

has this fix released?

@mgechev
Copy link
Member

mgechev commented Jun 22, 2019

Not yet. We'll release early next week.

@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.
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants