@@ -3,7 +3,6 @@ import parse5 from 'parse5';
3
3
import {
4
4
traverse ,
5
5
getFilter ,
6
- normalizeUrl ,
7
6
requestify ,
8
7
webpackIgnoreCommentRegexp ,
9
8
} from '../utils' ;
@@ -77,9 +76,17 @@ export default (options) =>
77
76
sourceCodeLocation . attrs [ name ] . endOffset - ( isValueQuoted ? 1 : 0 ) ;
78
77
const optionsForTypeFn = {
79
78
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 ,
83
90
attributes,
84
91
attribute : name ,
85
92
attributePrefix : attribute . prefix ,
@@ -121,46 +128,43 @@ export default (options) =>
121
128
let offset = 0 ;
122
129
123
130
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 ;
137
142
138
143
if ( ! urlFilter ( name , value , options . resourcePath ) ) {
139
144
// eslint-disable-next-line no-continue
140
145
continue ;
141
146
}
142
147
143
148
let hash ;
144
- const indexHash = normalizedUrl . lastIndexOf ( '#' ) ;
149
+ const indexHash = request . lastIndexOf ( '#' ) ;
145
150
146
151
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 ) ;
149
154
}
150
155
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 ) ;
155
159
156
160
if ( ! importName ) {
157
161
importName = `___HTML_LOADER_IMPORT_${ imports . size } ___` ;
158
- imports . set ( importKey , importName ) ;
162
+ imports . set ( request , importName ) ;
159
163
160
- options . imports . push ( { importName, source : newUrl } ) ;
164
+ options . imports . push ( { format , importName, request } ) ;
161
165
}
162
166
163
- const replacementKey = JSON . stringify ( { newUrl , isValueQuoted, hash } ) ;
167
+ const replacementKey = JSON . stringify ( { request , isValueQuoted, hash } ) ;
164
168
let replacementName = replacements . get ( replacementKey ) ;
165
169
166
170
if ( ! replacementName ) {
@@ -172,6 +176,7 @@ export default (options) =>
172
176
importName,
173
177
hash,
174
178
isValueQuoted,
179
+ runtime,
175
180
} ) ;
176
181
}
177
182
0 commit comments