Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix playwright oom #21755

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"@supabase/supabase-js": "^2.26.0",
"@svgr/rollup": "^8.0.1",
"@svgr/webpack": "^8.0.1",
"@swc-node/register": "1.6.8",
"@swc-node/register": "1.8.0",
"@swc/cli": "0.1.62",
"@swc/core": "^1.3.85",
"@swc/jest": "^0.2.20",
Expand Down
9 changes: 2 additions & 7 deletions packages/devkit/src/utils/config-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dirname, extname, join, relative } from 'path';
import { dirname, extname, join } from 'path';
import { existsSync, readdirSync } from 'fs';
import { requireNx } from '../../nx';

Expand All @@ -21,12 +21,7 @@ export async function loadConfigFile<T extends object = any>(
? join(dirname(configFilePath), 'tsconfig.json')
: getRootTsConfigPath();
if (tsConfigPath) {
const unregisterTsProject = registerTsProject(
tsConfigPath,
undefined,
// TODO(@AgentEnder): Remove this hack to make sure that e2e loads properly for next.js
relative(workspaceRoot, dirname(configFilePath)) === 'e2e'
);
const unregisterTsProject = registerTsProject(tsConfigPath);
try {
module = await load(configFilePath);
} finally {
Expand Down
9 changes: 9 additions & 0 deletions packages/js/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@
"alwaysAddToPackageJson": false
}
}
},
"18.0.4": {
"version": "18.0.4-beta.0",
"packages": {
"@swc-node/register": {
"version": "~1.8.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/js/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const prettierVersion = '^2.6.2';
export const swcCliVersion = '~0.1.62';
export const swcCoreVersion = '~1.3.85';
export const swcHelpersVersion = '~0.5.2';
export const swcNodeVersion = '~1.6.7';
export const swcNodeVersion = '~1.8.0';
export const tsLibVersion = '^2.3.0';
export const typesNodeVersion = '18.16.9';
export const verdaccioVersion = '^5.0.4';
Expand Down
9 changes: 9 additions & 0 deletions packages/next/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@
"alwaysAddToPackageJson": false
}
}
},
"18.0.4": {
"version": "18.0.4-beta.0",
"packages": {
"@swc-node/register": {
"version": "~1.8.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
2 changes: 1 addition & 1 deletion packages/next/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export const tsLibVersion = '^2.3.0';
export const swcCliVersion = '~0.1.62';
export const swcCoreVersion = '~1.3.85';
export const swcHelpersVersion = '~0.5.2';
export const swcNodeVersion = '~1.6.7';
export const swcNodeVersion = '~1.8.0';
2 changes: 1 addition & 1 deletion packages/nx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"ora": "5.3.0"
},
"peerDependencies": {
"@swc-node/register": "^1.6.7",
"@swc-node/register": "^1.8.0",
"@swc/core": "^1.3.85"
},
"peerDependenciesMeta": {
Expand Down
44 changes: 8 additions & 36 deletions packages/nx/src/plugins/js/utils/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,17 @@ export function registerTsProject(tsConfigPath: string): () => void;
* @returns cleanup function
* @deprecated This signature will be removed in Nx v19. You should pass the full path to the tsconfig in the first argument.
*/
export function registerTsProject(path: string, configFilename: string);
export function registerTsProject(
path: string,
configFilename: string,
/**
* @deprecated Do not use this.. it's a 1-off exception
*/
useForSwcEnvironmentVariable?: boolean
);
export function registerTsProject(
path: string,
configFilename?: string,
/**
* @deprecated Do not use this.. it's a 1-off exception
*/
useForSwcEnvironmentVariable?: boolean
configFilename?: string
): () => void {
const tsConfigPath = configFilename ? join(path, configFilename) : path;
const compilerOptions: CompilerOptions = readCompilerOptions(tsConfigPath);

const cleanupFunctions: ((...args: unknown[]) => unknown)[] = [
registerTsConfigPaths(tsConfigPath),
registerTranspiler(
compilerOptions,
useForSwcEnvironmentVariable ? tsConfigPath : undefined
),
registerTranspiler(compilerOptions),
];

// Add ESM support for `.ts` files.
Expand All @@ -80,24 +66,14 @@ export function registerTsProject(
}

export function getSwcTranspiler(
compilerOptions: CompilerOptions,
tsConfigPath?: string
compilerOptions: CompilerOptions
): (...args: unknown[]) => unknown {
type ISwcRegister = typeof import('@swc-node/register/register')['register'];

// These are requires to prevent it from registering when it shouldn't
const register = require('@swc-node/register/register')
.register as ISwcRegister;

if (tsConfigPath) {
process.env.SWC_NODE_PROJECT = tsConfigPath;
} else {
let rootTsConfig = join(workspaceRoot, 'tsconfig.base.json');
if (existsSync(rootTsConfig)) {
process.env.SWC_NODE_PROJECT = rootTsConfig;
}
}

const cleanupFn = register(compilerOptions);

return typeof cleanupFn === 'function' ? cleanupFn : () => {};
Expand Down Expand Up @@ -127,10 +103,7 @@ export function getTsNodeTranspiler(
};
}

export function getTranspiler(
compilerOptions: CompilerOptions,
tsConfigPath?: string
) {
export function getTranspiler(compilerOptions: CompilerOptions) {
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';

if (!ts) {
Expand All @@ -144,7 +117,7 @@ export function getTranspiler(
compilerOptions.skipLibCheck = true;

if (swcNodeInstalled && !preferTsNode) {
return () => getSwcTranspiler(compilerOptions, tsConfigPath);
return () => getSwcTranspiler(compilerOptions);
}

// We can fall back on ts-node if it's available
Expand All @@ -162,11 +135,10 @@ export function getTranspiler(
* @returns cleanup method
*/
export function registerTranspiler(
compilerOptions: CompilerOptions,
tsConfigPath?: string
compilerOptions: CompilerOptions
): () => void {
// Function to register transpiler that returns cleanup function
const transpiler = getTranspiler(compilerOptions, tsConfigPath);
const transpiler = getTranspiler(compilerOptions);

if (!transpiler) {
warnNoTranspiler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ exports[`@nx/storybook:configuration for Storybook v7 dependencies should add an
"@storybook/jest": "^0.2.3",
"@storybook/test-runner": "^0.13.0",
"@storybook/testing-library": "^0.2.2",
"@swc-node/register": "~1.6.7",
"@swc-node/register": "~1.8.0",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@types/jest": "^29.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ exports[`lib should add vue, vite and vitest to package.json 1`] = `
"@nx/vite": "0.0.1",
"@nx/vue": "0.0.1",
"@nx/web": "0.0.1",
"@swc-node/register": "~1.6.7",
"@swc-node/register": "~1.8.0",
"@swc/core": "~1.3.85",
"@swc/helpers": "~0.5.2",
"@typescript-eslint/eslint-plugin": "^6.13.2",
Expand Down