test: launch QA standalone server as CommonJS
This commit is contained in:
1 parent
a149dbdfab
commit
d2cc9780e7
2 files changed
+7
-2
No files matched your search
@@ -90,7 +90,8 @@ export const createCandidateBuildPaths = (candidateSha: string) => {
|
||||
buildDir,
|
||||
standaloneRoot,
|
||||
standaloneAppDir,
|
||||
serverPath: path.join(standaloneAppDir, "server.js"),
|
||||
generatedServerPath: path.join(standaloneAppDir, "server.js"),
|
||||
serverPath: path.join(standaloneAppDir, "server.cjs"),
|
||||
markerPath: path.join(buildDir, "qa-build-manifest.json"),
|
||||
};
|
||||
};
|
||||
@@ -431,6 +432,9 @@ const ensureCandidateBuild = async (runRoot: string, candidateSha: string) => {
|
||||
await mkdir(path.dirname(staticTarget), { recursive: true });
|
||||
await cp(path.join(buildPaths.buildDir, "static"), staticTarget, { recursive: true, force: true });
|
||||
await cp(path.join(buildPaths.appRoot, "public"), publicTarget, { recursive: true, force: true });
|
||||
// The app package is ESM, while Next emits a CommonJS standalone launcher.
|
||||
// Give the generated launcher an explicit CommonJS extension before executing it.
|
||||
await rename(buildPaths.generatedServerPath, buildPaths.serverPath);
|
||||
const serverStats = await stat(buildPaths.serverPath);
|
||||
if (!serverStats.isFile()) throw new Error(`Standalone server is missing after build: ${buildPaths.serverPath}`);
|
||||
await writeJsonAtomic(buildPaths.markerPath, {
|
||||
|
||||
@@ -139,7 +139,8 @@ describe("release-v2 QA app execution contract", () => {
|
||||
const paths = createCandidateBuildPaths("0123456789abcdef0123456789abcdef01234567");
|
||||
|
||||
expect(paths.distDirName).toBe(".next-qa/release-v2-0123456789abcdef0123456789abcdef01234567");
|
||||
expect(paths.serverPath).toBe(`${paths.buildDir}/standalone/apps/nextjs/server.js`);
|
||||
expect(paths.generatedServerPath).toBe(`${paths.buildDir}/standalone/apps/nextjs/server.js`);
|
||||
expect(paths.serverPath).toBe(`${paths.buildDir}/standalone/apps/nextjs/server.cjs`);
|
||||
expect(paths.standaloneRoot).toBe(`${paths.buildDir}/standalone`);
|
||||
expect(() => createCandidateBuildPaths("not-a-commit")).toThrow(/40-character lowercase commit SHA/u);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user