Skip to content

Commit

Permalink
set * when auto
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Apr 17, 2024
1 parent b1aa790 commit 5ee946e
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1039,20 +1039,23 @@ function addClientImport(
isCjsModule ? 'commonjs' : 'auto'
)

// If it's not analyzed as named ESM exports, e.g. if it's mixing `export *` with named exports,
// We'll include all modules since it's not able to do tree-shaking.
for (const name of importedIdentifiers) {
// For cjs module default import, we include the whole module since
const isCjsDefaultImport = isCjsModule && name === 'default'
const isAutoModuleSourceType = assumedSourceType === 'auto'
// Always include __esModule along with cjs module default export,
// to make sure it work with client module proxy from React.
if (isCjsDefaultImport) {
clientComponentImports[modRequest].add('__esModule')
}
if (isAutoModuleSourceType) {
clientComponentImports[modRequest].add('*')
const isAutoModuleSourceType = assumedSourceType === 'auto'
if (isAutoModuleSourceType) {
clientComponentImports[modRequest] = new Set(['*'])
} else {
// If it's not analyzed as named ESM exports, e.g. if it's mixing `export *` with named exports,
// We'll include all modules since it's not able to do tree-shaking.
for (const name of importedIdentifiers) {
// For cjs module default import, we include the whole module since
const isCjsDefaultImport = isCjsModule && name === 'default'

// Always include __esModule along with cjs module default export,
// to make sure it work with client module proxy from React.
if (isCjsDefaultImport) {
clientComponentImports[modRequest].add('__esModule')
}

clientComponentImports[modRequest].add(name)
}
clientComponentImports[modRequest].add(name)
}
}

0 comments on commit 5ee946e

Please sign in to comment.