Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimizeDeps.entries transformRequest url (fix #8719) #8748

Merged
merged 1 commit into from Jun 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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