| 283 | } |
| 284 | |
| 285 | function resolveNodePlugins() { |
| 286 | // we are bundling forked consolidate.js in compiler-sfc which dynamically |
| 287 | // requires a ton of template engines which should be ignored. |
| 288 | /** @type {ReadonlyArray<string>} */ |
| 289 | let cjsIgnores = [] |
| 290 | if (pkg.name === '@vue/compiler-sfc') { |
| 291 | cjsIgnores = [ |
| 292 | ...Object.keys(consolidatePkg.devDependencies), |
| 293 | 'vm', |
| 294 | 'crypto', |
| 295 | 'react-dom/server', |
| 296 | 'teacup/lib/express', |
| 297 | 'arc-templates/dist/es5', |
| 298 | 'then-pug', |
| 299 | 'then-jade', |
| 300 | ] |
| 301 | } |
| 302 | |
| 303 | const nodePlugins = |
| 304 | (format === 'cjs' && Object.keys(pkg.devDependencies || {}).length) || |
| 305 | packageOptions.enableNonBrowserBranches |
| 306 | ? [ |
| 307 | commonJS({ |
| 308 | sourceMap: false, |
| 309 | ignore: cjsIgnores, |
| 310 | }), |
| 311 | ...(format === 'cjs' ? [] : [polyfillNode()]), |
| 312 | nodeResolve(), |
| 313 | ] |
| 314 | : [] |
| 315 | |
| 316 | return nodePlugins |
| 317 | } |
| 318 | |
| 319 | return { |
| 320 | input: resolve(entryFile), |