Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Pass file instead of path to importToPlatformApi builders#17816

Merged
nicolo-ribaudo merged 1 commit intobabel:mainfrom
nicolo-ribaudo:pass-file-to-import-types-helper-plugin
Feb 23, 2026
Merged

Pass file instead of path to importToPlatformApi builders#17816
nicolo-ribaudo merged 1 commit intobabel:mainfrom
nicolo-ribaudo:pass-file-to-import-types-helper-plugin

Conversation

@nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

I'm working on support for https://github.com/tc39/proposal-import-bytes, and it would be helpful to have the file passed to the "Pieces builders" so that I can easily inject helpers in there.

This is technically a breaking change, but it's unobservable for users that are not manually using the helper package, given that right now versions are pinned. I'm opening this as its own PR because we need to ship it at latest in 8.0.0, when we'll stop pinning dependencies.

@nicolo-ribaudo nicolo-ribaudo added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label Feb 20, 2026
throw path.buildCodeFrameError(
buildFetch = (specifier, file) => {
throw file.buildCodeFrameError(
specifier,
Copy link
Member Author

@nicolo-ribaudo nicolo-ribaudo Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now points to the specifier, before it would point to the whole file (since we always passed in the program path).

@babel-bot
Copy link
Collaborator

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 20, 2026

Open in StackBlitz

commit: e135e27

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the interface change, do you think during the lifetime of Babel 8 we will have to transform JSON module imports within module declaration or module expression? If so we may have to pass file and program path separately.

@nicolo-ribaudo
Copy link
Member Author

If that happens I think we can add a third path parameter, which defaults to file.path, in a non-breaking way.

@nicolo-ribaudo nicolo-ribaudo merged commit ca36d55 into babel:main Feb 23, 2026
55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the pass-file-to-import-types-helper-plugin branch February 23, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants