Skip to content
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

Change ESM builds for R3F extension so the components are treeshakeable 🌲 #99

Closed
wants to merge 1 commit into from

Conversation

juniorxsound
Copy link
Contributor

What?

Right now when esbuilding the R3F extension everything is bundled into a single file for both ESM and CJS builds (including import statements to @theatre/studio which are only required by some of the components). This PR moves to building an ESM version without bundling all components to a single file, that way separate components can be imported by the user without fear that studio would be included in your bundle when not needed (e.g when importing just editable without studio in the project).

Before

Here is a snapshot of the current build output (esm target builds a single index.mjs file with everything inlined)
Screen Shot 2022-03-15 at 4 27 41 PM

After

Screen Shot 2022-03-15 at 4 29 25 PM

Each component is built into JS but kept separated by turning `esbuild`'s `bundle` prop off - that way components can be imported individually without having to import the whole `index.mjs` dependencies.

Closes #97

Copy link

@nbartzokas nbartzokas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AriaMinaei
Copy link
Member

Thanks for the PR @juniorxsound and @nbartzokas!

@AndrewPrifer is fixing up the build system via #101 so I think this PR would be reviewed as part of that task.

@AndrewPrifer
Copy link
Contributor

This is now (finally, yay) addressed by #129, along with various other issues. Thanks for your contribution @juniorxsound, we ended up using your solution and even removing the cjs build altogether.

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

Successfully merging this pull request may close these issues.

theatre/r3f: Bundle includes theatre/studio
4 participants