Skip to content

Commit

Permalink
fix(module): switch to commonjs2 libraryTarget (#379)
Browse files Browse the repository at this point in the history
Emit `__esModule` indicators for ES modules to distinguish between
them and CommonJS modules.

If libraryTarget is set to `commonjs`, the bundle does not match the interface
provided by the type declarations because `default` imports end up as
`module.exports`, e.g.:

```
import transformer from 'ts-auto-mock/transformer'; // commonjs -> { default: [Function (anonymous)] }
import transformer from 'ts-auto-mock/transformer'; // commonjs2 -> [Function (anonymous)] ✓
```

Co-authored-by: Vittorio Guerriero <[email protected]>
  • Loading branch information
martinjlowm and uittorio authored Jun 14, 2020
1 parent a41ff55 commit 9259f10
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion config/modules/base/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (options) => {
]
},
output: {
libraryTarget: "commonjs",
libraryTarget: "commonjs2",
filename: "[name].js"
},
plugins: [
Expand Down

0 comments on commit 9259f10

Please sign in to comment.