@@ -3,7 +3,6 @@ import parse5 from 'parse5';
33import {
44 traverse ,
55 getFilter ,
6- normalizeUrl ,
76 requestify ,
87 webpackIgnoreCommentRegexp ,
98} from '../utils' ;
@@ -77,9 +76,17 @@ export default (options) =>
7776 sourceCodeLocation . attrs [ name ] . endOffset - ( isValueQuoted ? 1 : 0 ) ;
7877 const optionsForTypeFn = {
7978 tag : tagName ,
80- isSelfClosing : node . selfClosing ,
81- tagStartOffset : sourceCodeLocation . startOffset ,
82- tagEndOffset : sourceCodeLocation . endOffset ,
79+ startTag : {
80+ startOffset : sourceCodeLocation . startTag . startOffset ,
81+ endOffset : sourceCodeLocation . startTag . endOffset ,
82+ } ,
83+ endTag : sourceCodeLocation . endTag
84+ ? {
85+ startOffset : sourceCodeLocation . endTag . startOffset ,
86+ endOffset : sourceCodeLocation . endTag . endOffset ,
87+ }
88+ : // eslint-disable-next-line no-undefined
89+ undefined ,
8390 attributes,
8491 attribute : name ,
8592 attributePrefix : attribute . prefix ,
@@ -121,46 +128,43 @@ export default (options) =>
121128 let offset = 0 ;
122129
123130 for ( const source of sources ) {
124- const { name, value, isValueQuoted, startOffset, endOffset } = source ;
125-
126- let normalizedUrl = value ;
127- let prefix = '' ;
128-
129- const queryParts = normalizedUrl . split ( '!' ) ;
130-
131- if ( queryParts . length > 1 ) {
132- normalizedUrl = queryParts . pop ( ) ;
133- prefix = queryParts . join ( '!' ) ;
134- }
135-
136- normalizedUrl = normalizeUrl ( normalizedUrl ) ;
131+ const {
132+ name,
133+ value,
134+ isValueQuoted,
135+ format,
136+ runtime,
137+ startOffset,
138+ endOffset,
139+ } = source ;
140+
141+ let request = value ;
137142
138143 if ( ! urlFilter ( name , value , options . resourcePath ) ) {
139144 // eslint-disable-next-line no-continue
140145 continue ;
141146 }
142147
143148 let hash ;
144- const indexHash = normalizedUrl . lastIndexOf ( '#' ) ;
149+ const indexHash = request . lastIndexOf ( '#' ) ;
145150
146151 if ( indexHash >= 0 ) {
147- hash = normalizedUrl . substring ( indexHash ) ;
148- normalizedUrl = normalizedUrl . substring ( 0 , indexHash ) ;
152+ hash = request . substring ( indexHash ) ;
153+ request = request . substring ( 0 , indexHash ) ;
149154 }
150155
151- const request = requestify ( normalizedUrl ) ;
152- const newUrl = prefix ? `${ prefix } !${ request } ` : request ;
153- const importKey = newUrl ;
154- let importName = imports . get ( importKey ) ;
156+ request = requestify ( options . context , request ) ;
157+
158+ let importName = imports . get ( request ) ;
155159
156160 if ( ! importName ) {
157161 importName = `___HTML_LOADER_IMPORT_${ imports . size } ___` ;
158- imports . set ( importKey , importName ) ;
162+ imports . set ( request , importName ) ;
159163
160- options . imports . push ( { importName, source : newUrl } ) ;
164+ options . imports . push ( { format , importName, request } ) ;
161165 }
162166
163- const replacementKey = JSON . stringify ( { newUrl , isValueQuoted, hash } ) ;
167+ const replacementKey = JSON . stringify ( { request , isValueQuoted, hash } ) ;
164168 let replacementName = replacements . get ( replacementKey ) ;
165169
166170 if ( ! replacementName ) {
@@ -172,6 +176,7 @@ export default (options) =>
172176 importName,
173177 hash,
174178 isValueQuoted,
179+ runtime,
175180 } ) ;
176181 }
177182
0 commit comments