Skip to content

fix(parser): parser should not crash for import defer {} - #18431

Merged
nicolo-ribaudo merged 2 commits into
7.xfrom
automation/backport-18406
Oct 27, 2026
Merged

nicolo-ribaudo merged 2 commits into
7.xfrom
automation/backport-18406

Conversation

@babel-bot

Copy link
Copy Markdown
Collaborator

Backport of #18406 to 7.x

Cherry-picked commits:

  • df3d4af → fix(parser): parser should not crash for import defer {}

Conflicts: Resolved.

  • packages/babel-parser/src/parser/statement.ts: on main, checkImportPhase is a different function than on 7.x (7.x still has checkImportReflection, which also handles module imports and sits next to the JSON-module helpers). I kept the 7.x function and added the intent of the fix there: the specifiers[0].loc.start error positions for SourcePhaseImportRequiresDefault and DeferImportRequiresNamespace become node.loc.start, so empty import defer {} / import source {} no longer crash. The early phase == null return was not added because 7.x's function also handles node.module.

Checks:

  • rebuild: passed
  • yarn jest packages/babel-parser: passed (including the new fixtures)
  • full test: 1 suite failed, packages/babel-code-frame/test/color-detection.js (6 tests). It is unrelated, a terminal color-detection issue in the CI environment.
  • lint: eslint and tsc ran with no errors reported. check-compat-data could not run because the sandbox has no network access (cloning compat-table failed).

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 🔙 Backport to 7.x for #18406 · copilot · auto · 18.8 AIC · ⌖ 0.744 AIC · ⊞ 9.1K · ◷

@babel-bot

babel-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62630

@JLHwung

JLHwung commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix prettier error.

Copilot AI commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix prettier error.

Fixed the prettier error in statement.ts. The two this.raise calls now fit on one line each. I checked it with prettier 3.5.2.

Copilot AI requested a review from JLHwung October 27, 2026 13:57
@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: d6c6c67

@nicolo-ribaudo
nicolo-ribaudo merged commit b719c32 into 7.x Oct 27, 2026
169 of 170 checks passed
@nicolo-ribaudo
nicolo-ribaudo deleted the automation/backport-18406 branch October 27, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.x: backport pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Source Phase Imports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants