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(commonjs): correctly wrap a default class export from cjs module #1350

Merged
merged 2 commits into from Nov 27, 2022

Conversation

sodatea
Copy link
Contributor

@sodatea sodatea commented Nov 19, 2022

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

Fixes vitejs/vite-plugin-react#28

Since 3c00191
the namespace became callable when requiring ESM with function default,
but it isn't newable, leading to errors when the function is actually a
class.

This PR fixed the getAugmentedNamespace() helper by adding a branch to check if the function is invoked with the new operator.

…t is a class

Fixes https://github.com/vitejs/vite/issues/10853

Since rollup@3c00191
the namespace became callable when requiring ESM with function default,
but it isn't newable, leading to errors when the function is actually a
class.
Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

👍

@shellscape shellscape changed the title fix: correctly wraps the default export from a CommonJS module when it is a class fix(commonjs): correctly wrap a default class export from cjs module Nov 27, 2022
@shellscape shellscape merged commit ab05216 into rollup:master Nov 27, 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.

React Carbon Components <CodeSnippet> Errors Out on Vite Production Build Only But Works on Dev
4 participants