-
Notifications
You must be signed in to change notification settings - Fork 26
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
esbuild export patterns #44
Comments
I don't think I would recommend doing this. The identifiers of local helper functions aren't necessarily stable. For example, My current plan for this is to change esbuild's output somehow to support this library when esbuild's platform is set to |
@evanw point taken, although we do support The point is more that as code is published to npm using these patterns, it would be beneficial for Node.js to support it, and this project is the best shot at that. npm code is typically direct build tool output so would still work - or does esbuild change these outputs in minification mode to something we can't detect? If you have suggestions as to alternative patterns that we could support please do share. For example, would better support for |
It just seems like this is coupling things too tightly IMO. I think having esbuild annotate the CommonJS exports for node's ESM loader seems less brittle. After thinking about it more, something like this would be even more compact: By the way, I think the grammar for doing this in the README is missing a -EXPORTS_LITERAL_PROP: (IDENTIFIER `:` IDENTIFIER)?) | (IDENTIFIER_STRING `:` IDENTIFIER)
+EXPORTS_LITERAL_PROP: (IDENTIFIER (`:` IDENTIFIER)?) | (IDENTIFIER_STRING `:` IDENTIFIER)
In this case the |
Actually it looks like using 0 && (module.exports = {a, b, c}, __exportStar(require('fs'))); However, that strangely still doesn't seem to work. The re-export is missing. This does work though: 0 && (module.exports = {a, b, c});
0 && __exportStar(require('fs')); Is this a bug in the parser? |
@evanw the reason the first case is not supported is because we only perform this check at the very top level, in order not to match more than we need, eg in bundling patterns etc. A slight variation does work though, see #46. I'm still not 100% sold on the hint pattern due to potential minification issues, but you can definitely rely on it working in all previous versions of Node.js and future versions of this project at least. |
Ok, for now I have skipped adding any of these. The new 1.1.0 update will take about a week to land on Node.js and a further month or so to fully be backported, if there are changes needed before then there's still a chance we can get a patch in. |
It could be worthwhile to look at supporting the esbuild export patterns in the coming upgrade being upstreamed and backported for Node.js.
As far as I can tell, we could use the following simple patterns for esbuild:
@evanw this would be a little bit of work but could be possible to support. Do you forsee these patterns changing or do you think this work would be worthwhile? I would likely be able to get to this next week.
The text was updated successfully, but these errors were encountered: