From b5ab77d878d7bdc5c68dbbf144395f2a590f7d99 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Mon, 12 Jul 2021 21:04:28 +0800 Subject: [PATCH] fix: correctly ignore optional deps when bundling vite deps (#4223) Fixes #3977 Fixes #3850 --- packages/vite/rollup.config.js | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/vite/rollup.config.js b/packages/vite/rollup.config.js index 4be0533f4404b7..8b1bda554695ad 100644 --- a/packages/vite/rollup.config.js +++ b/packages/vite/rollup.config.js @@ -161,14 +161,10 @@ const createNodeConfig = (isProduction) => { replacement: `: eval('require'),` } }), - // Optional peer deps of ws. Native deps that are mostly for performance. - // Since ws is not that perf critical for us, just ignore these deps. - ignoreDepPlugin({ - bufferutil: 1, - 'utf-8-validate': 1 - }), commonjs({ extensions: ['.js'], + // Optional peer deps of ws. Native deps that are mostly for performance. + // Since ws is not that perf critical for us, just ignore these deps. ignore: ['bufferutil', 'utf-8-validate'] }), json(), @@ -261,26 +257,6 @@ function shimDepsPlugin(deps) { } } -/** - * @type { (deps: Record) => import('rollup').Plugin } - */ -function ignoreDepPlugin(ignoredDeps) { - return { - name: 'ignore-deps', - resolveId(id) { - if (id in ignoredDeps) { - return id - } - }, - load(id) { - if (id in ignoredDeps) { - console.log(`ignored: ${id}`) - return '' - } - } - } -} - function licensePlugin() { return license({ thirdParty(dependencies) {