Skip to content
Closed
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix regex pattern
  • Loading branch information
DallasCarraher committed Dec 19, 2025
commit 9b32ef96906a4f2be1796dfcc5a71f627438be62
8 changes: 5 additions & 3 deletions src/plugins/pluginProxySharedModule_preBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ export function proxySharedModule(options: {
config(config: UserConfig, { command }) {
(config.resolve as any).alias.push(
...Object.keys(shared).map((key) => {
// FIX: When key ends with '/', only match subpaths (e.g., 'react/' matches 'react/jsx-runtime' but NOT 'react')
// The previous regex (/.+)? was optional, incorrectly matching the base package too
const pattern = key.endsWith('/') ? `(^${key.replace(/\/$/, '')}/.+$)` : `(^${key}$)`;
// When key ends with '/', only match subpaths (e.g., 'react/' matches 'react/jsx-runtime' but NOT 'react')
// When key does NOT end with '/', match both exact and subpaths (e.g., 'react' matches 'react' AND 'react/jsx-runtime')
const pattern = key.endsWith('/')
? `(^${key.replace(/\/$/, '')}/.+$)`
: `(^${key}(/.+)?$)`;
return {
// Intercept all shared requests and proxy them to loadShare
find: new RegExp(pattern),
Expand Down
Loading