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

Function programOf

ark/aot/nextProgram.ts:118–141  ·  view source on GitHub ↗
(
	root: string,
	opts: PrecompilePluginOptions
)

Source from the content-addressed store, hash-verified

116
117// as next.config's wrapper read it for this build
118export const programOf = (
119 root: string,
120 opts: PrecompilePluginOptions
121): ReadProgramDir => {
122 const dir = programDirOf(root, opts)
123 const read = process.env[readEnv]
124 if (read !== dir) {
125 return {
126 dir,
127 refused: writeUnreadProgramMessage(
128 read === undefined ?
129 "next.config doesn't export its config through withPrecompile, which reads the project before Turbopack starts"
130 : "next.config read it from another directory or with other loader options"
131 )
132 }
133 }
134 return {
135 dir,
136 ...(JSON.parse(readFileSync(doneFileOf(dir), "utf8")) as Pick<
137 ProgramDone,
138 "refused"
139 >)
140 }
141}
142
143// whether next.config's wrapper read it for this build, under whatever options
144export const isProgramRead = (): boolean => process.env[readEnv] !== undefined

Callers 1

answerFromProgramFunction · 0.90

Calls 3

programDirOfFunction · 0.85
doneFileOfFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected