Skip to content

Commit

Permalink
fix: correctly ignore optional deps when bundling vite deps (#4223)
Browse files Browse the repository at this point in the history
Fixes #3977
Fixes #3850
  • Loading branch information
sodatea committed Jul 12, 2021
1 parent dceacc7 commit b5ab77d
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions packages/vite/rollup.config.js
Expand Up @@ -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(),
Expand Down Expand Up @@ -261,26 +257,6 @@ function shimDepsPlugin(deps) {
}
}

/**
* @type { (deps: Record<string, any>) => 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) {
Expand Down

0 comments on commit b5ab77d

Please sign in to comment.