Skip to content

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

Closed

Description

@kawamoto

🐞 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?

Activity

  1. added this to the needsTriage milestone on Jun 14, 2019
  2. modified the milestones: needsTriage, Backlog on Jun 14, 2019
  3. modified the milestones: Backlog, 8.0.x on Jun 14, 2019
  4. added 2 commits that reference this issue on Jun 19, 2019
    3bb67d8
    e816de7
  5. sazalihisham88 commented on Jun 21, 2019

    @sazalihisham88

    has this fix released?

  6. mgechev commented on Jun 22, 2019

    @mgechev
    Member

    Not yet. We'll release early next week.

  7. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Sep 9, 2019
  9. added a commit that references this issue on May 29, 2026
    4b85003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions