(bundler: BundlerCompiler)
| 502 | from |
| 503 | )) |
| 504 | const keepCompiler = (bundler: BundlerCompiler) => { |
| 505 | compiler = bundler |
| 506 | resolveIn(bundler.options.mode === "development") |
| 507 | // a closed compiler releases its worker. buildEnd releases it only from |
| 508 | // the emit hook, which a production build failing doesn't reach, so |
| 509 | // each compiler a process ran, as a test runner's, held its own |
| 510 | bundler.hooks.shutdown?.tap("arktype", restart) |
| 511 | // a persistent cache keeps what other options or code precompiled, so |
| 512 | // they version it |
| 513 | const { cache } = bundler.options |
| 514 | if (cache && typeof cache === "object") { |
| 515 | const version = `arktype ${fingerprintOfCode()} ${JSON.stringify(set)}` |
| 516 | cache.version = cache.version ? `${cache.version} ${version}` : version |
| 517 | } |
| 518 | // a production build reads its modules once it has built them as they |
| 519 | // are, then writes those its validators need written, as only then can it |
| 520 | // know what a generated entry or a plugin's import reads. A child |
| 521 | // compilation's modules run apart from them, and are written whole |
| 522 | bundler.hooks.thisCompilation.tap("arktype", compilation => { |
| 523 | if (!prunesIn(!!environment?.production)) return |
| 524 | const read: BuiltRead = { |
| 525 | loaded: new Map(), |
| 526 | mappings: new Map(), |
| 527 | written: [] |
| 528 | } |
| 529 | builtReads.set(compilation, read) |
| 530 | compilation.hooks.finishModules.tapPromise( |
| 531 | // ahead of what reads the modules as they end |
| 532 | { name: "arktype", stage: -1000 } as never, |
| 533 | () => answerBuilt(bundler, compilation, read) |
| 534 | ) |
| 535 | compilation.hooks.seal.tap("arktype", () => { |
| 536 | const unbuilt = unbuiltReadOf(compilation, read.written) |
| 537 | if (unbuilt) { |
| 538 | compilation.errors.push( |
| 539 | new bundler.webpack.WebpackError( |
| 540 | writeUnbuiltReadMessage( |
| 541 | printablePathOf(realCwd(), unbuilt[0]), |
| 542 | unbuilt[1] |
| 543 | ) |
| 544 | ) |
| 545 | ) |
| 546 | } |
| 547 | if (!read.program) return |
| 548 | const late = unreadBuiltOf( |
| 549 | read.program, |
| 550 | builtEntriesOf(compilation, read, isTransformedId), |
| 551 | { isTransformed: isTransformedId } |
| 552 | ) |
| 553 | if (!late) return |
| 554 | compilation.errors.push( |
| 555 | new bundler.webpack.WebpackError( |
| 556 | writeUnseenMessage( |
| 557 | `a plugin built ${printablePathOf(realCwd(), late)} once it had read them` |
| 558 | ) |
| 559 | ) |
| 560 | ) |
| 561 | }) |
no test coverage detected