Publishing typescript library on npm: exported characters, modules

I am writing a typescript library that I intend to publish on npm. It is intended only for nodebrowser only. It will make sense to use the library only from typescript (I do not expect some Javascript users).

I'm having trouble finding guidelines for publishing typescript -for-typescript libraries on npm (it also seems to change these things quickly in the typescript world).

Should I wrap all my code in module? (I do not feel the need for modules in the library itself, currently it is only about 1000 LOC). Should I create a file index.ts? I think I should send files .js, .js.mapand .d.ts, but not files .tsfor the npm package?

How do I call functions between files in a library without exporting them to library users? I am not currently using typescript modules. I tried to use typedoc, and it also lists the characters that I exported from individual files for use in another library file. But I do not want them to be visible to users of the library.

Is there a library that I could use as an example? I looked at typescript-collections , they do not use moduleand have index.ts. I think they export all of their common functions, so that doesn't help me.

+2
source share
2 answers

, index.ts .

like

export { default as Actions } from './Actions'

package.json, "typings": "dist/index.d.ts" ( )

, . source-map-support, .

.js .

+2

TypeScript Library Starter. :

  • Package.json
  • (.d.ts)
  • TypeDoc
0

Source: https://habr.com/ru/post/1675643/


All Articles