Index of every page on this site: llms.txt
All skills
software-mansion-labs avatar

/enable-worklets-bundle-mode

@43cde80
Run it yourself

Enable react-native-worklets Bundle Mode (imports inside worklets, third party libraries on worklet runtimes) in an Expo, RN CLI or brownfield React Native app, including the mandatory metro/metro-runtime patches. Use when the user asks to enable Bundle Mode, wants to import npm libraries inside worklets or offload JS code to worklet runtimes, or hits "Failed to get the SHA-1" errors in a worklets Bundle Mode project / missing Fast Refresh for worklet code. Covers enabling only — not disabling; upgrades react-native-worklets to a compatible version when needed, but never installs it from scratch and never touches Reanimated.

Use this Skill: https://skilld.dev/gh/software-mansion-labs/skills/enable-worklets-bundle-mode

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesuniwind-remap-workaround.md

≈899 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Bundle Mode + uniwind (and other react-native-remapping resolvers)

Source: https://github.com/software-mansion/react-native-reanimated/issues/9817 (root cause in the issue body, workaround in the maintainer comment). Not fixable inside worklets — Metro provides no way to prevent resolution cycles — so the fix lives in the app's metro.config.js.

The problem

Bundle Mode's resolver redirects every react-native import to its own shim (bundleMode/shims/reactNativeShim.js), and the shim re-acquires the real module with require('react-native') — the bare specifier, which re-enters the resolver chain. Any other resolver that remaps that bare specifier intercepts the shim's require: uniwind rewrites import 'react-native' → uniwind/components, whose own internal require('react-native') Bundle Mode redirects back to the shim. The result is a shim ↔ uniwind/components require cycle. NativeWind is reported to trigger the same class of problem.

Symptoms — startup crash before AppRegistry.registerComponent runs:

ERROR  [runtime not ready]: RangeError: Maximum call stack size exceeded (native stack depth)
ERROR  [runtime not ready]: Invariant Violation: "main" has not been registered.

The workaround (from the maintainers)

Two parts: apply withUniwindConfig BEFORE getBundleModeMetroConfig (many broken setups have it the other way around), then install an outermost resolver guard that pins react-native requests originating inside the uniwind package to the real react-native path:

const path = require('path');

config = withUniwindConfig(config, {
  cssEntryFile: './global.css',
  dtsFile: './uniwind-types.d.ts',
});
config = getBundleModeMetroConfig(config);

const uniwindDir = path.dirname(require.resolve('uniwind/package.json')) + path.sep;
const realReactNativePath = require.resolve('react-native');
const wrappedResolveRequest = config.resolver.resolveRequest;
config.resolver.resolveRequest = (context, moduleName, platform) => {
  if (
    moduleName === 'react-native' &&
    typeof context.originModulePath === 'string' &&
    context.originModulePath.startsWith(uniwindDir)
  ) {
    return { type: 'sourceFile', filePath: realReactNativePath };
  }
  return (wrappedResolveRequest || context.resolveRequest)(context, moduleName, platform);
};

module.exports = config;

Keep the app's existing withUniwindConfig import and options — only the ordering and the guard are new.

Why it works (inferred from the issue's root-cause description): app code's react-native still goes shim → uniwind/components (both libraries' rewrites stay active), but uniwind/components' internal require('react-native') hits the guard and resolves straight to the real react-native file — a concrete path that never re-enters resolution, so the cycle cannot form.

Caveats

  • Non-standard setups (monorepos): verify uniwindDir and realReactNativePath point at the copies the app actually uses — e.g. require.resolve('react-native', { paths: [__dirname] }) from the app package.
  • Other remapping libraries (e.g. NativeWind): same guard pattern, but scope the origin check to that library's package dir instead of uniwind's. This variant is untested — the issue thread only validates the uniwind one.
  • Watch the upstream issue: it proposes a sentinel-specifier fix inside worklets; if that ships, this guard becomes unnecessary (check node_modules/react-native-worklets/bundleMode/shims/reactNativeShim.js — if it no longer contains require('react-native'), the fix landed).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill enables Bundle Mode for react-native-worklets by updating Babel and Metro configurations and applying official patches to the Metro bundler. It fetches these patches from the official software-mansion GitHub repository and applies them using standard package management tools.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 43cde80. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 4 months ago
metadata
{
  "author": "Tomasz Żelawski",
  "version": "1.0.0"
}
Other metadata
compatibility
Requires network access to raw.githubusercontent.com and api.github.com to fetch metro patches

README badge

README badge for software-mansion-labs/skills/enable-worklets-bundle-mode