Skip to content

Commit

Permalink
fix: normalize shared with trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
f4562 committed Dec 23, 2024
1 parent fed459d commit 121dd52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/plugins/pluginProxySharedModule_preBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export function proxySharedModule(options: {
config(config: UserConfig, { command }) {
(config.resolve as any).alias.push(
...Object.keys(shared).map((key) => {
const pattern = key.endsWith('/')
? `(^${key.replace(/\/$/, '')}(\/.+)?$)`
: `(^${key}$)`;
const pattern = key.endsWith('/') ? `(^${key.replace(/\/$/, '')}(\/)?$)` : `(^${key}$)`;
return {
// Intercept all shared requests and proxy them to loadShare
find: new RegExp(pattern),
Expand Down
4 changes: 2 additions & 2 deletions src/utils/normalizeModuleFederationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@ function normalizeShared(
const result: NormalizedShared = {};
if (Array.isArray(shared)) {
shared.forEach((key) => {
result[key] = normalizeShareItem(key, key);
result[cleanShareItem(key)] = normalizeShareItem(key, key);
});
return result;
}
if (typeof shared === 'object') {
Object.keys(shared).forEach((key) => {
result[key] = normalizeShareItem(key, shared[key] as any);
result[cleanShareItem(key)] = normalizeShareItem(key, shared[key] as any);
});
}

Expand Down

0 comments on commit 121dd52

Please sign in to comment.