-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Move module.exports
assigment to the top
#2059
Conversation
When using cjs format make sure to move `module.exports` to the top of the generated chunk, right after the `__export()` call: var exports = {}; __export(exports, { // ... }); module.exports = __toCommonJS(exports); This guarantees that all circular requires following these calls would see the correct `module.exports` object. Additionally, add an extra argument for `__reExport` to copy the data to the `module.exports`: __reExport(exports, module.exports, ...) This is required to support `export * from '..'` since now `module.exports` wouldn't automatically receive properties otherwise. Fix: evanw#1894
cc @evanw |
Tested on our codebase with both test suite and application tests, in addition to the existing tests in the esbuild's test suite. |
@evanw being a maintainer of a large project like esbuild is very stressful and I totally understand if you don't have time or desire to look into things. Let me know, however, if there is anything I could do to make it easier for you to review this and other PRs. Maybe I need to add test cases, write better description of the changes? Any feedback is welcome, and thanks for building and support this project! |
My personal life is really busy right now and I currently have extremely limited time to work on esbuild. I've got a ton of stuff going on all at once. Maintaining esbuild is one of the least stressful things about my life right now haha. I'm hoping to have more free time in a month or so but right now esbuild-related stuff is just going to go slowly. |
Totally understand. Thanks for sharing, and hope you will find a way to
reduce the stress!
…On Sun, Mar 13, 2022 at 18:16 Evan Wallace ***@***.***> wrote:
My personal life is really busy right now and I currently have extremely
limited time to work on esbuild. I've got a ton of stuff going on all at
once. Maintaining esbuild is one of the least stressful things about my
life right now haha. I'm hoping to have more free time in a month or so but
right now esbuild-related stuff is just going to go slowly.
—
Reply to this email directly, view it on GitHub
<#2059 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB2HQYFF5QXKTI34BXO6JTU72OQBANCNFSM5PLWFBGQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thank you! 🤗 |
When using cjs format make sure to move
module.exports
to the top ofthe generated chunk, right after the
__export()
call:This guarantees that all circular requires following these calls would
see the correct
module.exports
object.Additionally, add an extra argument for
__reExport
to copy the data tothe
module.exports
:This is required to support
export * from '..'
since nowmodule.exports
wouldn't automatically receive properties otherwise.Fix: #1894