-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
babel-register: Fast path without transpilation/source-map-support when no plugins are enabled? #6163
Comments
Hey @papandreou! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
Wouldn't you want the dev experience to mirror the CI/prod experience, "bugs of its own" and all? |
@ljharb, that would be nice, of course, but since it's still a relatively rare occurrence, I can live with CI catching those cases. |
I made a module called maybabel that helps me achieve what I want. It's inferior to having babel-preset-env determine the capabilities at runtime, so I still hope you'll consider this feature request. |
Also similar to #5890. If we can determine nothing is run we should just return the file sure, would appreciate a pr if you want this earlier since we are trying to release v7 |
Revisiting this, I'd be open to this as a Babel option like |
Choose one: is this a bug report or feature request?
Feature request
I'm introducing babel and babel-preset-env in a project (unexpectedjs/unexpected#416) where the main development takes place in bleeding edge node, but the code has to be transpiled to work in older node.js versions (including on CI) and in older browsers.
Since node.js 8.3.0+ has a fairly complete ES201[567] implementation I thought I'd use that as the baseline so I wouldn't need to transpile anything in my main edit->save->test cycle. I expected babel-preset-env to just bypass the transpilation pipeline when none of the configured plugins are required in the running environment. It could simply unhook itself from
require.extensions
and not bother installingsource-map-support
.The reasons why I'd like it to work like that are:
require
d at all.My
.babelrc
looks like this:babel-preset-env
's debug mode displays an empty list of plugins when I run it in node.js 8. However, I can tell that despite this fact, babel is still burning cycles processing and reserializing all my code. This results in a performance degradation of about half a second compared to removing--require babel-register
from the mocha command line.Since the premise of
babel-preset-env
is to dynamically adjust the amount of work that has be done, I expected it to disable babel's require hook altogether when the platform has all the required capabilities. The alternative would be for me to wrapbabel-register
in a module of my own and only execute the require when using node.js < 8.3.0, then use that instead ofbabel-register
. However, that's hard to get to work with tools that include native babel support (such as jest), and the exact cutoff point is subject to change. To me it feels like something that babel itself should take care of.I brought up the issue/idea in the slack channel here: https://babeljs.slack.com/archives/C0DFJT81H/p1503758913000063
There was a productive discussion, some potential caveats were brought up, but the idea of a fast path when no plugins are configured was not flat out rejected, so I'm taking the liberty of raising it here :)
Thanks in advance for considering it!
Your Environment
The text was updated successfully, but these errors were encountered: