@@ -160,21 +160,17 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
160160 ? `'modulepreload'`
161161 : `(${ detectScriptRel . toString ( ) } )()`
162162
163- // There are three different cases for the preload list format in __vitePreload
163+ // There are two different cases for the preload list format in __vitePreload
164164 //
165165 // __vitePreload(() => import(asyncChunk), [ ...deps... ])
166166 //
167167 // This is maintained to keep backwards compatibility as some users developed plugins
168168 // using regex over this list to workaround the fact that module preload wasn't
169169 // configurable.
170- const assetsURL = renderBuiltUrl
171- ? // If `experimental.renderBuiltUrl` is used, the dependencies are already resolved.
172- // To avoid the need for `new URL(dep, import.meta.url)`, a helper `__vitePreloadRelativeDep` is
173- // used to resolve from relative paths which can be minimized.
174- `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
175- : optimizeModulePreloadRelativePaths
176- ? // If there isn't custom resolvers affecting the deps list, deps in the list are relative
177- // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
170+ const assetsURL =
171+ renderBuiltUrl || optimizeModulePreloadRelativePaths
172+ ? // If `experimental.renderBuiltUrl` is used, the dependencies might be relative to the current chunk.
173+ // If relative base is used, the dependencies are relative to the current chunk.
178174 // The importerUrl is passed as third parameter to __vitePreload in this case
179175 `function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
180176 : // If the base isn't relative, then the deps are relative to the projects `outDir` and the base
0 commit comments