Closed awareness481 closed 2 years ago
@awareness481 I would like to hear your proposal 😉
@momegas The 2nd option would imply having an index.ts
file with an export statement for every component
// index.ts
export * from './src/component/Nav.ts'
export * from './src/component/Button.ts'
// ..
In general, I find this pattern hard to work with and harder to change. I'm also worried about any potential effects it might have on tree-shaking (in most cases it should be fine).
In general, I would much prefer using the standard exports field (1st option) https://nodejs.org/api/packages.html#conditional-exports This would also make it easy to provide different exports for cjs.
As to whether we should keep the old single-file export, that should depend on whether this library is used by other projects and how hard it would be to switch to the new import syntax.
Great. I'm in favour. Let's discuss and plan a potential MR to solve this. Can you create the issue and we can plan / proritise it one of these days.
Currently, we're only shipping a single file which causes bundle sizes to be significantly inflated. I'm proposing implementing either of the two options outlined below:
Option 1: Keep current export, add single exports for each component
If we were to implement this, users would still be able to use the old exports. Ex:
but they would be encouraged to use the new exports:
Benefits
Drawbacks
Option 2: Remove the current export, exports components from a single file
With this proposal users would not need to change the imports but they would get the benefit of a smaller bundle size just by upgrading.
ex:
Benefits
Drawback
Notes
We should provide cjs exports
cc: @ksiabani @momegas