( bundler: BundlerCompiler, compilation: BundlerCompilation, read: BuiltRead )
| 763 | native.loaderContext?.cacheable(false) |
| 764 | } |
| 765 | const answerBuilt = async ( |
| 766 | bundler: BundlerCompiler, |
| 767 | compilation: BundlerCompilation, |
| 768 | read: BuiltRead |
| 769 | ) => { |
| 770 | const warn = (warning: string) => |
| 771 | compilation.warnings.push(new bundler.webpack.WebpackError(warning)) |
| 772 | const resolve = compilerResolveOf(bundler) |
| 773 | const asBuilt = |
| 774 | definedProblemOf(bundler) ?? |
| 775 | programAsBuilt( |
| 776 | `${++scans}`, |
| 777 | builtEntriesOf(compilation, read, isTransformedId), |
| 778 | { isTransformed: isTransformedId, cwd: realCwd() } |
| 779 | ) |
| 780 | const [program, built] = |
| 781 | typeof asBuilt === "string" ? |
| 782 | [asBuilt, {} as Record<string, string>] |
| 783 | : withoutBuilt(asBuilt) |
| 784 | const usage = |
| 785 | typeof program === "string" ? |
| 786 | writeUnprunedMessage(program) |
| 787 | : await scanChoosing(resolve, program).catch(unreadMessageOf) |
| 788 | const scanned = |
| 789 | ( |
| 790 | typeof program !== "string" && |
| 791 | typeof usage !== "string" && |
| 792 | usage.written |
| 793 | ) ? |
| 794 | program |
| 795 | : undefined |
| 796 | if (typeof usage === "string") warn(usage) |
| 797 | else { |
| 798 | for (const warning of warningsOf(usage)) warn(warning) |
| 799 | if (scanned) read.issues = usage.issues |
| 800 | } |
| 801 | read.program = scanned |
| 802 | read.answering = true |
| 803 | // a module it leaves as it is needn't build again, which only a read shows |
| 804 | const rewritten = |
| 805 | scanned && new Set(await rewrittenIn(scanned, compilation, resolve)) |
| 806 | const modules = [...(compilation.modules as Iterable<BuiltBundlerModule>)] |
| 807 | const written = modules.filter(({ resource }) => { |
| 808 | if (!resource) return false |
| 809 | const file = fileOf(resource) |
| 810 | return ( |
| 811 | issueFeaturesFile.test(file) || |
| 812 | // built again whatever it read, as a cache may hold each written |
| 813 | // for a program that was pruned and is no longer |
| 814 | readsIssueFeatures(file) || |
| 815 | (rewritten ? rewritten.has(file) : isTransformedId(file)) |
| 816 | ) |
| 817 | }) |
| 818 | // Rspack builds what it's asked for itself, and gives another module to |
| 819 | // one that's read once rebuilt |
| 820 | if (meta.framework === "webpack") { |
| 821 | read.written = written |
| 822 | askAgainOf(compilation, written) |
no test coverage detected