Nx
Enterprise
Nx
fix(misc): emit playwright.config.cts so Playwright + Nx both load the config cleanly, restore tsconfig-paths in registerTsProject, recover .cts ESM-syntax via swc-node ## Current Behavior - Playwright generator emitted `playwright.config.ts`. In default `apps` workspaces the file had top-level imports so Nx's native strip auto-detected ESM and `__filename` blew up with ReferenceError. In `type: "module"` workspaces a CJS-shape `.ts` was rejected (no `require`/`module.exports` in ESM scope). An ESM-shape `.ts` (top-level `import` + `import.meta.dirname`) also broke under Playwright's pirates loader, which compiles to CJS leaving `import.meta` intact; Node then re-detects ESM from the compiled output and errors on `exports is not defined in ES module scope` (the cascade across e2e-angular, e2e-cypress, e2e-eslint, e2e-jest, e2e-nx, e2e-react, e2e-remix, e2e-vite, e2e-vue, e2e-web). - `registerTsProject(tsConfigPath)` became a no-op under native strip - skipped BOTH transpiler and tsconfig-paths registration. Native strip handles transpilation, but path mapping is orthogonal: user code that explicitly calls `registerTsProject` to resolve `paths` aliases (e.g. Jest `globalSetup` requiring `@my-org/lib`) silently broke with MODULE_NOT_FOUND. - Legacy `.cts` files using ESM `export` syntax fail Node's strict CJS parser with SyntaxError. No fallback path existed under native strip, so configs that worked pre-v23 (via swc-node's CJS hook compiling away ESM syntax) break. - js-strip-types e2e asserted via `nx report`, which catches ProjectGraphError and exits 0 even when configs fail to load - so the regression above went undetected. jest.test.ts also wrote `export default` into a .cts fixture, broken for the same reason. ## Expected Behavior - Playwright generator now emits `playwright.config.cts`. Node forces `.cts` to CommonJS regardless of workspace `type`, so the file loads cleanly under Playwright's pirates runtime AND Nx's native strip. Playwright auto-discovers `.cts` via its configLoader extension list (`.ts/.js/.mts/.mjs/.cts/.cjs`). The Nx playwright plugin already globs all six extensions, so no plugin changes needed. - `registerTsProject` still skips the transpiler under native strip but always registers tsconfig-paths. `registerTsConfigPaths` short-circuits when the tsconfig has no `paths` entries, so package-manager-workspace setups (resolve via symlinks, no aliases) pay only the one-time tsconfig read - no per-require hook overhead. Workspaces with `paths` get the alias resolution they explicitly asked for. - loadTsFile detects SyntaxError on .cts/.cjs (new isCjsSyntaxError) and escalates to swc/ts-node, restoring pre-v23 behavior for ESM-syntax-in-CJS files. - js-strip-types swaps `nx report` for `nx graph --file=...` + JSON-graph assertions. Adds: regression test for playwright config emission, new .cts ESM-syntax recovery case, afterEach cleanup so plugin-worker state doesn't leak between fallback tests, .cts+require() extensionless-import scenario that actually exercises the MODULE_NOT_FOUND path. jest.test.ts .cts fixture now uses module.exports. Affected unit specs and snapshots in angular/nuxt/react/remix/vue/web updated to expect `.cts`. ## Related Issue(s) Fixes NXC-4299
nx-cloud record -- pnpm nx-cloud conformance:check
Sign in / Sign up
Open main menu
Succeeded
CI Pipeline Execution
1 run failed
nx-cloud record -- pnpm nx-cloud conformance:check
Click to copy
Linux
4 CPU cores
e5f4ec64
35608