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(commonjs): Do not use getters for module.exports #1455

Merged
merged 1 commit into from Apr 11, 2023

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Mar 13, 2023

Rollup Plugin Name: commonjs

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

This reactors the commons plugin to achieve two things:

  • module is now again a simple object with an exports property and no getters and setters. This resolves issues when using Object.defineProperty on it.
  • we still do not use syntheticNamedExports for this, which was an issue that I tried to fix earlier with the getters/setters

Furthermore, I made the __esModule detection logic more conservative so that we can be sure the detection helper is used whenever it is possible that an __esModule property might sneak in some way.

I checked the reproductions of both linked issues and can confirm that this change indeed fixes them.

@lukastaegert
Copy link
Member Author

I published a beta release @rollup/plugin-commonjs@24.1.0-0 for easier testing.

@sapphi-red
Copy link
Contributor

I tested out this PR with Vite. It passed the Vite's tests and I confirmed this fixes vitejs/vite#11986.

@shellscape
Copy link
Collaborator

@lukastaegert we'll need to revert the version change in packages/commonjs/package.json before merging

@lukastaegert
Copy link
Member Author

we'll need to revert the version change in packages/commonjs/package.json before merging

@shellscape Oops, thanks for spotting, done!

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