MCPcopy Create free account
hub / github.com/arktypeio/arktype / keepCompiler

Function keepCompiler

ark/aot/unplugin.ts:504–618  ·  view source on GitHub ↗
(bundler: BundlerCompiler)

Source from the content-addressed store, hash-verified

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 })

Callers 2

applyRspackFunction · 0.85
unplugin.tsFile · 0.85

Calls 15

fingerprintOfCodeFunction · 0.90
printablePathOfFunction · 0.90
unreadBuiltOfFunction · 0.90
writeUnseenMessageFunction · 0.90
unfoldedCallProblemOfFunction · 0.90
resolveInFunction · 0.85
prunesInFunction · 0.85
answerBuiltFunction · 0.85
unbuiltReadOfFunction · 0.85
realCwdFunction · 0.85
builtEntriesOfFunction · 0.85
bundlerImportsOfFunction · 0.85

Tested by

no test coverage detected