@module-federation/metro 2.7.0 → 2.8.0
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/babel-plugin/patch-initialize-core.js +3 -3
- package/babel-plugin/patch-require.js +3 -3
- package/dist/modules/asyncRequire.ts +2 -2
- package/dist/plugin/helpers.js +4 -6
- package/dist/plugin/helpers.mjs +4 -6
- package/dist/plugin/resolver.js +1 -1
- package/dist/plugin/resolver.mjs +1 -1
- package/dist/plugin/serializer.js +1 -8
- package/dist/plugin/serializer.mjs +1 -8
- package/package.json +6 -6
|
@@ -45,9 +45,9 @@ function metroPatchInitializeCorePlugin() {
|
|
|
45
45
|
Program: {
|
|
46
46
|
enter(_, state) {
|
|
47
47
|
state.hasInjected = false;
|
|
48
|
-
state.shouldTransform = state.file.opts.filename
|
|
49
|
-
'
|
|
50
|
-
|
|
48
|
+
state.shouldTransform = state.file.opts.filename
|
|
49
|
+
.replaceAll('\\', '/')
|
|
50
|
+
.includes('react-native/Libraries/Core/InitializeCore.js');
|
|
51
51
|
},
|
|
52
52
|
exit(path, state) {
|
|
53
53
|
if (!state.shouldTransform) return;
|
|
@@ -140,9 +140,9 @@ function metroPatchRequireBabelPlugin() {
|
|
|
140
140
|
Program: {
|
|
141
141
|
enter(_, state) {
|
|
142
142
|
// Transform only require.js from metro-runtime
|
|
143
|
-
state.shouldTransform = state.file.opts.filename
|
|
144
|
-
'
|
|
145
|
-
|
|
143
|
+
state.shouldTransform = state.file.opts.filename
|
|
144
|
+
.replaceAll('\\', '/')
|
|
145
|
+
.includes('metro-runtime/src/polyfills/require.js');
|
|
146
146
|
// Perform refreshSymbols transformation only once
|
|
147
147
|
// Because it is referenced in multiple places
|
|
148
148
|
state.hasTransformed = {
|
|
@@ -27,8 +27,8 @@ function getBundleId(bundlePath: string, publicPath: string) {
|
|
|
27
27
|
if (path.startsWith('/')) {
|
|
28
28
|
path = path.slice(1);
|
|
29
29
|
}
|
|
30
|
-
// remove the query params
|
|
31
|
-
path = path.split('?')[0];
|
|
30
|
+
// remove the query params and normalize Windows separators
|
|
31
|
+
path = path.split('?')[0].replaceAll('\\', '/');
|
|
32
32
|
// remove the bundle extension
|
|
33
33
|
return path.replace('.bundle', '');
|
|
34
34
|
}
|
package/dist/plugin/helpers.js
CHANGED
|
@@ -67,12 +67,10 @@ function isUsingMFBundleCommand(command = process.argv[2]) {
|
|
|
67
67
|
return allowedCommands.includes(command);
|
|
68
68
|
}
|
|
69
69
|
function replaceExtension(filepath, extension) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ext: extension
|
|
75
|
-
});
|
|
70
|
+
const separatorIndex = Math.max(filepath.lastIndexOf('/'), filepath.lastIndexOf('\\'));
|
|
71
|
+
const dotIndex = filepath.lastIndexOf('.');
|
|
72
|
+
const extensionStart = dotIndex > separatorIndex + 1 ? dotIndex : filepath.length;
|
|
73
|
+
return `${filepath.slice(0, extensionStart)}${extension}`;
|
|
76
74
|
}
|
|
77
75
|
function removeExtension(filepath) {
|
|
78
76
|
return replaceExtension(filepath, '');
|
package/dist/plugin/helpers.mjs
CHANGED
|
@@ -18,12 +18,10 @@ function isUsingMFBundleCommand(command = process.argv[2]) {
|
|
|
18
18
|
return allowedCommands.includes(command);
|
|
19
19
|
}
|
|
20
20
|
function replaceExtension(filepath, extension) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ext: extension
|
|
26
|
-
});
|
|
21
|
+
const separatorIndex = Math.max(filepath.lastIndexOf('/'), filepath.lastIndexOf('\\'));
|
|
22
|
+
const dotIndex = filepath.lastIndexOf('.');
|
|
23
|
+
const extensionStart = dotIndex > separatorIndex + 1 ? dotIndex : filepath.length;
|
|
24
|
+
return `${filepath.slice(0, extensionStart)}${extension}`;
|
|
27
25
|
}
|
|
28
26
|
function removeExtension(filepath) {
|
|
29
27
|
return replaceExtension(filepath, '');
|
package/dist/plugin/resolver.js
CHANGED
|
@@ -177,7 +177,7 @@ function resolveModule(moduleName) {
|
|
|
177
177
|
}
|
|
178
178
|
function replaceModule(from, to) {
|
|
179
179
|
return (resolved)=>{
|
|
180
|
-
if ('sourceFile' === resolved.type && from.test(resolved.filePath)) {
|
|
180
|
+
if ('sourceFile' === resolved.type && from.test((0, external_helpers_js_namespaceObject.toPosixPath)(resolved.filePath))) {
|
|
181
181
|
if (null === to) return {
|
|
182
182
|
type: 'empty'
|
|
183
183
|
};
|
package/dist/plugin/resolver.mjs
CHANGED
|
@@ -139,7 +139,7 @@ function resolveModule(moduleName) {
|
|
|
139
139
|
}
|
|
140
140
|
function replaceModule(from, to) {
|
|
141
141
|
return (resolved)=>{
|
|
142
|
-
if ('sourceFile' === resolved.type && from.test(resolved.filePath)) {
|
|
142
|
+
if ('sourceFile' === resolved.type && from.test(toPosixPath(resolved.filePath))) {
|
|
143
143
|
if (null === to) return {
|
|
144
144
|
type: 'empty'
|
|
145
145
|
};
|
|
@@ -151,14 +151,7 @@ function isProjectSource(entryPoint, projectRoot) {
|
|
|
151
151
|
function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand) {
|
|
152
152
|
const relativeEntryPath = external_node_path_default().relative(projectRoot, entryPoint);
|
|
153
153
|
const normalizedRelativeEntryPath = normalizeEntryPath(relativeEntryPath);
|
|
154
|
-
if (!isUsingMFBundleCommand)
|
|
155
|
-
const { dir, name } = external_node_path_default().parse(relativeEntryPath);
|
|
156
|
-
return external_node_path_default().format({
|
|
157
|
-
dir,
|
|
158
|
-
name,
|
|
159
|
-
ext: ''
|
|
160
|
-
});
|
|
161
|
-
}
|
|
154
|
+
if (!isUsingMFBundleCommand) return removePathExtension(normalizedRelativeEntryPath);
|
|
162
155
|
const exposeEntries = Object.entries(exposes).map(([exposeKey, exposePath])=>({
|
|
163
156
|
exposeKey,
|
|
164
157
|
normalizedExposePath: normalizeEntryPath(exposePath)
|
|
@@ -110,14 +110,7 @@ function isProjectSource(entryPoint, projectRoot) {
|
|
|
110
110
|
function getBundlePath(entryPoint, projectRoot, exposes, isUsingMFBundleCommand) {
|
|
111
111
|
const relativeEntryPath = node_path.relative(projectRoot, entryPoint);
|
|
112
112
|
const normalizedRelativeEntryPath = normalizeEntryPath(relativeEntryPath);
|
|
113
|
-
if (!isUsingMFBundleCommand)
|
|
114
|
-
const { dir, name } = node_path.parse(relativeEntryPath);
|
|
115
|
-
return node_path.format({
|
|
116
|
-
dir,
|
|
117
|
-
name,
|
|
118
|
-
ext: ''
|
|
119
|
-
});
|
|
120
|
-
}
|
|
113
|
+
if (!isUsingMFBundleCommand) return removePathExtension(normalizedRelativeEntryPath);
|
|
121
114
|
const exposeEntries = Object.entries(exposes).map(([exposeKey, exposePath])=>({
|
|
122
115
|
exposeKey,
|
|
123
116
|
normalizedExposePath: normalizeEntryPath(exposePath)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/metro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Module Federation for Metro bundler",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"module-federation",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@expo/metro-runtime": "^5.0.4",
|
|
60
|
-
"@module-federation/dts-plugin": "2.
|
|
61
|
-
"@module-federation/runtime": "2.
|
|
62
|
-
"@module-federation/sdk": "2.
|
|
60
|
+
"@module-federation/dts-plugin": "2.8.0",
|
|
61
|
+
"@module-federation/runtime": "2.8.0",
|
|
62
|
+
"@module-federation/sdk": "2.8.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@babel/types": "^7.25.0",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@rslib/core": "^0.23.2",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
85
|
-
"@typescript-eslint/parser": "8.
|
|
84
|
+
"@typescript-eslint/eslint-plugin": "8.56.1",
|
|
85
|
+
"@typescript-eslint/parser": "8.56.1",
|
|
86
86
|
"@types/node": "^20.19.5",
|
|
87
87
|
"@types/react": "^19.1.0",
|
|
88
88
|
"memfs": "4.46.0",
|