( args: BuildOptions, downloadResult: Awaited<ReturnType<typeof downloadInstallAndBundle>> )
| 25 | } |
| 26 | |
| 27 | export const maybeDoBuildCommand = async ( |
| 28 | args: BuildOptions, |
| 29 | downloadResult: Awaited<ReturnType<typeof downloadInstallAndBundle>> |
| 30 | ) => { |
| 31 | const buildCommandResult = await maybeExecBuildCommand(args, downloadResult); |
| 32 | const outputSetting = args.config.outputDirectory; |
| 33 | |
| 34 | let outputDir: string | undefined; |
| 35 | let entrypoint: string | undefined; |
| 36 | if (buildCommandResult && outputSetting) { |
| 37 | if (outputSetting) { |
| 38 | const _outputDir = join(args.workPath, outputSetting); |
| 39 | // Skip when `outputDirectory` is the project root itself (e.g. `.`): |
| 40 | // globbing it would sweep in `node_modules` and break tracing. Fall back |
| 41 | // to the rolldown bundle instead. |
| 42 | if (resolve(_outputDir) !== resolve(args.workPath)) { |
| 43 | const _entrypoint = await findEntrypointInOutputDir(_outputDir); |
| 44 | if (_entrypoint) { |
| 45 | outputDir = _outputDir; |
| 46 | entrypoint = _entrypoint; |
| 47 | } |
| 48 | } |
| 49 | } else { |
| 50 | const commonOutputDirectories = ['dist', 'build', 'output']; |
| 51 | for (const outputDirectory of commonOutputDirectories) { |
| 52 | const _outputDir = join(args.workPath, outputDirectory); |
| 53 | if (existsSync(_outputDir)) { |
| 54 | const _entrypoint = await findEntrypointInOutputDir(_outputDir); |
| 55 | if (_entrypoint) { |
| 56 | outputDir = _outputDir; |
| 57 | entrypoint = _entrypoint; |
| 58 | break; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | const localBuildFiles = new Set<string>(); |
| 65 | let files: Files | undefined; |
| 66 | if (outputDir && entrypoint) { |
| 67 | files = await glob('**', outputDir); |
| 68 | for (const file of Object.keys(files)) { |
| 69 | localBuildFiles.add(join(outputDir, file)); |
| 70 | } |
| 71 | } |
| 72 | return { localBuildFiles, files, handler: entrypoint, outputDir }; |
| 73 | }; |
no test coverage detected