Skip to content

Commit

Permalink
docs(Configuration): Update TypeScript configuration example to TS 2.7 (
Browse files Browse the repository at this point in the history
webpack#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!
  • Loading branch information
peterblazejewicz authored and montogeek committed Mar 19, 2018
1 parent 3e9b9da commit bc13648
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/content/configuration/configuration-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ and then proceed to write your configuration:
__webpack.config.ts__

```typescript
import * as webpack from 'webpack';
import * as path from 'path';
import path from 'path';
import webpack from 'webpack';

const config: webpack.Configuration = {
entry: './foo.js',
Expand All @@ -40,6 +40,8 @@ const config: webpack.Configuration = {
export default config;
```

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.

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`.

There are two solutions to this issue:
Expand Down

0 comments on commit bc13648

Please sign in to comment.