ex) Array.includes
[1,2,3].includes
는 안되었음..)뭐 대충 이런식으로 작성(babel 7기준)
{
"presets": [
["@babel/preset-env", {
"modules": false,
"targets": {
"browsers" : ["last 2 versions", "ie >= 11"]
},
}]
],
"plugins": ["@babel/plugin-transform-async-to-generator", "@babel/plugin-transform-runtime"]
}
@babel/polyfill
은 deprecated// 'foo' could be either a string or an array, or a custom object
foo.includes("a");
// transfile 후에는
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
_includesInstanceProperty(foo).call(foo, "a");
//.babelrc에 corejs3를 쓰도록 명시하고
"presets": [
["@babel/preset-env", {
"targets": {
"browsers" : ["last 2 versions", "ie >= 11"]
},
"useBuiltIns": "usage",
"corejs":3,
"shippedProposals": true
}]
],
//.babelrc
useBuiltIns: "entry",
// main에서는
// before
import "@babel/polyfill";
// after
import "core-js/stable";
import "regenerator-runtime/runtime";
//위의 import는
//chrome72
import "core-js/modules/es.array.unscopables.flat";
import "core-js/modules/es.array.unscopables.flat-map";
import "core-js/modules/es.object.from-entries";
import "core-js/modules/web.immediate";
//chrome73
import "core-js/modules/web.immediate";
"corejs":3,
"shippedProposals": true
or
"corejs":{ version: 3, proposals: true },
아래는 트랜스파일 때 화면 각 소스별로 폴리필을 추가 해 줌
babel7을 업데이트하고 useBuiltIns: "usage"로 polyfill로딩을 최적화