Skip to content

Commit 060b318

Browse files
committed
refactor: less intrusive module sytem patching
1 parent 88bec52 commit 060b318

6 files changed

Lines changed: 98 additions & 1147 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: prerelease
3+
---
4+
5+
Refactored module system patching for module mocks to be less intrusive, no longer requiring full module system replacement.

packages/metro/src/moduleSystem.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

packages/metro/src/withRnHarness.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { MetroConfig } from 'metro-config';
22
import { getConfig } from '@react-native-harness/config';
3-
import { patchModuleSystem } from './moduleSystem';
43
import { getHarnessResolver } from './resolver';
54
import { getHarnessManifest } from './manifest';
65
import { getHarnessBabelTransformerPath } from './babel-transformer';
@@ -25,8 +24,6 @@ export const withRnHarness = <T extends MetroConfig>(
2524
const metroConfig = await config;
2625
const { config: harnessConfig } = await getConfig(process.cwd());
2726

28-
patchModuleSystem();
29-
3027
const harnessResolver = getHarnessResolver(metroConfig, harnessConfig);
3128
const harnessManifest = getHarnessManifest(harnessConfig);
3229
const harnessBabelTransformerPath =
@@ -40,6 +37,9 @@ export const withRnHarness = <T extends MetroConfig>(
4037
getPolyfills: (...args) => [
4138
...(metroConfig.serializer?.getPolyfills?.(...args) ?? []),
4239
harnessManifest,
40+
require.resolve(
41+
'@react-native-harness/runtime/polyfills/harness-module-system'
42+
),
4343
],
4444
isThirdPartyModule({ path: modulePath }) {
4545
const isThirdPartyByDefault =

0 commit comments

Comments
 (0)