| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -504,7 +504,9 @@ class ModuleLoader { | |||
| 504 | 504 | const loadResult = this.#loadSync(url, { format, importAttributes }); | |
| 505 | 505 | ||
| 506 | 506 | // Use the synchronous commonjs translator which can deal with cycles. | |
| 507 | - const finalFormat = loadResult.format === 'commonjs' ? 'commonjs-sync' : loadResult.format; | ||
| 507 | + const finalFormat = | ||
| 508 | + loadResult.format === 'commonjs' || | ||
| 509 | + loadResult.format === 'commonjs-typescript' ? 'commonjs-sync' : loadResult.format; | ||
| 508 | 510 | ||
| 509 | 511 | if (finalFormat === 'wasm') { | |
| 510 | 512 | assert.fail('WASM is currently unsupported by require(esm)'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,3 +174,13 @@ test('expect failure of a .cts file requiring esm in node_modules', async () => | |||
| 174 | 174 | match(result.stderr, /ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING/); | |
| 175 | 175 | strictEqual(result.code, 1); | |
| 176 | 176 | }); | |
| 177 | + | ||
| 178 | + test('cts -> require mts -> import cts', async () => { | ||
| 179 | + const result = await spawnPromisified(process.execPath, [ | ||
| 180 | + fixtures.path('typescript/cts/issue-59963/a.cts'), | ||
| 181 | + ]); | ||
| 182 | + | ||
| 183 | + strictEqual(result.stderr, ''); | ||
| 184 | + strictEqual(result.stdout, 'Hello from c.cts\n'); | ||
| 185 | + strictEqual(result.code, 0); | ||
| 186 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,3 +98,14 @@ test('execute .ts file importing a module', async () => { | |||
| 98 | 98 | strictEqual(result.stdout, 'Hello, TypeScript!\n'); | |
| 99 | 99 | strictEqual(result.code, 0); | |
| 100 | 100 | }); | |
| 101 | + | ||
| 102 | + test('mts -> import cts -> require mts', async () => { | ||
| 103 | + const result = await spawnPromisified(process.execPath, [ | ||
| 104 | + '--no-warnings', | ||
| 105 | + fixtures.path('typescript/mts/issue-59963/a.mts'), | ||
| 106 | + ]); | ||
| 107 | + | ||
| 108 | + strictEqual(result.stderr, ''); | ||
| 109 | + strictEqual(result.stdout, 'Hello from c.mts\n'); | ||
| 110 | + strictEqual(result.code, 0); | ||
| 111 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + const { message } = require("./b.mts"); | ||
| 2 | + interface Foo {}; | ||
| 3 | + console.log(message); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + interface Foo {}; | ||
| 2 | + export { message } from "./c.cts"; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + const message: string = "Hello from c.cts"; | ||
| 2 | + module.exports = { message }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + import { message } from "./b.cts"; | ||
| 2 | + interface Foo {}; | ||
| 3 | + console.log(message); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + const { message } = require("./c.mts"); | ||
| 2 | + interface Foo {}; | ||
| 3 | + module.exports = { message }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + export const message: string = "Hello from c.mts"; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments