Skip to content

Commit

Permalink
feat(dev): support keepNames option for optimizeDependencies config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
itsthekeming committed Mar 29, 2021
1 parent 38466d1 commit 130bf5a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 130bf5a

Please sign in to comment.