Content-Length: 265810 | pFad | http://github.com/vitejs/vite/pull/16084/commits/94b3713011918a45912fd0324516b7537009da71

39 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
Next Next commit
fix: resolve relative URL generated by renderBuiltUrl passed to mod…
…ule preload
  • Loading branch information
sapphi-red committed Aug 11, 2024
commit 94b3713011918a45912fd0324516b7537009da71
14 changes: 5 additions & 9 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,17 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
? `'modulepreload'`
: `(${detectScriptRel.toString()})()`

// There are three different cases for the preload list format in __vitePreload
// There are two different cases for the preload list format in __vitePreload
//
// __vitePreload(() => import(asyncChunk), [ ...deps... ])
//
// This is maintained to keep backwards compatibility as some users developed plugins
// using regex over this list to workaround the fact that module preload wasn't
// configurable.
const assetsURL = renderBuiltUrl
? // If `experimental.renderBuiltUrl` is used, the dependencies are already resolved.
// To avoid the need for `new URL(dep, import.meta.url)`, a helper `__vitePreloadRelativeDep` is
// used to resolve from relative paths which can be minimized.
`function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
: optimizeModulePreloadRelativePaths
? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
// to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
const assetsURL =
renderBuiltUrl || optimizeModulePreloadRelativePaths
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
? // 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
`function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
: // If the base isn't relative, then the deps are relative to the projects `outDir` and the base
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/94b3713011918a45912fd0324516b7537009da71

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy