💻
How are you using Babel?
Programmatic API (babel.transform, babel.parse)
Input code
const babelParser = require("@babel/parser");
const code = `({}<x)`;
console.log(
babelParser.parse(code, {
plugins: ["jsx"],
})
);
Babel REPL – try toggling JSX!
Configuration file name
No response
Configuration
No response
Current and expected behavior
- Babel 7.14.4 and older: The code parses like when JSX is disabled.
- Babel 7.14.5 and newer: The code fails to parse when JSX is enabled.
Environment
System:
OS: macOS 12.3.1
Binaries:
Node: 16.14.2 - /usr/local/opt/node@16/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.5.0 - /usr/local/opt/node@16/bin/npm
npmPackages:
@babel/parser: 7.14.5 => 7.14.5
Possible solution
Figure out what changed between 7.14.4 and 7.14.5. Looking at the changelog, this does not seem to be an intentional change.
Additional context
Note: I did not find this in real-world code. I found it while updating npm packages in js-tokens (a dependency of Babel, btw!). When updating @babel/parser, one of my tests failed. My test runs both js-tokens and @babel/parser and expects the results to be the same. Here’s where @babel/parser failed:
https://github.com/lydell/js-tokens/blob/6d5dba63c58d24ec982b6e859c040294f8ea2598/test/fixtures/valid/jsx1.jsx#L20
💻
How are you using Babel?
Programmatic API (
babel.transform,babel.parse)Input code
Babel REPL – try toggling JSX!
Configuration file name
No response
Configuration
No response
Current and expected behavior
Environment
Possible solution
Figure out what changed between 7.14.4 and 7.14.5. Looking at the changelog, this does not seem to be an intentional change.
Additional context
Note: I did not find this in real-world code. I found it while updating npm packages in js-tokens (a dependency of Babel, btw!). When updating
@babel/parser, one of my tests failed. My test runs bothjs-tokensand@babel/parserand expects the results to be the same. Here’s where@babel/parserfailed:https://github.com/lydell/js-tokens/blob/6d5dba63c58d24ec982b6e859c040294f8ea2598/test/fixtures/valid/jsx1.jsx#L20