diff --git a/src/config/rollup.config.js b/src/config/rollup.config.js index a782bd53..3d8210e1 100644 --- a/src/config/rollup.config.js +++ b/src/config/rollup.config.js @@ -88,8 +88,19 @@ if (isPreact) { } const externalPattern = new RegExp(`^(${external.join('|')})($|/)`) -const externalPredicate = - external.length === 0 ? () => false : id => externalPattern.test(id) + +function externalPredicate(id) { + const isDep = externalPattern.test(id) + if (umd) { + // for UMD, we want to bundle all non-peer deps + return isDep + } + // for esm/cjs we want to make all node_modules external + // TODO: support bundledDependencies if someone needs it ever... + const isNodeModule = id.includes('node_modules') + const isRelative = id.startsWith('.') + return isDep || (!isRelative && !path.isAbsolute(id)) || isNodeModule +} const filename = [ pkg.name,