Skip to content

Commit

Permalink
chore: extract reused code
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Feb 20, 2022
1 parent 51b28ef commit 420817e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/vite/src/node/importGlob.ts
Expand Up @@ -89,6 +89,7 @@ export async function transformImportGlob(
;[importee] = await normalizeUrl(file, pos)
}
imports.push(importee)
const importeeUrl = isCSSRequest(importee) ? `${importee}?used` : importee
if (assertion?.assert?.type === 'raw') {
entries += ` ${JSON.stringify(file)}: ${JSON.stringify(
await fsp.readFile(path.join(base, file), 'utf-8')
Expand All @@ -98,14 +99,10 @@ export async function transformImportGlob(
// css imports injecting a ?used query to export the css string
importsString += `import ${
isEagerDefault ? `` : `* as `
}${identifier} from ${JSON.stringify(
isCSSRequest(importee) ? `${importee}?used` : importee
)};`
}${identifier} from ${JSON.stringify(importeeUrl)};`
entries += ` ${JSON.stringify(file)}: ${identifier},`
} else {
let imp = `import(${JSON.stringify(
isCSSRequest(importee) ? `${importee}?used` : importee
)})`
let imp = `import(${JSON.stringify(importeeUrl)})`
if (!normalizeUrl && preload) {
imp =
`(${isModernFlag}` +
Expand Down

0 comments on commit 420817e

Please sign in to comment.