@@ -373,32 +373,8 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
373373 return [ resolved . id , resolved . id ]
374374 }
375375
376- const isRelative = url [ 0 ] === '.'
377- const isSelfImport = ! isRelative && cleanUrl ( url ) === cleanUrl ( importer )
378-
379376 url = normalizeResolvedIdToUrl ( environment , url , resolved )
380377
381- // make the URL browser-valid
382- if ( environment . config . consumer === 'client' ) {
383- // mark non-js/css imports with `?import`
384- if ( isExplicitImportRequired ( url ) ) {
385- url = injectQuery ( url , 'import' )
386- } else if (
387- ( isRelative || isSelfImport ) &&
388- ! DEP_VERSION_RE . test ( url )
389- ) {
390- // If the url isn't a request for a pre-bundled common chunk,
391- // for relative js/css imports, or self-module virtual imports
392- // (e.g. vue blocks), inherit importer's version query
393- // do not do this for unknown type imports, otherwise the appended
394- // query can break 3rd party plugin's extension checks.
395- const versionMatch = DEP_VERSION_RE . exec ( importer )
396- if ( versionMatch ) {
397- url = injectQuery ( url , versionMatch [ 1 ] )
398- }
399- }
400- }
401-
402378 try {
403379 // delay setting `isSelfAccepting` until the file is actually used (#7870)
404380 // We use an internal function to avoid resolving the url again
@@ -423,6 +399,31 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
423399 throw e
424400 }
425401
402+ // make the URL browser-valid
403+ if ( environment . config . consumer === 'client' ) {
404+ const isRelative = url [ 0 ] === '.'
405+ const isSelfImport =
406+ ! isRelative && cleanUrl ( url ) === cleanUrl ( importer )
407+
408+ // mark non-js/css imports with `?import`
409+ if ( isExplicitImportRequired ( url ) ) {
410+ url = injectQuery ( url , 'import' )
411+ } else if (
412+ ( isRelative || isSelfImport ) &&
413+ ! DEP_VERSION_RE . test ( url )
414+ ) {
415+ // If the url isn't a request for a pre-bundled common chunk,
416+ // for relative js/css imports, or self-module virtual imports
417+ // (e.g. vue blocks), inherit importer's version query
418+ // do not do this for unknown type imports, otherwise the appended
419+ // query can break 3rd party plugin's extension checks.
420+ const versionMatch = DEP_VERSION_RE . exec ( importer )
421+ if ( versionMatch ) {
422+ url = injectQuery ( url , versionMatch [ 1 ] )
423+ }
424+ }
425+ }
426+
426427 // prepend base
427428 if ( ! ssr ) url = joinUrlSegments ( base , url )
428429
0 commit comments