Skip to content

feat(repack): add conditionNames to getResolveOptions#365

Merged
RafikiTiki merged 4 commits into
mainfrom
fix/resolve-options
Jun 19, 2023
Merged

feat(repack): add conditionNames to getResolveOptions#365
RafikiTiki merged 4 commits into
mainfrom
fix/resolve-options

Conversation

@jbroma
Copy link
Copy Markdown
Contributor

@jbroma jbroma commented May 24, 2023

Summary

Added conditionNames to getResolveOptions exposed by Re.Pack.

Whenever a dependency in node_modules has exports field in package.json it will be preferred over main when looking for an entrypoint. When exports has conditional fields such as import, require etc. webpack will try to match it's defaults: ['require', 'node']. As our target is React-Native, we should follow closely what metro does and go with default as the only preset conditionName.

This should reduce the effort needed to get the 3rd party dependencies working with Re.Pack when they work out of the box with metro.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 24, 2023

🦋 Changeset detected

Latest commit: bd2b639

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@callstack/repack Patch
testerapp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jbroma
Copy link
Copy Markdown
Contributor Author

jbroma commented May 24, 2023

After some research, I've also included require as a fallback if default is not found. This will make this change less breaking, as some packages do not have default inside exports. In our setup react-native-svg has a dependency of css-select which only has import & require as conditionNames.

@jbroma jbroma marked this pull request as ready for review May 24, 2023 13:38
@jbroma jbroma force-pushed the fix/resolve-options branch from 0936398 to 7a415f3 Compare May 24, 2023 14:48
@RafikiTiki RafikiTiki merged commit cf6c77a into main Jun 19, 2023
@RafikiTiki RafikiTiki deleted the fix/resolve-options branch June 19, 2023 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants