preset-env's targets.esmodules will not ignore browsers targets #12688
Answered
by
nicolo-ribaudo
myNameIsDu
asked this question in
Q&A
-
When I view the document, I saw the sentence "Please note: when specifying the esmodules target, browsers targets will be ignored" Original code const a = 123
class Person1 {
};
new Person1() this is config module.exports = (api) => {
api.cache(false);
return {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
},
}
]
]
}
} result "use strict";
var a = 123;
class Person1 {}
;
new Person1(); Add browsers targets module.exports = (api) => {
api.cache(false);
return {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"ie":11,
"esmodules": true
},
}
]
]
}
} result "use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var a = 123;
var Person1 = function Person1() {
_classCallCheck(this, Person1);
};
;
new Person1(); In addition, I saw such a sentence in @babel/preset-modules: the targets.esmodules option is effectively an alias for the set of browsers that support ES Modules: Edge 16+, Safari 10.1+, Firefox 60+ and Chrome 61+. Is he really like this |
Beta Was this translation helpful? Give feedback.
Answered by
nicolo-ribaudo
Jan 24, 2021
Replies: 1 comment 1 reply
-
Its the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
myNameIsDu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Its the
targets.browsers
option that is ignored, and not explicit overrides.