| 255 | } |
| 256 | |
| 257 | function resolveExternal() { |
| 258 | const treeShakenDeps = [ |
| 259 | 'source-map-js', |
| 260 | '@babel/parser', |
| 261 | 'estree-walker', |
| 262 | 'entities/decode', |
| 263 | ] |
| 264 | |
| 265 | if (isGlobalBuild || isBrowserESMBuild || isCompatPackage) { |
| 266 | if (!packageOptions.enableNonBrowserBranches) { |
| 267 | // normal browser builds - non-browser only imports are tree-shaken, |
| 268 | // they are only listed here to suppress warnings. |
| 269 | return treeShakenDeps |
| 270 | } |
| 271 | } else { |
| 272 | // Node / esm-bundler builds. |
| 273 | // externalize all direct deps unless it's the compat build. |
| 274 | return [ |
| 275 | ...Object.keys(pkg.dependencies || {}), |
| 276 | ...Object.keys(pkg.peerDependencies || {}), |
| 277 | // for @vue/compiler-sfc / server-renderer |
| 278 | ...['path', 'url', 'stream'], |
| 279 | // somehow these throw warnings for runtime-* package builds |
| 280 | ...treeShakenDeps, |
| 281 | ] |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | function resolveNodePlugins() { |
| 286 | // we are bundling forked consolidate.js in compiler-sfc which dynamically |