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

feat: enable inline for CommonJS bundle #2442

Merged
merged 6 commits into from
Oct 18, 2022
Merged

Conversation

joshblack
Copy link
Member

This is a follow-up to: #2404 after primer/.github#8 was merged. It restores the ability to inline ESM-only modules in the CommonJS path.

The RC workflow should now include the lib/node_modules directory when publishing which should remedy the underlying issue when testing out release candidates.

Note
Dynamic require() in _FormattingTools.tsx

There is an exception to the inline behavior described above with dynamic require statements. By default the commonjs plugin will attempt to hoist these declarations to the top-level when transformMixedEsModules is true. As a result, these statements are left as-is.

There is one potential path forward with these calls where they are converted to dynamic import() statements in source. When they are built for ESM and CommonJS they are then converted to require() statements to work around a bug present in Jest and V8.

Another path forward is to determine the way to make these top-level imports so that we can avoid dynamic require() and import() statements altogether.

@joshblack joshblack requested review from a team and mperrotti October 17, 2022 17:55
@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2022

🦋 Changeset detected

Latest commit: f763030

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 77.99 KB (0%)
dist/browser.umd.js 78.64 KB (0%)

@joshblack joshblack temporarily deployed to github-pages October 17, 2022 18:03 Inactive
@joshblack joshblack temporarily deployed to github-pages October 17, 2022 18:13 Inactive
@joshblack
Copy link
Member Author

@broccolinisoup would it be possible for this to make it into the release this cycle? 🙏

@broccolinisoup
Copy link
Member

@broccolinisoup would it be possible for this to make it into the release this cycle? 🙏

Sure! Is there any tests on the release checklist you suggest running again or should our CI checks be enough to confirm?

@joshblack joshblack temporarily deployed to github-pages October 18, 2022 20:01 Inactive
@joshblack
Copy link
Member Author

@broccolinisoup I think that if it works in the memex smoketest we should be good to go!

Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Seems like a good approach 👍

If the canary release works in Memex, let's go ahead and merge this 🚀

@broccolinisoup
Copy link
Member

Confirming that the canary release works in memex 🥳

@joshblack joshblack enabled auto-merge (squash) October 18, 2022 22:07
@joshblack joshblack merged commit 6b559a9 into main Oct 18, 2022
@joshblack joshblack deleted the feat/add-inline-node-modules branch October 18, 2022 22:11
@joshblack joshblack temporarily deployed to github-pages October 18, 2022 22:11 Inactive
@primer-css primer-css mentioned this pull request Oct 18, 2022
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.

3 participants