forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A regression from vercel/turborepo#8748 Closes PACK-3312 Previously, it treated imports to `something.mjs` as importing `something.mts` with a fallback to `something.js`. But it should obviously instead fallback to the original extension `mjs`, which is also what tsc does: ``` Found 'package.json' at 'input/package.json'. ======== Resolving module './src/foo.mjs' from 'input/index.js'. ======== Explicitly specified module resolution kind: 'NodeNext'. Resolving in CJS mode with conditions 'require', 'types', 'node'. Loading module as file / folder, candidate module location 'input/src/foo.mjs', target file types: TypeScript, JavaScript, Declaration. File name 'input/src/foo.mjs' has a '.mjs' extension - stripping it. File 'input/src/foo.mts' does not exist. File 'input/src/foo.d.mts' does not exist. File 'input/src/foo.mjs' does not exist. File 'input/src/foo.mjs.ts' does not exist. File 'input/src/foo.mjs.tsx' does not exist. File 'input/src/foo.mjs.d.ts' does not exist. File 'input/src/foo.mjs.js' does not exist. File 'input/src/foo.mjs.jsx' does not exist. Directory 'input/src/foo.mjs' does not exist, skipping all lookups in it. ======== Module name './src/foo.mjs' was not resolved. ======== ```
- Loading branch information
Showing
14 changed files
with
55 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 17 additions & 7 deletions
24
...ates/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import foo from "./src/foo.js"; | ||
import bar from "./src/bar.js"; | ||
import fooEsm from "./src/foo-esm.mjs"; | ||
import fooCjs from "./src/foo-cjs.cjs"; | ||
import fileTsx from "./src/file-tsx.js"; | ||
import fileMts from "./src/file-mts.mjs"; | ||
import fileCts from "./src/file-cts.cjs"; | ||
import fileMjs from "./src/file-mjs.mjs"; | ||
import fileCjs from "./src/file-cjs.cjs"; | ||
|
||
it("should correctly resolve explicit extensions with nodenext", () => { | ||
expect(foo).toBe("foo"); | ||
expect(bar).toBe("bar"); | ||
expect(fooEsm).toBe("fooEsm"); | ||
expect(fooCjs).toBe("fooCjs"); | ||
expect(foo).toBe("foo.ts"); | ||
expect(fileTsx).toBe("file-tsx"); | ||
expect(fileMts).toBe("file-mts"); | ||
expect(fileCts).toBe("file-cts"); | ||
expect(fileMjs).toBe("file-mjs"); | ||
expect(fileCjs).toBe("file-cjs"); | ||
}); | ||
|
||
// import fooButton from "foo/button"; | ||
|
||
// it("should correctly resolve explicit extensions with nodenext", () => { | ||
// expect(fooButton).toBe("button"); | ||
// }); |
6 changes: 6 additions & 0 deletions
6
...tests/execution/turbopack/resolving/tsconfig-nodenext/input/node_modules/foo/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...s/tests/execution/turbopack/resolving/tsconfig-nodenext/input/node_modules/foo/source.mjs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...s/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/bar.tsx
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...bopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/file-cjs.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'file-cjs' |
1 change: 1 addition & 0 deletions
1
...bopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/file-cts.cts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "file-cts"; |
1 change: 1 addition & 0 deletions
1
...bopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/file-mjs.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default 'file-mjs' |
1 change: 1 addition & 0 deletions
1
...bopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/file-mts.mts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default "file-mts"; |
1 change: 1 addition & 0 deletions
1
...bopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/file-tsx.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default "file-tsx"; |
1 change: 0 additions & 1 deletion
1
...rbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/foo-cjs.cts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...rbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/foo-esm.mts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...es/turbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/src/foo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default "foo"; | ||
export default "foo.ts"; |
7 changes: 5 additions & 2 deletions
7
...turbopack-tests/tests/execution/turbopack/resolving/tsconfig-nodenext/input/tsconfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext" | ||
} | ||
"moduleResolution": "NodeNext", | ||
"allowJs": true, | ||
"outDir": "dist" | ||
}, | ||
"include": ["index.js"], | ||
} |