Skip to content

Minifying the code in 3 passes leads to a syntax error #3051

Description

@cawa-93

Describe the bug

If set up terser with passes >=3

terserOptions: {
  compress: {
    passes: 3
  }
}

The application does not load, you may see an error in the console:

Uncaught SyntaxError: identifier starts immediately after numeric literal

The cause of the problem is the minification of the code using a terser. It occurs if 3 or more passes are configured.

I thought this was a problem with the terser and tried for a long time to reproduce the error in REPL. But no matter what I do, everything works as expected and it happens only when the code is optimized through the Vite.

Reproduction

Reproduction repo: cawa-93/vite-terser-issue

  1. Clone reproduction repo: git clone [email protected]:cawa-93/vite-terser-issue.git
  2. cd ./vite-terser-issue
  3. Install deps: npm ci
  4. Build and serve npm run build && npm run sevce
  5. Open app http://localhost:5000

System Info

  System:
    OS: Windows 10 10.0.19042
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 9.36 GB / 15.42 GB
  Binaries:
    Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (90.0.818.41)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.1 => 1.2.1
    vite: ^2.2.0 => 2.2.0

Used package manager: npm

Before submitting the issue, please make sure you do the following

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions