MCPcopy
hub / github.com/webpack/webpack / compile

Function compile

test/test262.spectest.js:466–556  ·  view source on GitHub ↗
(entry, scenario, options = {})

Source from the content-addressed store, hash-verified

464);
465
466const compile = async (entry, scenario, options = {}) =>
467 new Promise((resolve, reject) => {
468 const compiler = webpack({
469 ...options,
470 entry,
471 context: path.dirname(entry),
472 output: {
473 ...options.output,
474 ...(scenario === "module" ? { module: true } : { iife: false })
475 },
476 mode: options.mode || "development",
477 target: "node",
478 devtool: false,
479 stats: "errors-warnings",
480 performance: false,
481 experiments: {
482 outputModule: scenario === "module",
483 deferImport: true
484 },
485 optimization: {
486 emitOnErrors: true,
487 minimize: false
488 },
489 cache: false,
490 module: {
491 parser: {
492 javascript: {
493 // For dynamic import test cases
494 exprContextRegExp: /.*_FIXTURE\.js$/,
495 exprContextRequest: path.dirname(entry),
496 exprContextCritical: false,
497 // For testing purposes, where the `export` is tested that it is not defined
498 exportsPresence: false,
499 reexportExportsPresence: false
500 }
501 },
502 rules:
503 // For top level await, maybe we can improve our parser to detect and switch to module
504 scenario === "module"
505 ? [
506 {
507 // Avoid override `type` when we have `bytes` or `text` type
508 with: {
509 type: (value) => value !== "bytes" && value !== "text"
510 },
511 test: /\.js$/,
512 type: "javascript/esm"
513 }
514 ]
515 : [
516 // TODO do we need to use just `javascript/dynamic`?
517 {
518 test: edgeCasesRegExp,
519 parser: {
520 commonjs: false,
521 amd: false,
522 harmony: false,
523 requireJs: false,

Callers 1

Calls 5

resolveFunction · 0.85
callbackFunction · 0.70
webpackFunction · 0.50
runMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected