nimiq / vue-components

Vue component library for Nimiq ecosystem apps.
https://nimiq.github.io/vue-components/
Apache License 2.0
17 stars 4 forks source link

Provide an esm build #8

Open danimoh opened 5 years ago

danimoh commented 5 years ago

Provide an esm build to enable tree shaking in apps importing components from this component library without the need to import all components at once. See webpack tree shaking documentation for more info.

Work and experimentation on this has already been started here.

Unfortunately, with the current state of the build tools, this goal is not achievable for our project structure (vue single file components written in typescript):

To provide .d.ts type declarations after compilation with rollup, dts-bundle can be used. We could also keep our current approach with vue-cli-plugin-ts-bundler but rebuilding that behavior with dts-bundle should be easy.

The default for css option of rollup-plugin-vue already ensures that css styling is embedded into the components and not output as a big css file. Thus, we can benefit from tree shaking for css also.

danimoh commented 4 years ago

Just stumbled upon these links whcih might be interesting when we touch this issue again: https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html https://github.com/MikeMitterer/vue-ts-sfc-starter

The vue-ts-sfc-starter kit uses rollup-plugin-typescript2 in conjunction with rollup. We should check whether the author found a way around the issues described above.