vercel / ncc

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.
https://npmjs.com/@vercel/ncc
MIT License
9.13k stars 287 forks source link

Bundle type declarations (through option?) #482

Open tunnckoCore opened 4 years ago

tunnckoCore commented 4 years ago

Probably using https://www.npmjs.com/package/dts-bundle-webpack?

If it's an option it can be run after the main build.

ncc build src/index.ts -o dist/main
ncc build dist/types/index.d.ts -o dist/typings --dts
rm -rf dist/types

Would be good if it reads the typings / types field.

cinderblock commented 4 years ago

If I remember correctly, all you need to do is to add "declaration": true, to your tsconfig.json.

tunnckoCore commented 4 years ago

Nope, I don't think so. :) I wouldn't open an issue if it worked or just for the sake of opening it.

And I think that it's also a bit different thing here what I'm talking about. Consider src/ with .js files but also with .d.ts files. As seen above

ncc build src/index.d.ts -o dist/typings --dts
# ---> dist/typings/index.d.ts bundle

Would be good to be possible.

Anyway, I may try soon.