Skip to content

Commit

Permalink
fix(nextjs): Custom server should run on fresh apps without errors (#…
Browse files Browse the repository at this point in the history
…17806)

(cherry picked from commit bd7157b)
  • Loading branch information
ndcunningham authored and FrozenPandaz committed Jun 27, 2023
1 parent ee46f99 commit 2deb3a9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/js/src/executors/node/node.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,19 @@ export async function* nodeExecutor(

// Re-map buildable workspace projects to their output directory.
const mappings = calculateResolveMappings(context, options);

const outputFileName =
buildOptions.outputFileName ?? `${path.parse(buildOptions.main).name}.js`;
let outputFileName =
buildOptions.outputFileName || `${path.parse(buildOptions.main).name}.js`;

if (!buildOptions.outputFileName) {
const matches = buildOptions.main.match(/^(?!.*src)(.*)\/([^/]*)$/); //ignore strings that contain src and split paths into [folders before main, main.ts]
if (matches) {
const [mainFolder, mainFileName] = matches.slice(1);
outputFileName = path.join(
mainFolder,
`${path.parse(mainFileName).name}.js`
);
}
}

const fileToRun = join(context.root, buildOptions.outputPath, outputFileName);
const tasks: ActiveTask[] = [];
Expand Down

0 comments on commit 2deb3a9

Please sign in to comment.