fix(react): ssr should serve correctly and e2e should function (#17725)

This commit is contained in:
Colum Ferry 2023-06-22 14:51:41 +01:00 committed by GitHub
parent 1fcba1a43a
commit fffd84c3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 153 additions and 152 deletions

View File

@ -9,8 +9,8 @@ import {
} from '@nx/devkit'; } from '@nx/devkit';
import { daemonClient } from 'nx/src/daemon/client/client'; import { daemonClient } from 'nx/src/daemon/client/client';
import { randomUUID } from 'crypto'; import { randomUUID } from 'crypto';
import { join } from 'path';
import * as path from 'path'; import * as path from 'path';
import { join } from 'path';
import { InspectType, NodeExecutorOptions } from './schema'; import { InspectType, NodeExecutorOptions } from './schema';
import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable'; import { createAsyncIterable } from '@nx/devkit/src/utils/async-iterable';
@ -81,8 +81,10 @@ export async function* nodeExecutor(
const tasks: ActiveTask[] = []; const tasks: ActiveTask[] = [];
let currentTask: ActiveTask = null; let currentTask: ActiveTask = null;
yield* createAsyncIterable<{ success: boolean }>( yield* createAsyncIterable<{
async ({ done, next, error }) => { success: boolean;
options?: Record<string, any>;
}>(async ({ done, next, error }) => {
const processQueue = async () => { const processQueue = async () => {
if (tasks.length === 0) return; if (tasks.length === 0) return;
@ -110,9 +112,7 @@ export async function* nodeExecutor(
task.promise = new Promise<void>(async (resolve, reject) => { task.promise = new Promise<void>(async (resolve, reject) => {
task.childProcess = exec( task.childProcess = exec(
`npx nx run ${context.projectName}:${buildTarget.target}${ `npx nx run ${context.projectName}:${buildTarget.target}${
buildTarget.configuration buildTarget.configuration ? `:${buildTarget.configuration}` : ''
? `:${buildTarget.configuration}`
: ''
}`, }`,
{ {
cwd: context.root, cwd: context.root,
@ -185,7 +185,7 @@ export async function* nodeExecutor(
resolve(); resolve();
}); });
next({ success: true }); next({ success: true, options: buildOptions });
}); });
}, },
stop: async (signal = 'SIGTERM') => { stop: async (signal = 'SIGTERM') => {
@ -246,8 +246,7 @@ export async function* nodeExecutor(
await addToQueue(); await addToQueue();
await processQueue(); await processQueue();
} });
);
} }
function getExecArgv(options: NodeExecutorOptions) { function getExecArgv(options: NodeExecutorOptions) {
@ -284,6 +283,7 @@ function calculateResolveMappings(
return m; return m;
}, {}); }, {});
} }
function runWaitUntilTargets( function runWaitUntilTargets(
options: NodeExecutorOptions, options: NodeExecutorOptions,
context: ExecutorContext context: ExecutorContext

View File

@ -115,6 +115,7 @@ export async function setupSsrGenerator(tree: Tree, options: Schema) {
target: 'node', target: 'node',
main: `${projectRoot}/server.ts`, main: `${projectRoot}/server.ts`,
outputPath: joinPathFragments(originalOutputPath, 'server'), outputPath: joinPathFragments(originalOutputPath, 'server'),
outputFileName: 'server.js',
tsConfig: `${projectRoot}/tsconfig.server.json`, tsConfig: `${projectRoot}/tsconfig.server.json`,
compiler: 'babel', compiler: 'babel',
externalDependencies: 'all', externalDependencies: 'all',