Skip to content

Commit bc13648

Browse files
peterblazejewiczmontogeek
authored andcommitted
docs(Configuration): Update TypeScript configuration example to TS 2.7 (#1926)
The updated snippet uses the same syntax as in any ES6/ES2015 based module imports in vanilla JavaScript thanks to new features from TypeScript 2.7 or newer The relevant not has been added to the sample to mention these new configuration compiler properties. Thanks!
1 parent 3e9b9da commit bc13648

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/content/configuration/configuration-languages.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ and then proceed to write your configuration:
2626
__webpack.config.ts__
2727

2828
```typescript
29-
import * as webpack from 'webpack';
30-
import * as path from 'path';
29+
import path from 'path';
30+
import webpack from 'webpack';
3131

3232
const config: webpack.Configuration = {
3333
entry: './foo.js',
@@ -40,6 +40,8 @@ const config: webpack.Configuration = {
4040
export default config;
4141
```
4242

43+
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.
44+
4345
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`.
4446

4547
There are two solutions to this issue:

0 commit comments

Comments
 (0)