feat(dev): support keepNames option for optimizeDependencies config (#2742)

This commit is contained in:
Edward Sanders 2021-03-29 16:24:14 -04:00 committed by GitHub
parent 38466d1248
commit 130bf5a03a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -569,6 +569,15 @@ export default ({ command, mode }) => {
By default, linked packages not inside `node_modules` are not pre-bundled. Use this option to force a linked package to be pre-bundled.
### optimizeDeps.keepNames
- **Type:** `boolean`
- **Default:** `false`
The bundler sometimes needs to rename symbols to avoid collisions.
Set this to `true` to keep the `name` property on functions and classes.
See [`keepNames`](https://esbuild.github.io/api/#keep-names).
## SSR Options
:::warning Experimental

View File

@ -46,6 +46,12 @@ export interface DepOptimizationOptions {
* cannot be globs).
*/
exclude?: string[]
/**
* The bundler sometimes needs to rename symbols to avoid collisions.
* Set this to `true` to keep the `name` property on functions and classes.
* https://esbuild.github.io/api/#keep-names
*/
keepNames?: boolean
}
export interface DepOptimizationMetadata {
@ -229,7 +235,7 @@ export async function optimizeDeps(
const result = await build({
entryPoints: Object.keys(flatIdDeps),
bundle: true,
keepNames: true,
keepNames: config.optimizeDeps?.keepNames,
format: 'esm',
external: config.optimizeDeps?.exclude,
logLevel: 'error',