Skip to content

Commit 7db2466

Browse files
Fix path join for downloading remote types in FederatedTypesPlugin.ts (#4169)
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com> Co-authored-by: ScriptedAlchemy <zackaryjackson@bytedance.com>
1 parent 0d27feb commit 7db2466

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@module-federation/typescript": patch
3+
---
4+
5+
Fix URL construction in FederatedTypesPlugin for Node.js >22.11 compatibility
6+
7+
Fixed incorrect use of `path.join()` for URL construction in FederatedTypesPlugin.ts which was causing "Invalid URL" errors in Node.js versions greater than 22.11. The fix properly uses the URL constructor with the base URL as the second parameter instead of concatenating URLs with path.join().
8+
9+
This resolves compatibility issues when downloading remote types in newer Node.js environments.

packages/typescript/src/plugins/FederatedTypesPlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ export class FederatedTypesPlugin {
327327
await Promise.all(
328328
filesToCacheBust.filter(Boolean).map((file) => {
329329
const url = new URL(
330-
path.join(origin, typescriptFolderName, file),
330+
path.join(typescriptFolderName, file),
331+
origin,
331332
).toString();
332333
const destination = path.join(
333334
this.normalizeOptions.webpackCompilerOptions.context as string,

0 commit comments

Comments
 (0)