Skip to content

Commit

Permalink
refactor: remove optimizeDeps.plugins
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `optimizeDeps.plugins` has been removed. The dep
optimizer is now using `esbuild`, and all non-js files are automatically
externalized to be processed by Vite's transform pipeline when imported.
  • Loading branch information
yyx990803 committed Jan 23, 2021
1 parent 2261fc3 commit 38524f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 4 additions & 4 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ export default ({ command, mode }) => {

Dependencies to force exclude in pre-bundling.

### optimizeDeps.plugins
### optimizeDeps.link

- **Type:** `Plugin[]`
- **Type:** `string[]`

By default, Vite assumes dependencies ship plain JavaScript and will not attempt to transform non-js file formats during pre-bundling. If you wish to support special file types, e.g. `.vue` files, you will need to supply the relevant plugins via this option.
A list of packages to be treated as "linked". Linked packages will not be pre-bundled - Vite will analyze and pre-bundle its depndencies instead.

Note that you will also need to include these plugins in the main `plugins` option in order to support the same file types during production build.
Note that if you are using a monorepo via package manager workspaces, and have the packages listed as dependencies in your Vite entry package, Vite will automatically treat them as linked (by checking if it's inside `node_modules`). This option is only needed if you have unusual setups where your Vite app is importing from a package that isn't already linked as a Node-resolvable dependency.

### optimizeDeps.auto

Expand Down
10 changes: 2 additions & 8 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import { tryNodeResolve } from '../plugins/resolve'
import aliasPlugin from '@rollup/plugin-alias'
import { createFilter } from '@rollup/pluginutils'
import { Plugin } from '../plugin'
import { prompt } from 'enquirer'
import { build } from 'esbuild'
import { esbuildDepPlugin } from './esbuildDepPlugin'
Expand Down Expand Up @@ -57,18 +56,14 @@ export interface DepOptimizationOptions {
*/
exclude?: string | RegExp | (string | RegExp)[]
/**
* Plugins to use for dep optimizations.
* A list of linked dependencies that should be treated as source code.
*/
plugins?: Plugin[]
link?: string[]
/**
* Automatically run `vite optimize` on server start?
* @default true
*/
auto?: boolean
/**
* A list of linked dependencies that should be treated as source code.
*/
link?: string[]
}

export interface DepOptimizationMetadata {
Expand Down Expand Up @@ -429,7 +424,6 @@ function getDepHash(
optimizeDeps: {
include: config.optimizeDeps?.include,
exclude: config.optimizeDeps?.exclude,
plugins: config.optimizeDeps?.plugins?.map((p) => p.name),
link: config.optimizeDeps?.link
}
},
Expand Down

0 comments on commit 38524f6

Please sign in to comment.