Skip to content

fix: copy guarded require properties safely - #1435

Open
yellowbeee wants to merge 3 commits into
callstack:mainfrom
yellowbeee:codex/fix-guarded-require-strict-mode
Open

fix: copy guarded require properties safely#1435
yellowbeee wants to merge 3 commits into
callstack:mainfrom
yellowbeee:codex/fix-guarded-require-strict-mode

Conversation

@yellowbeee

Copy link
Copy Markdown

Summary

  • copy guarded __webpack_require__ runtime properties using their descriptors
  • skip non-configurable Function intrinsics already present on the wrapper
  • add a strict-mode regression test and a patch changeset

Problem

The guarded require runtime assigns every own property from the original require function directly to its wrapper. When the runtime is emitted inside a strict-mode bundle, assigning read-only Function properties such as length or name throws before the React Native application entry can run.

Descriptor copying also avoids evaluating runtime getters while the wrapper is being initialized and preserves their original enumerability and accessors.

Test plan

  • pnpm --filter @callstack/repack test -- guardedRequire.test.ts --runInBand
  • pnpm --filter @callstack/repack typecheck
  • pnpm exec biome check packages/repack/src/plugins/RepackTargetPlugin/implementation/guardedRequire.ts packages/repack/src/plugins/RepackTargetPlugin/implementation/__tests__/guardedRequire.test.ts

@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 94c8ac8

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

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init 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

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

@yellowbeee is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@dannyhw

dannyhw commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Hey thanks for your pr 🙏.

Was wondering if you can help describe the issue it solves a bit mode.

Do we have an issue for the bug it fixes? How to reproduce that problem?

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.

2 participants