-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Using ESBuild with Babel: error when target="es5" #1010
Comments
If Babel is being used to transform newer syntax to ES5, then why does it matter that the arrow function is there? Shouldn't Babel also transform that to ES5? What happens if you remove |
With the example script I posted here, yes. With the plugin API and
In that case, yes, I get regular functions - but I also get So maybe the answer is to reverse the process? Run the source-files through Babel first, to a temporary folder - then run ESBuild with This will give me none of the speed benefits of ESBuild though - since Babel will need to run after every change. Not sure what I'm really getting from ESBuild with that setup. Either way, something needs to change, to enable |
There are two ways to do this, and I'd expect both ways to work:
|
(1) is what I was trying to do before - so I have plugins: [
babel({
config: {
presets: [
['@babel/preset-env', { targets: "ie 11, not ie_mob 11" }]
],
}
})
] This should get rid of the short arrow functions. But (as covered here) now it exits with a different message:
I'm not using dynamic imports. My test-framework might be using them, that's my only clue - but I'm not including the test in my Is there any way to enable some extra verbosity or something? So I can find out where it found this dynamic import? (I also wish there were some way to tell where these messages are coming from - neither Babel nor ESBuild identifies error messages with the name of the tool. Identifying the source of an error currently comes down to searching Github for the error message string...) |
(2) Running Babel on output files is what I've been trying today, but this results in Babel "unminifying" the code - if I have to run ESBuild again to minify, that's ESBuild -> Babel -> ESBuild, which isn't pretty, or adding a minifier to Babel. |
Regarding the "dynamic import" error message, I have no idea what triggers this - I just tried removing my entire test-suite from the folder (which I have no idea why it would be picking up in the first place - as said, not listed in my entry-points) and it still emits this error. Literally all that's being compiled now is |
Oh, it's not an error! 😂 The message about dynamic imports is just a warning, I suppose? To let you know that dynamic imports aren't supported when the output format is Okay, so maybe use this feedback to improve the console output? 🙂 If every output message started with e.g. Also maybe consider emitting general messages like I mean, it sounds like the situation where Babel is needed for IE11 is not temporary, so a lot of people are going to have to try to integrate these tools, at least for the time being. (Our product gets embedded on half a million websites, and while I would love to just tell everyone to drop support for IE11, it's not our call - we don't have that liberty. Maybe in a couple of years.) Thanks for trying to help! You can close this issue if there's nothing else actionable you want to take away from this discussion. |
Side note: I discovered the |
I'm going to close this issue since the problem isn't with esbuild, and there's nothing actionable to do here.
A summary message will be printed if you use
This isn't coming from esbuild. This message is from Babel, not esbuild. |
@mindplay-dk Did you manage to somehow solve the issue of "target" |
@januszm this was a while back, but I think I ended up with a dedicated build-step (using Babel) for the IE11 version. If you're looking for something faster, I hear SWC is pretty good - it's probably the only fast transpiler with IE11 support. |
I'm starting a project that targets IE11.
I'd like to use ESBuild during development with modern browsers - then finalize the build by lowering for IE11 with Babel. (The hope is to get a fast development cycle and only transform for IE11 towards the end before cross-browser testing.)
I've tried with
esbuild-plugin-babel
, but no luck.So now I'm attempting to post-process the build by manually integrating Babel, using a build-script along the lines of:
As soon as it hits a
const
, it errors with the following message:The author of
esbuild-plugin-babel
said in this issue to usetarget: "es5"
to avoid the ES6-style closure around the end result withiife
- which, yes, ESBuild emits an old-fashionedfunction
instead, but apparently this has the unfortunate effect of also rejecting the entire build when ES6 features are used.Is there any way to ignore issues like these and just pass the code through without transforming it?
Or some way to configure the
iife
wrapper without configuring the language level?Or is there some other better way to integrate ESBuild and Babel? Maybe by not integrating them at all, and instead just running them as two separate build steps entirely?
Any ideas or examples would be incredibly helpful! Have spent two days now and still not getting to "hello world" 😥
The text was updated successfully, but these errors were encountered: