Skip to content

Revisit bundling strategy #1669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
devongovett opened this issue Mar 5, 2021 · 1 comment · Fixed by #6064
Closed

Revisit bundling strategy #1669

devongovett opened this issue Mar 5, 2021 · 1 comment · Fixed by #6064
Labels
enhancement New feature or request

Comments

@devongovett
Copy link
Member

We currently build all files in each package into two dist files: an ESM version and a CommonJS version. This has the advantage that it prevents users from accessing internal functions that we didn't mean to expose (e.g. import 'foo/dist/private.js'), but has the disadvantage that tree shaking is less effective. This is because the sideEffects: false option in package.json only applies on the file level, and we bundle all files into one. See #1378 for some discussion about this.

We should consider splitting these out and not bundling all files together. The exports field in package.json could potentially be used to prevent unintended access to private modules, but only if actually implemented by tools (e.g. Parcel doesn't currently support it). It's also possible that we could bundle some packages and not others, or do some smarter bundling strategy where modules that are only imported from one other file are bundled together, but publicly accessible files are separate entry points. We could also allow accessing certain sub-paths via the exports field, e.g. import '@react-aria/interactions/usePress' and treat these as entry points into the graph.

@Andarist
Copy link
Contributor

Andarist commented Mar 7, 2021

Feel free to ping me whenever you get to this - always happy to give feedback regarding this kind of stuff 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants