-
-
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
Emit deep imports for helpers when using Common JS #7144
Comments
The root cause: The exported function name is Solution: What are your thoughts? @kdy1 |
I agree, |
Ah, didn't notice that there was a mismatch between the used name and the exported name. However, even if I manually patch |
We can declare "peerDependencies": {
"@swc/core": ">1.3.42"
} |
Good idea. I never thought that I can use it to do such thing |
I think I should keep using default exports. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Describe the feature
Currently when using external helpers SWC will output something like this for ESM:
And something like this for CJS:
I discovered this when analyzing this issue: webpack/webpack#16861
While I do believe that issue to be a webpack issue and not a SWC issue it would most likely not have happened if SWC emitted deep require statements instead of requireing from the entry point which exports all helpers. Eg, if the require statement would have looked like this:
This would also have the added benefit of getting smaller bundles when using CJS since you'd only import the helpers actually used. To my knowledge webpack won't be able to correctly tree shake unused requires from lib/index.js.
Babel plugin or link to the feature description
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: