-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
esbuild keepNames not respected #13727
Comments
Seems like import { defineConfig } from "vitest/config";
export default defineConfig({
esbuild: {
keepNames: true, // ---> not allowed in `esbuild`
},
test: {
globals: true,
},
}) |
That doesn't seem to be the case for me and looking at the source types: UserConfig.esbuild is typed as ESBuildOptions The main problem is that Vite doesn't expose |
I mean the option itself is disabled in vite: Code from Vite.js repo// packages/vite/src/node/plugins/esbuild.ts
const transformOptions: TransformOptions = {
target: 'esnext',
charset: 'utf8',
...esbuildTransformOptions,
minify: false,
minifyIdentifiers: false,
minifySyntax: false,
minifyWhitespace: false,
treeShaking: false,
// keepNames is not needed when minify is disabled.
// Also transforming multiple times with keepNames enabled breaks
// tree-shaking. (#9164)
keepNames: false,
} |
Ah oh see, sorry I thought you meant that it's not allowed under with typing. It looks like whilst generally |
I would assume that we need to disable configResolved(config) {
if (config.command === 'build') {
transformOptions.keepNames = false
}
} |
@sheremet-va Do you mind if I open a PR for that modification? |
Wouldn't that just fix serve mode and break it when built? |
This then? configResolved(config) {
if (config.command === 'build' && config.build.minify === 'esbuild') {
transformOptions.keepNames = false
}
} |
Would that then require to minify to be set to |
So the I think #9166 may as well be reverted unless we get to find a solution that makes both tree-shaking and |
is this still a bug? |
i would also like 'keepNames' to be respected |
Describe the bug
Keeps names is being overridden https:/vitejs/vite/blame/6f1c55e7d694dd26f9eca30239faeb5a59c41486/packages/vite/src/node/plugins/esbuild.ts#L226
This is confusing because the type definition for
vite.config.ts
accepts it.And whilst generally it doesn't seem to be a problem when a class references itself:
esbuild prefixes the class with an underscore.
Originally reported on Vitest, @sheremet-va suggested this was introduced as a fix for #9164
Reproduction
https:/spence-novata/vitest-keep-name-poc
Steps to reproduce
npm i
npm run test
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: