Skip to content

Commit

Permalink
fix: optimizeDeps.entries transformRequest url (fix #8719)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jun 23, 2022
1 parent ce484d7 commit 68747cf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/vite/src/node/optimizer/optimizer.ts
@@ -1,6 +1,8 @@
import path from 'node:path'
import colors from 'picocolors'
import _debug from 'debug'
import glob from 'fast-glob'
import { FS_PREFIX } from '../constants'
import { getHash } from '../utils'
import { transformRequest } from '../server/transformRequest'
import type { ResolvedConfig, ViteDevServer } from '..'
Expand Down Expand Up @@ -585,17 +587,21 @@ export async function preTransformOptimizeDepsEntries(
server: ViteDevServer
): Promise<void> {
const { config } = server
const { root } = config
const { entries } = config.optimizeDeps
if (entries) {
const explicitEntries = await glob(entries, {
cwd: config.root,
cwd: root,
ignore: ['**/node_modules/**', `**/${config.build.outDir}/**`],
absolute: true
})
// TODO: should we restrict the entries to JS and HTML like the
// scanner did? I think we can let the user chose any entry
for (const entry of explicitEntries) {
transformRequest(entry, server, { ssr: false }).catch((e) => {
const url = entry.startsWith(root + '/')
? entry.slice(root.length)
: path.posix.join(FS_PREFIX + entry)
transformRequest(url, server, { ssr: false }).catch((e) => {
config.logger.error(e.message)
})
}
Expand Down

0 comments on commit 68747cf

Please sign in to comment.