From 38524f6c6e864f9805dd0083da1dfa8ce20fa816 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 22 Jan 2021 22:04:51 -0500 Subject: [PATCH] refactor: remove optimizeDeps.plugins 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. --- docs/config/index.md | 8 ++++---- packages/vite/src/node/optimizer/index.ts | 10 ++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/config/index.md b/docs/config/index.md index c614f0298712ea..9d46f835bd66dc 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -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 diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 40664fc642c49a..ffae3c55790b2d 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -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' @@ -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 { @@ -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 } },