-
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
Question: How to recursively process files but not produce a single bundle #3064
Comments
There are a few different issues involved in your problem:
|
Thanks for the quick reply! If you can point me to where this behaviour (the lowering of top level class static fields) is enforced, I'd be reasonably happy if the solution was for me to fork it and either:
Separately - and just out of interest - what is special about top level class static fields that triggers this behaviour? I also think (based on other reported issues) that I'll get tripped up with the class referencing itself within the class body |
Here you are: esbuild/internal/js_parser/js_parser_lower.go Lines 1988 to 1990 in 0776a4b
Summary: when bundle: true, top level class static fields are always lowered. Related issues: #1524 #2416 #2800 #2950
This is because esbuild always transforms class declarations to variable declarations in bundle mode: class A { static a = new A() }
// becomes
var A = class { static a = new A() } // error: not found 'A' In the second line, the reference to class name 'A' will become |
Why? Something to do with duplicate class names? |
I'm looking for the same feature as @znewsham. Today the
Today, if you don't want bundling you need to add every single file as entry points and set bundle to It would be very nice to have an alternative to
Such a feature would be very valuable for me and apparently others as well. In the build script for my current project, I have made my own dependency graph resolver so that I can add each of the resolved modules as esbuild entry points. I still think it would be beneficial if this was added as a native feature of esbuild. If this feature is added, it would be nice if the |
I'm closing this issue because it duplicates other open issues. The request about bundling with recursive file processing is a duplicate of #708, and the request to not lower private class fields is a duplicate of #1328. You can read #2889 for more information about why top-level classes are transformed this way during bundling. FWIW I'm hoping to improve this transformation to avoid lowering private class fields at some point. |
I have a large application I want to process with esbuild - the code is mostly JS with a smattering of TS. Mostly the code is compliant with the version of node (14) I'm running, though there are a handful of places that use features not available in node 14 that need converting.
My goal is to pass in an entry point (e.g.,
server/main.js
) to esbuild - and have it process the files as necessary and copy them to the output directory.Unfortunately, this doesn't happen - if I pass the entry point to esbuild, only that one file appears in the output directory and obviously if I pass in bundle: true, I end up with a bundle.
Up until now I've been using
bundle: true
- with a custom plugin that recursively calls build for each imported file as a new entry point - unfortunately the problem with this approach is it down-levels certain features that shouldn't be (e.g., private class members) specifically because of the bundle flag (even though it's a 1:1 mapping of input to output).How can I achieve the desired result?
The text was updated successfully, but these errors were encountered: