Parsing failure before transformation when using @babel/preset-env
0 reputation · 03 Aug 2020, 08:00 UTC
The goal is to clarify whether @babel/preset-env influences the parsing stage of Babel’s pipeline or only the transformation stage when deciding which syntax features to support for a given target list.
Because the parser runs before any plugin visitors, it is unclear if preset-env loads syntax‑plugin equivalents (e.g., @babel/plugin-syntax-top-level-await) based on the targets, which would allow the parser to accept newer syntax, or if it relies solely on transform plugins after a successful parse. This uncertainty affects how malformed syntax is reported when a target environment supposedly supports the feature.
- Does @babel/preset-env automatically enable the corresponding syntax plugins for features it decides to transform based on the target list?
- If a syntax plugin is enabled, will Babel still treat a malformed syntax as a parse error, or will it defer to the transformation plugins to handle it?
- How does loose mode interact with this behavior for syntax plugins?