Skip to content

How to use preset-env in ES2020 #15609

Answered by JLHwung
josemigallas asked this question in Q&A
Discussion options

You must be logged in to vote
"browserslist": [
  "chrome >= 107",
  "firefox >= 105",
  "edge >= 107"
]

Your target already supports ?., that's why preset-env does not enable the transform for you. However, in your case, the webpack 4 does not support it. Please upgrade to webpack 5.

If you are stuck at webpack 4, you can use include to always enable ?. transform, though the output code will be slightly bigger than what it supposed to be.

["@babel/preset-env", { "include": [ "proposal-optional-chaining" ] }]

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
3 replies
@josemigallas
Comment options

@nicolo-ribaudo
Comment options

@JLHwung
Comment options

Answer selected by josemigallas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants