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

fix(build): Prevent Rollup from adding [Symbol.toStringTag]: 'Module' to CJS files #6043

Merged
merged 1 commit into from Oct 27, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Oct 25, 2022

As of version 2.69.0, setting output.generatedCode to 'es2015' (as we do) causes Rollup to add [Symbol.toStringTag]: 'Module' to generated CJS files. Though this is valid ES6, it causes Jest to be unable to mock our generated packages.

Though a PR has been opened to fix this, the change almost certainly won't be backported, so anyone using Jest 29.2.2 or under will run into this problem if they try to mock @sentry/xxx 7.16. (The relevant change was introduced in #5951, when we (semi-)accidentally upgraded Rollup from 2.67.1 to 2.78.0, and was first included in version 7.16.)

This PR prevents the new Rollup behavior, since it has no known benefit. (The Rollup docs say that presence of the 'Module' toStringTag "is used for feature detection in certain libraries and frameworks," but not having it hasn't seemed to hurt us so far.)

Fixes #5994.
Fixes #6037.

@lobsterkatie lobsterkatie force-pushed the kmclb-prevent-module-symbol-in-cjs-files branch from 26bc18b to d3324f4 Compare October 25, 2022 23:11
@lobsterkatie lobsterkatie self-assigned this Oct 25, 2022
@lforst
Copy link
Member

lforst commented Oct 27, 2022

Nice detective work!

@AbhiPrasad
Copy link
Member

Gonna merge this in so we can unblock release.

@AbhiPrasad AbhiPrasad merged commit 18b29d2 into master Oct 27, 2022
@AbhiPrasad AbhiPrasad deleted the kmclb-prevent-module-symbol-in-cjs-files branch October 27, 2022 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken @sentry/vue jest mock Failed to get mock metadata: node_modules/@sentry/react/cjs/index.js
4 participants