bpmn-visualization-js icon indicating copy to clipboard operation
bpmn-visualization-js copied to clipboard

[INFRA] Provide a single type definition file in the npm package

Open tbouffard opened this issue 3 years ago • 0 comments

In the npm package, the types are defined with an entry point that references a lot of files. The files leak the internal structure of the TS files tree which is not available in the npm package. We don’t provide individual JS files but only bundles. In addition, as we strip internal implementations, some type files are empty.

The proposal is to include a single type definition file in the npm package that will include all types. This will be consistent with the way we provide JS files as bundles and will fix current issues (non file tree structure leak nor empty files). Several solutions are available

  • https://www.npmjs.com/package/dts-bundle-generator seen in https://github.com/kbysiec/vite-vanilla-ts-lib-starter/tree/71f7435bf9842761719b235ba109a704a2acbc13. CLI that can use a configuration file
  • https://api-extractor.com/ is part of the tsdoc project. CLI that uses a configuration file, see https://api-extractor.com/pages/setup/configure_rollup/
  • rollup plugin https://github.com/Swatinem/rollup-plugin-dts. See it in action in this blog post: https://medium.com/codex/bundling-a-typescript-library-for-node-with-rollup-js-2c8add5e736f. We already use rollup to prepare the bundles in the npm package.
  • https://github.com/wessberg/rollup-plugin-ts#declaration-files but it seems it would also generate the bundle. This is too much for our use case. Keep it in mind as a backup.

Notes

Introducing a single definition file should prevent to expose the internal JSON BPMN model, see #2249.

tbouffard avatar Sep 12 '22 08:09 tbouffard