Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a1dae1f
fix(metro-core): escape babel transformer path
cursoragent Feb 15, 2026
8735d3d
chore(metro-core): format babel transformer test
cursoragent Feb 15, 2026
b0199b3
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 15, 2026
2f2db1e
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 16, 2026
a581c6d
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 16, 2026
95fd501
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 19, 2026
2b12b3b
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 19, 2026
fe538e7
fix(metro-core): align test target and memfs usage
ScriptedAlchemy Feb 24, 2026
0ae9ec4
Merge remote-tracking branch 'origin/main' into cursor/metro-windows-…
ScriptedAlchemy Feb 24, 2026
ac39b69
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 25, 2026
750cc90
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 25, 2026
b8f4ac3
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 26, 2026
739bbe5
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 26, 2026
7533d8b
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 27, 2026
50b4759
fix(metro-core): add missing dts in plugin test config
ScriptedAlchemy Feb 27, 2026
6cb430c
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 27, 2026
5c88fdc
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 28, 2026
e2152c0
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Feb 28, 2026
88af643
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Mar 2, 2026
3814913
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Mar 3, 2026
0526242
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Mar 5, 2026
25e2e7d
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Mar 9, 2026
6b3bd5b
Merge branch 'main' into cursor/metro-windows-path-resolution-47f0
ScriptedAlchemy Mar 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/metro-core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
"options": {
"lintFilePatterns": ["packages/metro-core/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/packages/metro-core"],
"options": {
"jestConfig": "packages/metro-core/jest.config.ts",
"passWithNoTests": true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs aligning with main, uses vitest now

}
}
}
2 changes: 1 addition & 1 deletion packages/metro-core/src/babel/transformer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
const babelTransformer = require('__BABEL_TRANSFORMER_PATH__');
const babelTransformer = require(__BABEL_TRANSFORMER_PATH__);
const babelPlugins = __BABEL_PLUGINS__;
/* eslint-enable no-undef */

Expand Down
39 changes: 39 additions & 0 deletions packages/metro-core/src/plugin/__tests__/babel-transformer.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { createBabelTransformer } from '../babel-transformer';
import type { ModuleFederationConfigNormalized } from '../../types';

function createConfig(): ModuleFederationConfigNormalized {
return {
name: 'test-app',
filename: 'remote.js',
remotes: {},
exposes: {},
shared: {},
shareStrategy: 'loaded-first',
plugins: [],
};
}

describe('createBabelTransformer', () => {
it('escapes Windows paths for require()', () => {
const tmpDirPath = fs.mkdtempSync(path.join(os.tmpdir(), 'mf-metro-'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memfs perhaps?

const windowsPath =
'C:\\Users\\someone\\project\\node_modules\\metro-babel-transformer\\src\\index.js';

const outputPath = createBabelTransformer({
blacklistedPaths: [],
federationConfig: createConfig(),
originalBabelTransformerPath: windowsPath,
tmpDirPath,
enableInitializeCorePatching: false,
enableRuntimeRequirePatching: false,
});

const output = fs.readFileSync(outputPath, 'utf-8');
expect(output).toContain(`require(${JSON.stringify(windowsPath)})`);

fs.rmSync(tmpDirPath, { recursive: true, force: true });
});
});
5 changes: 4 additions & 1 deletion packages/metro-core/src/plugin/babel-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ export function createBabelTransformer({
].filter(Boolean);

const babelTransformer = transformerTemplate
.replaceAll('__BABEL_TRANSFORMER_PATH__', originalBabelTransformerPath)
.replaceAll(
'__BABEL_TRANSFORMER_PATH__',
JSON.stringify(originalBabelTransformerPath),
)
.replaceAll('__BABEL_PLUGINS__', JSON.stringify(plugins));

fs.writeFileSync(outputPath, babelTransformer, 'utf-8');
Expand Down
Loading