1
votes

Is there a way to get an npm module to publish with typings that support es6 module usage?

I'm trying to make a new project based on https://github.com/onybo/webpack-react-typescript-demo which does babel|ts and works fine as-is. The npm module I made is based on basarat's ts-npm-module / ts-npm-module-consume repos and seems to work fine for commonjs, but when the compiler module option changes from commonjs to es6, it can no longer find the module. As basarat mentions in his repos, atom-typescript works fine (F6 builds) but ts-loader doesn't, tsc (1.7.5 and nightly) and ntsc also give the same error.

Minimal repro as a diff to the demo project (attempting to consume basarat's module) is https://github.com/jamesmanning/webpack-react-typescript-demo/commit/519fb9013065a3125742be804b20703e42d747bb and minimal repro as a diff to basarat's consume module is https://github.com/jamesmanning/ts-npm-module-consume/commit/70706e3280c2ce4cca04f7f8accbc22b5ba5284c

The "typings" entry in the package.json of the npm module seems sufficient for atom-typescript but how can I get ts-loader to also use it (or what can I change to make ts-loader see the module?)

Thanks!

1

1 Answers

2
votes

Use "moduleResolution": "node" to have the module resolver use npm style module resolution.