mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
fix(vite): only remove version query (#2587)
This commit is contained in:
parent
8fff48b8df
commit
1155d1b4d4
@ -3,7 +3,6 @@ import { existsSync } from 'fs'
|
|||||||
import { resolve } from 'pathe'
|
import { resolve } from 'pathe'
|
||||||
import * as vite from 'vite'
|
import * as vite from 'vite'
|
||||||
import { ExternalsOptions, isExternal as _isExternal, ExternalsDefaults } from 'externality'
|
import { ExternalsOptions, isExternal as _isExternal, ExternalsDefaults } from 'externality'
|
||||||
import { parseURL } from 'ufo'
|
|
||||||
import { hashId, uniq } from './utils'
|
import { hashId, uniq } from './utils'
|
||||||
|
|
||||||
export interface TransformChunk {
|
export interface TransformChunk {
|
||||||
@ -70,11 +69,12 @@ async function transformRequest (opts: TransformOptions, id: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { pathname } = parseURL(id)
|
// Vite will add ?v=123 to bypass browser cache
|
||||||
|
// Remove for externals
|
||||||
if (await isExternal(opts, pathname)) {
|
const withoutVersionQuery = id.replace(/\?v=\w+$/, '')
|
||||||
|
if (await isExternal(opts, withoutVersionQuery)) {
|
||||||
return {
|
return {
|
||||||
code: `(global, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => import('${(pathToFileURL(pathname))}').then(r => { exports.default = r.default; ssrExportAll(r) }).catch(e => { console.error(e); throw new Error('[vite dev] Error loading external "${id}".') })`,
|
code: `(global, exports, importMeta, ssrImport, ssrDynamicImport, ssrExportAll) => import('${(pathToFileURL(withoutVersionQuery))}').then(r => { exports.default = r.default; ssrExportAll(r) }).catch(e => { console.error(e); throw new Error('[vite dev] Error loading external "${id}".') })`,
|
||||||
deps: [],
|
deps: [],
|
||||||
dynamicDeps: []
|
dynamicDeps: []
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user