Content-Length: 277816 | pFad | http://github.com/vitejs/vite/pull/16084/commits/3b29bd86f385d8dad2918f588639f4a9d226fac2

5A fix: resolve relative URL generated by `renderBuiltUrl` passed to module preload by sapphi-red · Pull Request #16084 · vitejs/vite · GitHub
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: resolve relative URL generated by renderBuiltUrl passed to module preload #16084

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: replace optimizeModulePreloadRelativePaths with `isRelati…
…veBase`
  • Loading branch information
sapphi-red committed Aug 15, 2024
commit 3b29bd86f385d8dad2918f588639f4a9d226fac2
9 changes: 3 additions & 6 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {

const renderBuiltUrl = config.experimental.renderBuiltUrl
const isRelativeBase = config.base === './' || config.base === ''
const optimizeModulePreloadRelativePaths = isRelativeBase && !renderBuiltUrl

const { modulePreload } = config.build
const scriptRel =
Expand All @@ -184,7 +183,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
// using regex over this list to workaround the fact that module preload wasn't
// configurable.
const assetsURL =
renderBuiltUrl || optimizeModulePreloadRelativePaths
renderBuiltUrl || isRelativeBase
? // If `experimental.renderBuiltUrl` is used, the dependencies might be relative to the current chunk.
// If relative base is used, the dependencies are relative to the current chunk.
// The importerUrl is passed as third parameter to __vitePreload in this case
Expand Down Expand Up @@ -343,9 +342,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
str().appendRight(
expEnd,
`,${isModernFlag}?${preloadMarker}:void 0${
optimizeModulePreloadRelativePaths || renderBuiltUrl
? ',import.meta.url'
: ''
renderBuiltUrl || isRelativeBase ? ',import.meta.url' : ''
})`,
)
}
Expand Down Expand Up @@ -623,7 +620,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
renderedDeps = depsArray.map((d) =>
// Don't include the assets dir if the default asset file names
// are used, the path will be reconstructed by the import preload helper
optimizeModulePreloadRelativePaths
isRelativeBase
? addFileDep(toRelativePath(d, file))
: addFileDep(d),
)
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/vitejs/vite/pull/16084/commits/3b29bd86f385d8dad2918f588639f4a9d226fac2

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy