Skip to content

...#1692

Closed
retyui wants to merge 1 commit into
react:mainfrom
retyui:fix/retyui/inline-plugin-relative-imports
Closed

...#1692
retyui wants to merge 1 commit into
react:mainfrom
retyui:fix/retyui/inline-plugin-relative-imports

Conversation

@retyui

@retyui retyui commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

...

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 20, 2026
@retyui retyui force-pushed the fix/retyui/inline-plugin-relative-imports branch from 8658437 to 6b2e449 Compare April 20, 2026 15:42
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Apr 20, 2026
@retyui retyui marked this pull request as draft April 20, 2026 16:01
@retyui retyui force-pushed the fix/retyui/inline-plugin-relative-imports branch from 6b2e449 to 069af3d Compare April 20, 2026 16:17
@retyui retyui marked this pull request as ready for review April 20, 2026 16:17
@robhogan

Copy link
Copy Markdown
Contributor

Stop spamming me, @retyui, please.

@retyui

retyui commented Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Oops, sorry Rob for the notifications! I'll ease up. Hope you're having a good day otherwise

@robhogan

robhogan commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

I think, fundamentally, matching on a relative import without the context that we're inside the react-native package is too prone to false positives.

Since this only affects react-native's own source (and forks), IMO it'd be better to fix there by rewriting those imports from relative paths to self-referencing package imports. I added self-referencing import support to Metro last week, not yet released, partly to facilitate that.

@rubennorte

Copy link
Copy Markdown
Contributor

IMO it'd be better to fix there by rewriting those imports from relative paths to self-referencing package imports

This is very unidiomatic tbh and we actually have lint rules to prevent this.

Can we not know the path of the module being transformed to detect we're inside react-native?

@retyui retyui force-pushed the fix/retyui/inline-plugin-relative-imports branch from 069af3d to 840bd3a Compare June 9, 2026 13:43
@retyui retyui requested a review from javache June 9, 2026 13:45
@robhogan

robhogan commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

IMO it'd be better to fix there by rewriting those imports from relative paths to self-referencing package imports

This is very unidiomatic tbh and we actually have lint rules to prevent this.

Yeah I don't love it either 😅. It's not idiomatic, and it'd be a bad idea in general to import via a barrel file - this is a bit of a special case as Metro transforms the import away but it is still ugly. To solve for consumers of RN other than Meta it could be a pre-publish rewrite rather than something that lives in source.

Can we not know the path of the module being transformed to detect we're inside react-native?

Potentially, yeah - the projectRoot-relative path is a cache-safe transform input. It's not so easy to cover using RN directly from source in that case though.

Another ugly option is to guess that we're inside RN based on the copyright header or @oncall react_native.

Or, invent an explicit compiler hint and annotate the import.

Comment thread packages/metro-transform-plugins/src/utils/createInlinePlatformChecks.js Outdated
@retyui retyui force-pushed the fix/retyui/inline-plugin-relative-imports branch from 840bd3a to aab6ea0 Compare June 9, 2026 15:57
@retyui retyui requested a review from robhogan June 10, 2026 08:22
@retyui retyui closed this Jun 12, 2026
@retyui retyui deleted the fix/retyui/inline-plugin-relative-imports branch June 12, 2026 09:19
@retyui retyui changed the title Fix: Add support for relative Platform ES imports (inline-plugin) ... Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants