11import type MagicString from 'magic-string' ;
22import type { InternalModuleFormat } from '../../rollup/types' ;
3- import type { PluginDriver } from '../../utils/PluginDriver' ;
43import { escapeId } from '../../utils/escapeId' ;
54import type { GenerateCodeSnippets } from '../../utils/generateCodeSnippets' ;
65import { DOCUMENT_CURRENT_SCRIPT } from '../../utils/interopHelpers' ;
76import { dirname , normalize , relative } from '../../utils/path' ;
7+ import type { PluginDriver } from '../../utils/PluginDriver' ;
88import type { RenderOptions } from '../../utils/renderHelpers' ;
99import type { NodeInteraction } from '../NodeInteractions' ;
1010import { INTERACTION_ACCESSED } from '../NodeInteractions' ;
@@ -158,7 +158,7 @@ const getRelativeUrlFromDocument = (relativePath: string, umd = false) =>
158158 getResolveUrl (
159159 `'${ escapeId ( relativePath ) } ', ${
160160 umd ? `typeof document === 'undefined' ? location.href : ` : ''
161- } document.currentScript && document.currentScript.src || document.baseURI`
161+ } document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript. src || document.baseURI`
162162 ) ;
163163
164164const getGenericImportMetaMechanism =
@@ -180,7 +180,7 @@ const getFileUrlFromRelativePath = (path: string) =>
180180const getUrlFromDocument = ( chunkId : string , umd = false ) =>
181181 `${
182182 umd ? `typeof document === 'undefined' ? location.href : ` : ''
183- } (${ DOCUMENT_CURRENT_SCRIPT } && ${ DOCUMENT_CURRENT_SCRIPT } .src || new URL('${ escapeId (
183+ } (${ DOCUMENT_CURRENT_SCRIPT } && ${ DOCUMENT_CURRENT_SCRIPT } .tagName.toUpperCase() === 'SCRIPT' && ${ DOCUMENT_CURRENT_SCRIPT } . src || new URL('${ escapeId (
184184 chunkId
185185 ) } ', document.baseURI).href)`;
186186
0 commit comments