Repository navigation
Conversation
Record the design for issue callstackincubator#194: a bundler setting with Metro as the default, a bundler-webpack package that runs the compiler in-process from the project's config, test files delivered as async chunks from a generated manifest, and two seams in the runtime for the module system and the host. Refs callstackincubator#194
A small react-native-web app with no Metro config, built by webpack (babel-loader) and by Rspack (builtin:swc-loader). It uses a path alias, a DefinePlugin constant and an asset module, and carries Harness tests for those features, rendering, module mocking and setup files. It is the acceptance fixture for the bundler described in ADR 0002. The Harness tests cannot run until that bundler exists. Refs callstackincubator#194
Add @react-native-harness/bundlers with the bundler descriptor, the bundler-neutral instance and events, and the startup detection moved out of bundler-metro. bundler-metro implements it through metroBundler() and a module that wraps the Metro instance and translates its reporter events. The Harness config gains an optional bundler field; without it the Jest session uses Metro as before. New bundler:* plugin hooks fire for every bundler, next to the existing metro:* hooks when the bundler is Metro. No change in behavior for Metro. This is step 1 of ADR 0002. Refs callstackincubator#194
The neutral interface has no HTTP server, health is reported as a status object, and the descriptor carries a display name. Refs callstackincubator#194
Split the runtime along a module system (load a file and run it, release it, create the mock registry) and a host (dev-server URL, reload, HMR, LogBox, the global error handler, stack parsing). The Metro and React Native implementations are the existing code moved into src/metro and installed by the Metro entry before the common startup runs. A lint rule keeps files outside src/metro from importing that folder, React Native deep imports, or Metro's module registry. No change in behavior. The playground suite gives identical results before and after on Chromium, on a physical Android device and on the iOS simulator. This is step 2 of ADR 0002. Refs callstackincubator#194
Loading a file and running it stay separate steps, because a test file is fetched before collection and executed inside it. Note what that requires of the webpack implementation, and update paths that moved. Refs callstackincubator#194
Add @react-native-harness/bundler-webpack. webpackBundler() and rspackBundler() load the project's own config, swap the app entry for the Harness runtime, and serve the compilation and the bridge from one Harness-owned server. Test and setup files are async chunks listed in a generated manifest, and a pre-loader applies the mock id rewrite whatever transpiler the project uses. Web platform only; watch mode fails with a clear error until it is implemented. The runtime gains a webpack module system and a browser host next to the Metro ones. The bundler interface gains an optional setRunFiles hook that the session calls at the start of each run. Server connection tracking is shared with the Metro bundler through @react-native-harness/tools. The sandbox app now runs its Harness tests on both bundlers, selected with HARNESS_BUNDLER. Metro behavior is unchanged: the playground suite gives identical results on Chromium, a physical Android device and the iOS simulator. This is step 3 of ADR 0002. Refs callstackincubator#194
Describe the generated entry and manifest as built, require.ensure and its four-argument form, the swap before resolution and its two errors, the loader's rules, page-request detection and setRunFiles. Record the two measured mocking differences from Metro and why they are documented rather than removed. Rspack moves into step 3. Refs callstackincubator#194
…nerated page
Brings the webpack and Rspack bundler to parity with Metro for web runs:
- Watch mode. Each watch run writes a marker into the generated manifest
and waits for the build that picks it up, so the build holds every edit
made before the run. The bundler then asks the session to reload the app,
which still holds the chunks of the build before. A watcher that ignores
the .harness folder fails the run with an error that says so.
- /symbolicate. Failures get a code frame from the build's source maps,
whatever the config names the map files and their sources.
- Coverage. The loader instruments the project's source as written, with
the settings the Babel preset gives Metro, and a persistent cache gets an
identity of its own while coverage is collected.
- A project whose build emits no HTML gets a generated page that loads
every entrypoint.
BundlerInstance.setRunFiles now resolves with { reloadRequired }, and the
session performs the reload through its reset strategies. Metro does not
implement it and behaves as before.
Refs callstackincubator#194
…bpack Describes what step 4 built: which devtool settings are kept, the cache identity while coverage is collected, what the loader instruments, how a frame is mapped back to a file, the generated page, and the watch-mode wait on the compiler's own watcher. Adds the costs and limits that came out of it to the risks. Refs callstackincubator#194
…g users cannot act on The two build errors for an entryPoint that matches no entry told users to copy the path as written in the config's entry, which is wrong when the config's context is not the project root. They now say what is compared: entryPoint resolved from the project root against the entry request. A project installed from npm printed a missing-export warning on every run, from Harness's own packages importing native-only exports of react-native, which a web build aliases to react-native-web. That one warning is now ignored. The project's own ignoreWarnings entries are kept, and no other warning is hidden. Refs callstackincubator#194
Adds a matrix job next to the web end-to-end job that runs apps/playground-webpack in Chromium on each bundler, under the same trigger. Screenshot artifacts are off for it: the app has no screenshot tests, and the action's artifact name is the same for every job. Refs callstackincubator#194
Adds a guide for the webpack and Rspack bundler, the bundler option, the bundler:* plugin hooks, and the mocking patterns that behave the same on every bundler. Corrects the web platform's requirements: Harness starts the bundler itself, and a Metro project's page has to be served by its Metro config. Brings the sandbox app's and the package's README up to date. Refs callstackincubator#194
|
@manapard is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Demo: the sandbox app from this PR (
demo.mp4 |
manapard
marked this pull request as ready for review
November 18, 2026 08:36
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
Harness can now run web tests in a project that is bundled by webpack or Rspack and has no Metro config. Until now the web platform needed Metro, so a react-native-web app built only with webpack could not adopt Harness (#194).
A project opts in with a new
bundleroption and a new package:Metro stays the default and nothing changes for projects that use it. Native apps bundled with Re.Pack are not covered; that needs its own design.
How does it work?
Harness loads the project's own webpack or Rspack config, runs the compiler in-process and serves the result from its own server, next to the bridge the tests talk to. The project's loaders, aliases, plugins and constants apply as they do in the app. Harness changes only what testing needs: development mode, a source map it can read, optimizations that merge modules turned off, and the app's entry replaced by one that starts the Harness runtime. Each test file is built as a chunk of its own and loaded when its turn comes.
To make that possible, two parts of Harness stop assuming Metro:
@react-native-harness/bundlers). Metro is the first implementation and webpack/Rspack the second. Plugins getbundler:*hooks that fire for every bundler; themetro:*hooks still fire for Metro.mock,requireActual,resetModules) and the host (dev server URL, reload, stack parsing) through two seams, with a Metro and a webpack implementation of each.Watch mode, code frames for failures,
--coverage, setup files and module mocking work on both new bundlers. Two mocking behaviors differ from Metro and are documented with a pattern that works everywhere: callmock()before the consumer is first loaded, and return{ __esModule: true, default: fn }when mocking a default export.docs/adr/0002-webpack-bundler-backend.mdrecords the decision, the options that were rejected and the known limits.apps/playground-webpackis a small react-native-web app with a webpack and an Rspack config that shows the integration and runs in CI on both.Why is this useful?
Teams whose web app is built by webpack or Rspack can run Harness tests against the build their users get, with the same aliases, loaders and constants, without adding and maintaining a Metro config only for tests. The bundler interface and the runtime seams are also the groundwork Re.Pack support would need.
Closes #194