Skip to content

Commit

Permalink
fix(core): projects should work with nodenext set in tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham committed Nov 6, 2024
1 parent b14d5c5 commit e7d7590
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/jest/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -91,6 +94,9 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -143,6 +149,9 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down
21 changes: 21 additions & 0 deletions packages/jest/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -173,6 +176,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -306,6 +312,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -413,6 +422,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -480,6 +492,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -593,6 +608,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down Expand Up @@ -660,6 +678,9 @@ describe('@nx/jest/plugin', () => {
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
Expand Down
4 changes: 4 additions & 0 deletions packages/jest/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ async function buildJestTargets(
command: 'jest',
options: {
cwd: projectRoot,
// Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119
// Since we are moving in the direction of ESM via `module` nodenext, we need to override the resolution until Jest supports it.
env: { TS_NODE_COMPILER_OPTIONS: '{"moduleResolution":"node10"}' },
},
metadata: {
technologies: ['jest'],
Expand Down Expand Up @@ -269,6 +272,7 @@ async function buildJestTargets(
outputs,
options: {
cwd: projectRoot,
env: { TS_NODE_COMPILER_OPTIONS: '{"moduleResolution":"node10"}' },
},
metadata: {
technologies: ['jest'],
Expand Down

0 comments on commit e7d7590

Please sign in to comment.