(options, entry, format, writeMeta)
| 324 | const shebang = {}; |
| 325 | |
| 326 | function createConfig(options, entry, format, writeMeta) { |
| 327 | let { pkg } = options; |
| 328 | |
| 329 | /** @type {(string|RegExp)[]} */ |
| 330 | let external = ['dns', 'fs', 'path', 'url']; |
| 331 | |
| 332 | /** @type {Record<string, string>} */ |
| 333 | let outputAliases = {}; |
| 334 | |
| 335 | const moduleAliases = options.alias ? parseAliasArgument(options.alias) : []; |
| 336 | const aliasIds = moduleAliases.map(alias => alias.find); |
| 337 | |
| 338 | // We want to silence rollup warnings for node builtins as we rollup-node-resolve threats them as externals anyway |
| 339 | // @see https://github.com/rollup/plugins/tree/master/packages/node-resolve/#resolving-built-ins-like-fs |
| 340 | if (options.target === 'node') { |
| 341 | external = [/node:.*/].concat(builtinModules); |
| 342 | } |
| 343 | |
| 344 | const peerDeps = Object.keys(pkg.peerDependencies || {}); |
| 345 | if (options.external === 'none') { |
| 346 | // bundle everything (external=[]) |
| 347 | } else if (options.external) { |
| 348 | external = external.concat(peerDeps).concat( |
| 349 | // CLI --external supports regular expressions: |
| 350 | options.external.split(',').map(str => new RegExp(str)), |
| 351 | ); |
| 352 | } else { |
| 353 | external = external |
| 354 | .concat(peerDeps) |
| 355 | .concat(Object.keys(pkg.dependencies || {})); |
| 356 | } |
| 357 | |
| 358 | let globals = external.reduce((globals, name) => { |
| 359 | // Use raw value for CLI-provided RegExp externals: |
| 360 | if (name instanceof RegExp) name = name.source; |
| 361 | |
| 362 | // valid JS identifiers are usually library globals: |
| 363 | if (name.match(/^[a-z_$][a-z0-9_\-$]*$/)) { |
| 364 | globals[name] = camelCase(name); |
| 365 | } |
| 366 | return globals; |
| 367 | }, {}); |
| 368 | if (options.globals && options.globals !== 'none') { |
| 369 | globals = Object.assign(globals, parseMappingArgument(options.globals)); |
| 370 | } |
| 371 | |
| 372 | let defines = {}; |
| 373 | if (options.define) { |
| 374 | defines = Object.assign( |
| 375 | defines, |
| 376 | parseMappingArgument(options.define, toReplacementExpression), |
| 377 | ); |
| 378 | } |
| 379 | |
| 380 | const modern = format === 'modern'; |
| 381 | |
| 382 | // let rollupName = safeVariableName(basename(entry).replace(/\.js$/, '')); |
| 383 |
no test coverage detected
searching dependent graphs…