-
Notifications
You must be signed in to change notification settings - Fork 234
chore(web): change web build to produce esm instead of cjs COMPASS-9934 #7432
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
base: main
Are you sure you want to change the base?
Conversation
* runtime exports not being built correctly. We should investigate and try to | ||
* fix this to remove this custom chunk splitting logic. | ||
*/ | ||
function createSiblingBundleFromLeafDeps( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another benefit of this is that we don't need custom split chunk logic anymore
…ues in the sandbox
externals: { | ||
react: 'commonjs2 react', | ||
'react-dom': 'commonjs2 react-dom', | ||
react: ['__compassWebSharedRuntime', 'React'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does __compassWebSharedRuntime
work here? Does it mean that React would be accessible from window.__compassWebSharedRuntime
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Actually I'm wrong in saying that is it fully backwards compatible, I updated the PR description. I'll open an mms PR is a sec to illustrate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened https://github.com/10gen/mms/pull/143845 that shows how this will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it makes sense to me. Looks nice, thanks.
[nit]: can you add a comment so that someone does not change it unintentionally?
We're planning to switch mms to load compass-web from external cdn instead of having it bundled with the whole mms application, first step into that direction is to switch compass-web distribution to be a native esm module instead of a cjs one.
This change is fully backwards compatible with how the compass-web library is being consumed by mms right nowThis is a breaking change in how compass-web get embedded in the consumer app, but it can be done in safe, backwards compatible way where the the old compass-web is still working, while we do the prep work for the new version to be included