( root: string, opts: PrecompilePluginOptions )
| 116 | |
| 117 | // as next.config's wrapper read it for this build |
| 118 | export 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 |
| 144 | export const isProgramRead = (): boolean => process.env[readEnv] !== undefined |
no test coverage detected