-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package Exports resolution differs from Node in 2 edge cases #1236
Comments
Few other insights about Package Exports implementation & tests:
FYI, im willing to submit a PR for this after we agree on the spec. |
Thanks @jbroma!
Wow, essentially these implementations have a special-case expansion of
Yup, also looks incorrect ✅. I don't think we have a test against that behaviour at all.
These tests are for in-spec behaviour, so I think this is right as-is. However, the assertions seem slightly wrong (unless I'm misremembering) — they should be Yes please to PRs! 🙌🏻 Recommend splitting into one PR per fix, and we'll happily look through :). |
@huntie all tasks from the issue handled in the PRs above. |
Summary: This PR deals with restricting internal paths through the most specific subpath pattern edge case from #1236 - [x] - added test for implicit default condition to match Node.js resolution algorithm - [x] - aligned implementation of `reduceConditionalExport` to account for implicit default condition Changelog: [Experimental] Fix implicit default condition to be null for subpath patterns (edge case) Pull Request resolved: #1239 Test Plan: - [x] - all tests pass Reviewed By: EdmondChuiHW Differential Revision: D55244268 Pulled By: huntie fbshipit-source-id: e9cddbad2709a90a0282385a1b59ebc03735f975
…ve exports target directly tests (#1240) Summary: This PR adds comments to assertions in tests that check that neither `sourceExts` or `platformExts` are expanded when matching exports target directly, which was suggested inside of #1236 by huntie. The assertions rely on using `[nonstrict]` fallback mechanism as there is no other way to test this functionality right now because `strict` mode is not implemented. Changelog: [Internal] Refactor Package Exports `sourceExts` and `platformExts` tests that rely on fallback Pull Request resolved: #1240 Test Plan: - [x] - all tests pass Reviewed By: hoxyq Differential Revision: D55427364 Pulled By: huntie fbshipit-source-id: 8a36469508c67406e721b0300383d6b18add3ad2
Summary: This PR deals with array root shorthand edge case from #1236 - [x] - fixed array root shorthand spec in tests to match Node.js resolution algorithm - [x] - aligned implementation of package exports for array root shorthand - [x] - added extra `[nonstrict]` test case to highlight that non-declared paths from array should not work normally Changelog: [Experimental] Fix package exports array root shorthand resolution to behave like node (edge case) Pull Request resolved: #1238 Test Plan: - [x] - all tests pass Reviewed By: robhogan Differential Revision: D55688565 Pulled By: huntie fbshipit-source-id: edec02f30b38d5a372e3369277edc9460b4e8710
Do you want to request a feature or report a bug?
Bug
Hey metro team! 👋
I was working on aligning Re.Pack's resolution setup to follow
metro-resolver
with RN defaults closely and found these 2 edge-cases weremetro-resolver
behaves in a weird way when dealing with Package Exports:1. Root Array Shorthand
For the Root Array shorthand, the implementation differs when compared to Node.js or Webpack's
enhanced-resolve
specification:Results:
For the import specifier:
@metro-package-exports/root-shorthand
index.js
inside of@metro-package-exports/root-shorthand
.index.js
within@metro-package-exports/root-shorthand
.@metro-package-exports/root-shorthand
directory itself.2. Subpath Patterns in
exports
When using subpath patterns in
exports
to match the import specifier, the behaviors observed are as follows:Results:
For the import specifier:
@metro-package-exports/restricted/features/internal/b.js
b.js
is not exported from@metro-package-exports/restricted
.@metro-package-exports/restricted/features/internal/b.js
without falling back to file resolution.Reproduction repository
https://github.com/jbroma/metro-package-exports
Setup
yarn
v1 (classic).tester
directory executable by runningchmod +x
on them.test-root-shorthand.sh
&test-restricted.sh
scripts.What is the expected behavior?
Resolution in edge cases above should follow Node.js resolution algorithm
The text was updated successfully, but these errors were encountered: