-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for tsconfig 'nodenext' | 'node16' (#44177)
## ESM: support module option for tsconfig.json - fixes #37525 - fixes #41961 With [TypeScript 4.7 providing ECMAScript Module Support](https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js), we can now set this in our tsconfig.json file for the [module](https://www.typescriptlang.org/tsconfig#module) option. Webpack added "extensionAlias" to solve importing ts files with .js extension -> webpack/enhanced-resolve#351 Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
85 additions
and
0 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
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
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
5 changes: 5 additions & 0 deletions
5
test/integration/webpack-config-extensionalias/components/TsxComponent.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,5 @@ | ||
import React from 'react' | ||
|
||
export function TsxComponent() { | ||
return <>import me</> | ||
} |
5 changes: 5 additions & 0 deletions
5
test/integration/webpack-config-extensionalias/next.config.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
webpack(config) { | ||
return config | ||
}, | ||
} |
9 changes: 9 additions & 0 deletions
9
test/integration/webpack-config-extensionalias/pages/pagewithimport.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// import tsx file with .js extension alias, this leads to a build fail if extensionAlias is not configured | ||
import { TsxComponent } from '../components/TsxComponent.js' | ||
export default function PageWithImport() { | ||
return ( | ||
<> | ||
See import here: <TsxComponent /> | ||
</> | ||
) | ||
} |
12 changes: 12 additions & 0 deletions
12
test/integration/webpack-config-extensionalias/test/index.test.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { join } from 'path' | ||
import { nextBuild } from 'next-test-utils' | ||
|
||
const appDir = join(__dirname, '../') | ||
|
||
describe('webpack config with extensionAlias setting', () => { | ||
it('should run correctly with an tsx file import with .js extension', async () => { | ||
const { code } = await nextBuild(appDir, [], {}) | ||
|
||
expect(code).toBe(0) | ||
}) | ||
}) |