-
Notifications
You must be signed in to change notification settings - Fork 68
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: allow cjs version of packages to export a default value #943
Conversation
* "Fixes" the esbuild problem of exporting the CJS default export as `module.exports.default` | ||
* instead of `module.exports`. The plugin appends a block of code to the file that takes the | ||
* `.default` module export and re-exports it as `module.exports`. It then takes all named | ||
* exports and re-exports them as part of the `module.exports` under the same name. This also | ||
* gives the benefit of exporting the `.default` module which allows us to support all 3 export | ||
* styles: the default export, `.default` export, and named exports. |
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.
Is there an issue with ESBuild open on this? If not, could you submit one? This feels like it would be a generally useful feature.
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.
Small nitpick, up to you.
This adds an esbuild plugin to "fix" the esbuild problem of having
export default a
changed intomodule.exports.default = a
instead ofmodules.exports = a
. Using the plugin removes the build warnings we get from esbuild when we tried to addmodule.exports
into the code to do this manually.Closes #948