Skip to content

Update bundle mode patch guide to add bun patching instructions#9818

Open
acarlson33 wants to merge 6 commits into
software-mansion:mainfrom
acarlson33:patch-2
Open

Update bundle mode patch guide to add bun patching instructions#9818
acarlson33 wants to merge 6 commits into
software-mansion:mainfrom
acarlson33:patch-2

Conversation

@acarlson33

@acarlson33 acarlson33 commented Jul 1, 2026

Copy link
Copy Markdown

Added instructions for using bun without patch-package for better compatibility with bun.

Summary

There weren't any instructions for patching bun repositories, and patch-package by itself doesn't work because in monorepos at least, bun installs deps into the .bun folder inside of node_modules, which breaks patch-package. I added a section to the patching instructions that details how to use bun's built in patching mechanisms along with git to make the patches for bun monorepos with isolated linking.

Test plan

This is just a documentation change, but I've verified the patches are successful, and you can do so by following the instructions added into the file.

Added instructions for using bun with patch-package for better compatibility and performance.
@jsg2021

jsg2021 commented Jul 2, 2026

Copy link
Copy Markdown

You don't need patch-package with bun.

Just apply them with git and commit.

# download patches
curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro-runtime/metro-runtime+0.84.4.patch
curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro/metro+0.84.4.patch

# apply
bun patch metro-runtime #optional... if you know the package is clean, you can skip
(cd node_modules/metro-runtime apply ../../metro-runtime+0.84.4.patch)
bun patch --commit metro-runtime

bun patch metro
(cd node_modules/metro && git apply ../../metro+0.84.4.patch)
bun patch --commit metro

# cleanup
git add patches package.json
git commit -m "chore: patch metro"

rm ,/metro*.patch

Updated bun patching instructions to not rely on patch-package and instead use `git apply` to apply the patches before committing them with bun.
@acarlson33

acarlson33 commented Jul 2, 2026

Copy link
Copy Markdown
Author

You don't need patch-package with bun.

Just apply them with git and commit.

# download patches
curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro-runtime/metro-runtime+0.84.4.patch
curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro/metro+0.84.4.patch

# apply
bun patch metro-runtime #optional... if you know the package is clean, you can skip
(cd node_modules/metro-runtime apply ../../metro-runtime+0.84.4.patch)
bun patch --commit metro-runtime

bun patch metro
(cd node_modules/metro && git apply ../../metro+0.84.4.patch)
bun patch --commit metro

# cleanup
git add patches package.json
git commit -m "chore: patch metro"

rm ,/metro*.patch

Thanks for that, I doubt I would have figured out there would be a way to do it with git as I don't patch packages super often. I refactored the doc to include that instead of using patch-package. I didn't add the rm command yet, (I will in a future commit here soon), but I think it'll have to look like this: rm ./patches/metro+*.patch && rm ./patches/metro-runtime+*.patch I figure that's a safer option because running bun patch --commit 'node_modules/metro' will cause bun to create a patch of the package that you can commit to the repo but it does so with a naming convention like this: metro@0.84.4.patch. We don't want to remove these patch files so installing the deps on another machine or clearing node_modules and reinstalling doesn't cause bun to error when it tries to apply the patch on installation. However, we should be able to remove the patch-package ones we initially used.

Added instructions to return to project root before applying patches. Also added step 8 to optionally remove old `patch-package` patches in favor of bun's generated patches only.
@acarlson33 acarlson33 changed the title Update README with bun patching instructions Update bundle mode patch guide to add bun patching instructions Jul 2, 2026
@jsg2021

jsg2021 commented Jul 2, 2026

Copy link
Copy Markdown

You don't need patch-package with bun.

Just apply them with git and commit.

download patches

curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro-runtime/metro-runtime+0.84.4.patch

curl -fsSLO https://github.com/software-mansion/react-native-reanimated/raw/refs/heads/main/packages/react-native-worklets/bundleMode/patches/patch-package/metro/metro+0.84.4.patch

apply

bun patch metro-runtime #optional... if you know the package is clean, you can skip

(cd node_modules/metro-runtime apply ../../metro-runtime+0.84.4.patch)

bun patch --commit metro-runtime

bun patch metro

(cd node_modules/metro && git apply ../../metro+0.84.4.patch)

bun patch --commit metro

cleanup

git add patches package.json

git commit -m "chore: patch metro"

rm ,/metro*.patch

Thanks for that, I doubt I would have figured out there would be a way to do it with git as I don't patch packages super often. I refactored the doc to include that instead of using patch-package. I didn't add the rm command yet, (I will in a future commit here soon), but I think it'll have to look like this: rm ./patches/metro+*.patch && rm ./patches/metro-runtime+*.patch I figure that's a safer option because running bun patch --commit 'node_modules/metro' will cause bun to create a patch of the package that you can commit to the repo but it does so with a naming convention like this: metro@0.84.4.patch. We don't want to remove these patch files so installing the deps on another machine or clearing node_modules and reinstalling doesn't cause bun to error when it tries to apply the patch on installation. However, we should be able to remove the patch-package ones we initially used.

the rm command just removes the downloaded source patches. you don't want to delete the files in the patches directory that bun creates.

@acarlson33

Copy link
Copy Markdown
Author

The command I made filtered the patches by whether or not the patch files have the + in them. The bun ones will be filtered out because they contain @, so it shouldn't be an issue.

@jsg2021

jsg2021 commented Jul 3, 2026

Copy link
Copy Markdown

@acarlson33 yes, you are correct. My example put the source patches in a different directory to avoid the collision, and so it didn't need to handle the filter.

I probably should have output to /tmp or something to make that clearer. But anyways. I like to keep things as simple as possible. The more flags & filters we add to readmes, the more intimidating it is for the less experienced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants