Skip to content

Commit

Permalink
fix: remove moment from force interop packages (#11502)
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework authored Jan 4, 2023
1 parent a802828 commit b89ddd6
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -997,22 +997,14 @@ export async function extractExportsData(
return exportsData
}

// https://github.com/vitejs/vite/issues/1724#issuecomment-767619642
// a list of modules that pretends to be ESM but still uses `require`.
// this causes esbuild to wrap them as CJS even when its entry appears to be ESM.
const KNOWN_INTEROP_IDS = new Set(['moment'])

function needsInterop(
config: ResolvedConfig,
ssr: boolean,
id: string,
exportsData: ExportsData,
output?: { exports: string[] },
): boolean {
if (
getDepOptimizationConfig(config, ssr)?.needsInterop?.includes(id) ||
KNOWN_INTEROP_IDS.has(id)
) {
if (getDepOptimizationConfig(config, ssr)?.needsInterop?.includes(id)) {
return true
}
const { hasImports, exports } = exportsData
Expand Down

0 comments on commit b89ddd6

Please sign in to comment.