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 puts 'use strict'; in front of everything #1844
Comments
ES6 modules have an implicit strict mode so at the least you'll get
Not sure what you mean by "no transformers specified", by default all the ES6/stable transformers are enabled. Also FWIW, the strict directive is being duplicated because you've got the semicolon inside the string, moving it out results in the strict directive only being output once. |
Ah, can I disable them? I really only want Babel for its transpiling abilities.
I made a typo in the report above. The original code implemented strict mode correctly, and still generated the duplicate declaration. |
Strict mode is a part of that though?
Nope?
|
@sebmck FWIW, there is a (different)
|
@jmm Can you open a new issue? Should be easy enough to fix. |
@sebmck you're right, there was a bug in my test case. I was echoing the output twice!
No. Why, should it be? I'm experimenting with a superset of Javascript. For my own sanity, I'd like to be confident that the changes I get are just the changes I ask for. I think I just made the case for that requirement at the top of this post :) |
I see. It wasn't clear to me that Babel exclusively targets ES6. I deduced that it was written to enable ES6 compatibility in legacy browsers but the homepage gave me the impression it was also a general purpose transpiler. |
It doesn't? Babel just has an comprehensive suite of ES6 transformers that are enabled by default.
Yeah it is. There's a whole host of plugins. And syntax extensions, linting/static analysis and minification is in the pipeline. |
So can I disable them? It doesn't seem to be possible without modifying the code. I have stripped them out of |
You can disable any of the transformers. See the docs here for a list of the built-in ones. And see the strict transformer docs on how to disable that particular behaviour. |
Annoying issue, what a point to force "strict" mode? |
|
I've created the simplest babel programme I can think of, that I would expect to do nothing.
I had presumed that a call to
transform
with no transformers specified would do nothing. At the very least it's forcing strict mode on me. Is this a bug or a feature? Are there other things babel forces on me by default?The text was updated successfully, but these errors were encountered: