Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 860b994

Browse files
committed
docs(config): update ts configuration-languages
`import *` not required when `esModuleInterop: true` in `tsconfig.json`. ```json { "devDependencies": { "@types/node": "^20.3.1", "@types/webpack": "^5.28.1", "@types/webpack-dev-server": "^4.7.2", "ts-loader": "^9.2.6", "ts-node": "^10.9.1", "typescript": "^5.1.3", "webpack": "^5.88.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^4.7.4" } } ```
1 parent 25f43e3 commit 860b994

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

‎src/content/configuration/configuration-languages.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Configuration Languages
33
sort: 2
44
contributors:
5+
- piouson
56
- sokra
67
- skipjack
78
- tarang9211
@@ -33,8 +34,8 @@ and then proceed to write your configuration:
3334
**webpack.config.ts**
3435

3536
```typescript
36-
import *aspath from 'path';
37-
import *aswebpack from 'webpack';
37+
import path from 'path';
38+
import webpack from 'webpack';
3839
// in case you run into any typescript error when configuring `devServer`
3940
import 'webpack-dev-server';
4041

@@ -50,6 +51,15 @@ const config: webpack.Configuration = {
5051
export default config;
5152
```
5253

54+
**tsconfig.json**
55+
56+
```json
57+
{
58+
"allowSyntheticDefaultImports": true,
59+
"esModuleInterop": true
60+
}
61+
```
62+
5363
The above sample assumes version >= 2.7 or newer of TypeScript is used with the new `esModuleInterop` and `allowSyntheticDefaultImports` compiler options in your `tsconfig.json` file.
5464

5565
Note that you'll also need to check your `tsconfig.json` file. If the `module` in `compilerOptions` in `tsconfig.json` is `commonjs`, the setting is complete, else webpack will fail with an error. This occurs because `ts-node` does not support any module syntax other than `commonjs`.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /