🤧

@babel/preset-envのIE11で有効になるプラグインを確認する

2021/03/21に公開

@babel/preset-env で IE11をターゲットにしたとき有効になるプラグインが知りたくなった。
正しく網羅できているかは確認してないけど、下記の方法で調べた。

curl curl https://raw.githubusercontent.com/babel/babel/main/packages/babel-compat-data/data/plugins.json \
 | jq '. | to_entries | map(select((.value.ie // "0"| tonumber) < 11) | "@babel/plugin-" + .key)' 
[
  "@babel/plugin-proposal-class-properties",
  "@babel/plugin-proposal-private-methods",
  "@babel/plugin-proposal-numeric-separator",
  "@babel/plugin-proposal-logical-assignment-operators",
  "@babel/plugin-proposal-nullish-coalescing-operator",
  "@babel/plugin-proposal-optional-chaining",
  "@babel/plugin-proposal-json-strings",
  "@babel/plugin-proposal-optional-catch-binding",
  "@babel/plugin-transform-parameters",
  "@babel/plugin-proposal-async-generator-functions",
  "@babel/plugin-proposal-object-rest-spread",
  "@babel/plugin-transform-dotall-regex",
  "@babel/plugin-proposal-unicode-property-regex",
  "@babel/plugin-transform-named-capturing-groups-regex",
  "@babel/plugin-transform-async-to-generator",
  "@babel/plugin-transform-exponentiation-operator",
  "@babel/plugin-transform-template-literals",
  "@babel/plugin-transform-literals",
  "@babel/plugin-transform-function-name",
  "@babel/plugin-transform-arrow-functions",
  "@babel/plugin-transform-classes",
  "@babel/plugin-transform-object-super",
  "@babel/plugin-transform-shorthand-properties",
  "@babel/plugin-transform-duplicate-keys",
  "@babel/plugin-transform-computed-properties",
  "@babel/plugin-transform-for-of",
  "@babel/plugin-transform-sticky-regex",
  "@babel/plugin-transform-unicode-escapes",
  "@babel/plugin-transform-unicode-regex",
  "@babel/plugin-transform-spread",
  "@babel/plugin-transform-destructuring",
  "@babel/plugin-transform-block-scoping",
  "@babel/plugin-transform-typeof-symbol",
  "@babel/plugin-transform-new-target",
  "@babel/plugin-transform-regenerator",
  "@babel/plugin-transform-member-expression-literals",
  "@babel/plugin-transform-property-literals",
  "@babel/plugin-transform-reserved-words",
  "@babel/plugin-proposal-export-namespace-from"
]

本当は実行時の値を出力したいのだが、目的は達成できたので妥協してしまった。

--
この記事は業務中に得たノウハウをちょっと修正して公開しているものである。

Discussion