@react-native-harness/metro 1.0.0-alpha.13 → 1.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getHarnessSerializer.js +31 -25
- package/dist/withRnHarness.js +35 -31
- package/package.json +3 -3
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.getHarnessSerializer = void 0;
|
|
4
4
|
const getBaseSerializer = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const baseJSBundle = require('metro/private/DeltaBundler/Serializers/baseJSBundle');
|
|
6
|
+
const bundleToString = require('metro/private/lib/bundleToString');
|
|
7
|
+
return (entryPoint, prepend, graph, bundleOptions) =>
|
|
8
|
+
bundleToString(baseJSBundle(entryPoint, prepend, graph, bundleOptions));
|
|
8
9
|
};
|
|
9
10
|
const getAllFiles = require('metro/private/DeltaBundler/Serializers/getAllFiles');
|
|
10
11
|
const getHarnessSerializer = () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
processModuleFilter: (mod) => {
|
|
19
|
-
if (options.processModuleFilter &&
|
|
20
|
-
!options.processModuleFilter(mod)) {
|
|
21
|
-
// If the module is not allowed by the processModuleFilter, skip it
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
// If the module is in the main entry point, skip it
|
|
25
|
-
return !mainEntryPointModules.has(mod.path);
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
mainEntryPointModules = new Set(await getAllFiles(preModules, graph, options));
|
|
12
|
+
const baseSerializer = getBaseSerializer();
|
|
13
|
+
let mainEntryPointModules = new Set();
|
|
14
|
+
return {
|
|
15
|
+
customSerializer: async (entryPoint, preModules, graph, options) => {
|
|
16
|
+
if (options.modulesOnly) {
|
|
17
|
+
console.log('modulesOnly');
|
|
18
|
+
// This is most likely a test file
|
|
30
19
|
return baseSerializer(entryPoint, preModules, graph, options);
|
|
31
|
-
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log('collecting main entry point modules');
|
|
23
|
+
mainEntryPointModules = new Set(
|
|
24
|
+
await getAllFiles(preModules, graph, options)
|
|
25
|
+
);
|
|
26
|
+
return baseSerializer(entryPoint, preModules, graph, options);
|
|
27
|
+
},
|
|
28
|
+
processModuleFilter: (mod) => {
|
|
29
|
+
if (mainEntryPointModules.size === 0) {
|
|
30
|
+
// This is the first time we're collecting main entry point modules.
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// If the module is in the main entry point, skip it
|
|
35
|
+
return !mainEntryPointModules.has(mod.path);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
32
38
|
};
|
|
33
39
|
exports.getHarnessSerializer = getHarnessSerializer;
|
package/dist/withRnHarness.js
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
3
|
exports.withRnHarness = void 0;
|
|
4
|
-
const config_1 = require(
|
|
5
|
-
const moduleSystem_1 = require(
|
|
4
|
+
const config_1 = require('@react-native-harness/config');
|
|
5
|
+
const moduleSystem_1 = require('./moduleSystem');
|
|
6
6
|
const withRnHarness = async (config) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
const isEnabled = !!process.env.RN_HARNESS;
|
|
8
|
+
if (!isEnabled) {
|
|
9
|
+
return config;
|
|
10
|
+
}
|
|
11
|
+
const metroConfig = await config;
|
|
12
|
+
const { config: harnessConfig } = await (0, config_1.getConfig)(
|
|
13
|
+
process.cwd()
|
|
14
|
+
);
|
|
15
|
+
(0, moduleSystem_1.patchModuleSystem)();
|
|
16
|
+
const patchedConfig = {
|
|
17
|
+
...metroConfig,
|
|
18
|
+
cacheVersion: 'react-native-harness',
|
|
19
|
+
serializer: {
|
|
20
|
+
...metroConfig.serializer,
|
|
21
|
+
getPolyfills: (...args) => [
|
|
22
|
+
...(metroConfig.serializer?.getPolyfills?.(...args) ?? []),
|
|
23
|
+
require.resolve('../assets/init.js'),
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
resolver: {
|
|
27
|
+
...metroConfig.resolver,
|
|
28
|
+
// Unlock __tests__ directory
|
|
29
|
+
blockList: undefined,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
if (harnessConfig.unstable__skipAlreadyIncludedModules) {
|
|
33
|
+
patchedConfig.serializer = {
|
|
34
|
+
...patchedConfig.serializer,
|
|
35
|
+
...require('./getHarnessSerializer').getHarnessSerializer(),
|
|
29
36
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
require('./getHarnessSerializer').getHarnessSerializer();
|
|
33
|
-
}
|
|
34
|
-
return patchedConfig;
|
|
37
|
+
}
|
|
38
|
+
return patchedConfig;
|
|
35
39
|
};
|
|
36
40
|
exports.withRnHarness = withRnHarness;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-harness/metro",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.15",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@react-native-harness/runtime": "1.0.0-alpha.
|
|
18
|
+
"@react-native-harness/runtime": "1.0.0-alpha.15"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"tslib": "^2.3.0",
|
|
22
|
-
"@react-native-harness/config": "1.0.0-alpha.
|
|
22
|
+
"@react-native-harness/config": "1.0.0-alpha.15"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/babel__core": "^7.20.5"
|