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 890b34a

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 890b34a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ and then proceed to write your configuration:
3333
**webpack.config.ts**
3434

3535
```typescript
36-
import *aspath from 'path';
37-
import *aswebpack from 'webpack';
36+
import path from 'path';
37+
import webpack from 'webpack';
3838
// in case you run into any typescript error when configuring `devServer`
3939
import 'webpack-dev-server';
4040

@@ -50,6 +50,15 @@ const config: webpack.Configuration = {
5050
export default config;
5151
```
5252

53+
**tsconfig.json**
54+
55+
```json
56+
{
57+
"allowSyntheticDefaultImports": true,
58+
"esModuleInterop": true
59+
}
60+
```
61+
5362
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.
5463

5564
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 によって変換されたページ (->オリジナル) /