Skip to content
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

Some terser options does not work with TypeScript, including mangle.properties.regex #11222

Closed
7 tasks done
cheuksing opened this issue Dec 6, 2022 · 2 comments
Closed
7 tasks done

Comments

@cheuksing
Copy link

Describe the bug

Some terser options does not work with TypeScript.

Expected: Typescripts class member with name starting with /^_/ to be mangled after build.
Actual: Nothing is mangled.

Minimal Settings. For reproduction please refers to the reproducing repository.

// vite.config.ts
build: {
    minify: 'terser',
    terserOptions: {
      mangle: {
        toplevel: true,
        module: true,
        properties: {
           regex: /^_/
         }
       },
       compress: {
        drop_console: true,
        drop_debugger: true,
       }
    }
}

Reproduction

https://github.com/cheuksing/vite-terser-issue-demo

Steps to reproduce

Run yarn followed by yarn build.
See the build result in dist.

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11600 @ 2.80GHz
    Memory: 3.40 GB / 15.87 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (107.0.1418.62)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    vite: latest => 3.2.5

Used Package Manager

yarn

Logs

No response

Validations

@CT-LX
Copy link

CT-LX commented Mar 22, 2023

I have the same problem,when i use uni-app

@patak-dev
Copy link
Member

This works if you define build.target: 'es2022', so esbuild won't use a helper to support instance class fields.
The ES build would not be mangled/minified though, there is another issue tracking this #6555

@patak-dev patak-dev closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 10, 2023
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

3 participants