-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-resolve): Resolve js/jsx/mjs/cjs imports from TypeScript fi…
…les (#1498)
- Loading branch information
Showing
10 changed files
with
140 additions
and
5 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
4 changes: 4 additions & 0 deletions
4
packages/node-resolve/test/fixtures/ts-import-cjs-extension/import-ts-with-cjs-extension.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { main } from './main.cjs'; | ||
// This resolves as main.cts and _not_ main.cjs, despite the extension | ||
const mainResult = main(); | ||
export default mainResult; |
11 changes: 11 additions & 0 deletions
11
packages/node-resolve/test/fixtures/ts-import-cjs-extension/main.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,11 @@ | ||
// To make this very clearly TypeScript and not just CJS with a CTS extension | ||
type TestType = string | string[]; | ||
interface Main { | ||
(): string; | ||
propertyCall(input?: TestType): TestType; | ||
} | ||
|
||
const main: Main = () => 'It works!'; | ||
main.propertyCall = () => ''; | ||
|
||
export { main }; |
4 changes: 4 additions & 0 deletions
4
packages/node-resolve/test/fixtures/ts-import-mjs-extension/import-ts-with-mjs-extension.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { main } from './main.mjs'; | ||
// This resolves as main.mts and _not_ main.mjs, despite the extension | ||
const mainResult = main(); | ||
export default mainResult; |
11 changes: 11 additions & 0 deletions
11
packages/node-resolve/test/fixtures/ts-import-mjs-extension/main.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,11 @@ | ||
// To make this very clearly TypeScript and not just MJS with a MTS extension | ||
type TestType = string | string[]; | ||
interface Main { | ||
(): string; | ||
propertyCall(input?: TestType): TestType; | ||
} | ||
|
||
const main: Main = () => 'It works!'; | ||
main.propertyCall = () => ''; | ||
|
||
export { main }; |
7 changes: 7 additions & 0 deletions
7
packages/node-resolve/test/fixtures/tsx-import-js-extension/MyComponent.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,7 @@ | ||
// To make this very clearly TypeScript and not just JS with a TS extension | ||
type TestType = string | string[]; | ||
function MyComponent() { | ||
return 'It works!'; | ||
} | ||
|
||
export { MyComponent }; |
4 changes: 4 additions & 0 deletions
4
packages/node-resolve/test/fixtures/tsx-import-js-extension/import-tsx-with-js-extension.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { MyComponent } from './MyComponent.js'; | ||
// This resolves as MyComponent.tsx and _not_ MyComponent.js, despite the extension | ||
const componentResult = MyComponent(); | ||
export default componentResult; |
7 changes: 7 additions & 0 deletions
7
packages/node-resolve/test/fixtures/tsx-import-jsx-extension/MyComponent.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,7 @@ | ||
// To make this very clearly TypeScript and not just JS with a TS extension | ||
type TestType = string | string[]; | ||
function MyComponent() { | ||
return 'It works!'; | ||
} | ||
|
||
export { MyComponent }; |
4 changes: 4 additions & 0 deletions
4
...ages/node-resolve/test/fixtures/tsx-import-jsx-extension/import-tsx-with-jsx-extension.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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { MyComponent } from './MyComponent.jsx'; | ||
// This resolves as MyComponent.tsx and _not_ MyComponent.jsx, despite the extension | ||
const componentResult = MyComponent(); | ||
export default componentResult; |
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