Skip to content

[Bug]: "Support for the experimental syntax 'importReflection' isn't currently enabled" triggered incorrectly on some import statements #15197

@jpm4

Description

@jpm4

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

https://babel.dev/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=PTAEHcHsCcGsGcBQBLAtgBxgF1KyATAVwBsBTUAM2klVAHI8iy6BuRECGBFDbUAb1ABjaKQCGWUgCVSAR0LJRoAL6VqtBgRKlW7MACNRY7mkzQcjbQBoBwo5JnzF5VVRr1LzFkA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=&prettier=false&targets=&version=7.20.4&externalPlugins=&assumptions=%7B%7D

Configuration file name

No response

Configuration

No response

Current and expected behavior

In our monorepo, one of the packages has a line like:

import module, { createRequire } from 'module';

for the actual node Module API. On a recent upgrade attempt (@babel/parser 7.19.4 -> 7.20.1 I believe), we were seeing Support for the experimental syntax 'importReflection' isn't currently enabled, however, this is not an attempted usage of importReflection. I suspect the logic introduced in this PR incorrectly flags this case as importReflection.

Workaround was to simply change the default import name.

Expected behavior would be for module to work as a default import name when also importing named functions, regardless of importReflection status.

Environment

System:
OS: Linux 5.4 Ubuntu 18.04.5 LTS (Bionic Beaver)
Binaries:
Node: 16.13.2 - /nail/tmp/xfs-d1ce38f1/node
Yarn: 3.2.0 - /nail/tmp/xfs-d1ce38f1/yarn
npm: 8.1.2 - /opt/nodejs/node-v16.13.2/bin/npm
Monorepos:
Yarn Workspaces: 3.2.0
Lerna: 3.18.3
npmPackages:
@babel/core: ^7.15.5 => 7.19.3
babel-jest: ^29.1.2 => 29.1.2
babel-plugin-smart-webpack-import: ^2.0.0 => 2.0.0
jest: ^29.1.2 => 29.1.2
lerna: ^3.16.4 => 3.18.3

Possible solution

Likely a slight tweak to this logic:

parseMaybeImportReflection(node: Undone<N.ImportDeclaration>) {

Additional context

No response

Metadata

Metadata

Assignees

Labels

i: regressionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions