Skip to content

Commit c3faac4

Browse files
refactor: reduce runtime code
1 parent bd5ad04 commit c3faac4

8 files changed

+56
-61
lines changed

src/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ export default async function loader(content) {
8080
html = await options.postprocessor(html, this);
8181
}
8282

83-
const importCode = getImportCode(html, this, imports, options);
84-
const moduleCode = getModuleCode(html, replacements, {
83+
const importCode = getImportCode(html, imports, options);
84+
const moduleCode = getModuleCode(html, replacements, this, {
85+
esModule: options.esModule,
8586
isTemplateLiteralSupported,
8687
});
8788
const exportCode = getExportCode(html, options);

src/utils.js

+28-17
Original file line numberDiff line numberDiff line change
@@ -1218,25 +1218,12 @@ export function getFilter(filter) {
12181218
};
12191219
}
12201220

1221-
const GET_SOURCE_FROM_IMPORT_NAME = "___HTML_LOADER_GET_SOURCE_FROM_IMPORT___";
1222-
1223-
export function getImportCode(html, loaderContext, imports, options) {
1221+
export function getImportCode(html, imports, options) {
12241222
if (imports.length === 0) {
12251223
return "";
12261224
}
12271225

1228-
// TODO simplify in the next major release
1229-
const getURLRuntime = require.resolve("./runtime/getUrl.js");
1230-
const context = loaderContext.context || loaderContext.rootContext;
1231-
const fileURLToHelper =
1232-
typeof loaderContext.utils !== "undefined" &&
1233-
typeof loaderContext.utils.contextify === "function"
1234-
? loaderContext.utils.contextify(context, getURLRuntime)
1235-
: contextify(context, getURLRuntime);
1236-
1237-
let code = options.esModule
1238-
? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n`
1239-
: `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n`;
1226+
let code = "";
12401227

12411228
for (const item of imports) {
12421229
const { importName, request } = item;
@@ -1270,12 +1257,16 @@ export function convertToTemplateLiteral(str) {
12701257
return `\`${escapedString}\``;
12711258
}
12721259

1273-
export function getModuleCode(html, replacements, options) {
1260+
const GET_SOURCE_FROM_IMPORT_NAME = "___HTML_LOADER_GET_SOURCE_FROM_IMPORT___";
1261+
1262+
export function getModuleCode(html, replacements, loaderContext, options) {
12741263
let code = html;
12751264
let replacersCode = "";
12761265

12771266
const { isTemplateLiteralSupported } = options;
12781267

1268+
let needHelperImport = false;
1269+
12791270
for (const item of replacements) {
12801271
const { runtime, importName, replacementName, isValueQuoted, hash } = item;
12811272

@@ -1289,6 +1280,10 @@ export function getModuleCode(html, replacements, options) {
12891280
const needHelperFn = getUrlOptions.length > 0;
12901281

12911282
if (needHelperFn) {
1283+
if (!needHelperImport) {
1284+
needHelperImport = true;
1285+
}
1286+
12921287
replacersCode += `var ${replacementName} = ${GET_SOURCE_FROM_IMPORT_NAME}(${importName}${preparedOptions});\n`;
12931288
}
12941289

@@ -1311,7 +1306,23 @@ export function getModuleCode(html, replacements, options) {
13111306
isTemplateLiteralSupported ? `\${"<" + "${s}"}` : `<" + "${s}`,
13121307
);
13131308

1314-
return `// Module\n${replacersCode}var code = ${code};\n`;
1309+
code = `// Module\n${replacersCode}var code = ${code};\n`;
1310+
1311+
if (needHelperImport) {
1312+
// TODO simplify in the next major release
1313+
const getURLRuntime = require.resolve("./runtime/getUrl.js");
1314+
const context = loaderContext.context || loaderContext.rootContext;
1315+
const fileURLToHelper =
1316+
typeof loaderContext.utils !== "undefined" &&
1317+
typeof loaderContext.utils.contextify === "function"
1318+
? loaderContext.utils.contextify(context, getURLRuntime)
1319+
: contextify(context, getURLRuntime);
1320+
code = options.esModule
1321+
? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n${code}`
1322+
: `var ${GET_SOURCE_FROM_IMPORT_NAME} = require("${fileURLToHelper}");\n${code}`;
1323+
}
1324+
1325+
return code;
13151326
}
13161327

13171328
export function getExportCode(html, options) {

test/__snapshots__/esModule-option.test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports[`'esModule' option should use a CommonJS export by default: errors 1`] =
44

55
exports[`'esModule' option should use a CommonJS export by default: module 1`] = `
66
"// Imports
7-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
87
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
98
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
109
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -33,6 +32,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
3332
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
3433
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
3534
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
35+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
3636
// Module
3737
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
3838
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -965,7 +965,6 @@ exports[`'esModule' option should use a CommonJS export when the value is "false
965965

966966
exports[`'esModule' option should use a CommonJS export when the value is "false": module 1`] = `
967967
"// Imports
968-
var ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ = require("../../src/runtime/getUrl.js");
969968
var ___HTML_LOADER_IMPORT_0___ = require("./image.png");
970969
var ___HTML_LOADER_IMPORT_1___ = require("/image.png");
971970
var ___HTML_LOADER_IMPORT_2___ = require("aliasImg");
@@ -992,6 +991,7 @@ var ___HTML_LOADER_IMPORT_22___ = require("./nested/image3.png");
992991
var ___HTML_LOADER_IMPORT_23___ = require("/nested/image3.png");
993992
var ___HTML_LOADER_IMPORT_24___ = require("./noscript.png");
994993
var ___HTML_LOADER_IMPORT_25___ = require("./😀abc.png");
994+
var ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ = require("../../src/runtime/getUrl.js");
995995
// Module
996996
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
997997
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -1930,7 +1930,6 @@ exports[`'esModule' option should use an ES module export when the value is "tru
19301930

19311931
exports[`'esModule' option should use an ES module export when the value is "true": module 1`] = `
19321932
"// Imports
1933-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
19341933
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
19351934
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
19361935
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -1959,6 +1958,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
19591958
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
19601959
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
19611960
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
1961+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
19621962
// Module
19631963
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
19641964
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });

test/__snapshots__/loader.test.js.snap

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports[`loader should emit an error on broken HTML syntax: errors 1`] = `[]`;
44

55
exports[`loader should emit an error on broken HTML syntax: module 1`] = `
66
"// Imports
7-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
87
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
98
// Module
109
var code = \`Text < img src="image.png" >
@@ -80,8 +79,8 @@ exports[`loader should pass queries to other loader: errors 1`] = `[]`;
8079

8180
exports[`loader should pass queries to other loader: module 1`] = `
8281
"// Imports
83-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
8482
var ___HTML_LOADER_IMPORT_0___ = new URL("./icons.svg?color=%23BAAFDB%3F", import.meta.url);
83+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
8584
// Module
8685
var ___HTML_LOADER_REPLACEMENT_0___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { hash: "#foo" });
8786
var code = \`<img src="\${___HTML_LOADER_REPLACEMENT_0___}">\`;
@@ -118,7 +117,6 @@ exports[`loader should work with "resolve.roots": errors 1`] = `[]`;
118117

119118
exports[`loader should work with "resolve.roots": module 1`] = `
120119
"// Imports
121-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
122120
var ___HTML_LOADER_IMPORT_0___ = new URL("/image2.png", import.meta.url);
123121
// Module
124122
var code = \`<!doctype html>
@@ -142,7 +140,6 @@ exports[`loader should work with \`experiments.buildHttp\`: errors 1`] = `[]`;
142140

143141
exports[`loader should work with \`experiments.buildHttp\`: module 1`] = `
144142
"// Imports
145-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
146143
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
147144
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
148145
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -173,6 +170,7 @@ var ___HTML_LOADER_IMPORT_26___ = new URL("/nested/image3.png", import.meta.url)
173170
var ___HTML_LOADER_IMPORT_27___ = new URL("./noscript.png", import.meta.url);
174171
var ___HTML_LOADER_IMPORT_28___ = new URL("https://raw.githubusercontent.com/webpack-contrib/html-loader/master/test/fixtures/image.png", import.meta.url);
175172
var ___HTML_LOADER_IMPORT_29___ = new URL("./😀abc.png", import.meta.url);
173+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
176174
// Module
177175
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
178176
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -1128,7 +1126,6 @@ exports[`loader should work with server-relative url: errors 1`] = `[]`;
11281126

11291127
exports[`loader should work with server-relative url: module 1`] = `
11301128
"// Imports
1131-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
11321129
var ___HTML_LOADER_IMPORT_0___ = new URL("/nested/image3.png", import.meta.url);
11331130
// Module
11341131
var code = \`<!doctype html>
@@ -1152,7 +1149,6 @@ exports[`loader should work with webpackIgnore comment: errors 1`] = `[]`;
11521149

11531150
exports[`loader should work with webpackIgnore comment: module 1`] = `
11541151
"// Imports
1155-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
11561152
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
11571153
// Module
11581154
var code = \`<!doctype html>
@@ -1400,7 +1396,6 @@ exports[`loader should work: errors 1`] = `[]`;
14001396

14011397
exports[`loader should work: module 1`] = `
14021398
"// Imports
1403-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
14041399
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
14051400
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
14061401
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -1429,6 +1424,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
14291424
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
14301425
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
14311426
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
1427+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
14321428
// Module
14331429
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
14341430
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });

test/__snapshots__/minimize-option.test.js.snap

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports[`"minimize" option should be turned off by default: errors 1`] = `[]`;
44

55
exports[`"minimize" option should be turned off by default: module 1`] = `
66
"// Imports
7-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
87
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
98
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
109
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -33,6 +32,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
3332
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
3433
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
3534
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
35+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
3636
// Module
3737
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
3838
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -965,7 +965,6 @@ exports[`"minimize" option should be turned off in "development" mode: errors 1`
965965

966966
exports[`"minimize" option should be turned off in "development" mode: module 1`] = `
967967
"// Imports
968-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
969968
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
970969
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
971970
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -994,6 +993,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
994993
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
995994
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
996995
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
996+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
997997
// Module
998998
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
999999
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -1926,7 +1926,6 @@ exports[`"minimize" option should be turned on in "production" mode: errors 1`]
19261926

19271927
exports[`"minimize" option should be turned on in "production" mode: module 1`] = `
19281928
"// Imports
1929-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
19301929
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
19311930
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
19321931
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -1955,6 +1954,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
19551954
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
19561955
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
19571956
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
1957+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
19581958
// Module
19591959
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
19601960
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -1990,7 +1990,6 @@ Parse Error: < img src="image.png" >",
19901990

19911991
exports[`"minimize" option should emit an error on broken HTML syntax: module 1`] = `
19921992
"// Imports
1993-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
19941993
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
19951994
// Module
19961995
var code = \`Text < img src="image.png" >
@@ -2024,7 +2023,6 @@ exports[`"minimize" option should not work with a value equal to "false": errors
20242023

20252024
exports[`"minimize" option should not work with a value equal to "false": module 1`] = `
20262025
"// Imports
2027-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
20282026
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
20292027
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
20302028
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -2053,6 +2051,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
20532051
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
20542052
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
20552053
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
2054+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
20562055
// Module
20572056
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
20582057
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -2985,7 +2984,6 @@ exports[`"minimize" option should support options for minimizer: errors 1`] = `[
29852984

29862985
exports[`"minimize" option should support options for minimizer: module 1`] = `
29872986
"// Imports
2988-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
29892987
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
29902988
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
29912989
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -3014,6 +3012,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
30143012
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
30153013
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
30163014
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
3015+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
30173016
// Module
30183017
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
30193018
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });
@@ -3061,7 +3060,6 @@ exports[`"minimize" option should work with a value equal to "true": errors 1`]
30613060

30623061
exports[`"minimize" option should work with a value equal to "true": module 1`] = `
30633062
"// Imports
3064-
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
30653063
var ___HTML_LOADER_IMPORT_0___ = new URL("./image.png", import.meta.url);
30663064
var ___HTML_LOADER_IMPORT_1___ = new URL("/image.png", import.meta.url);
30673065
var ___HTML_LOADER_IMPORT_2___ = new URL("aliasImg", import.meta.url);
@@ -3090,6 +3088,7 @@ var ___HTML_LOADER_IMPORT_24___ = new URL("./nested/image3.png", import.meta.url
30903088
var ___HTML_LOADER_IMPORT_25___ = new URL("/nested/image3.png", import.meta.url);
30913089
var ___HTML_LOADER_IMPORT_26___ = new URL("./noscript.png", import.meta.url);
30923090
var ___HTML_LOADER_IMPORT_27___ = new URL("./😀abc.png", import.meta.url);
3091+
import ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___ from "../../src/runtime/getUrl.js";
30933092
// Module
30943093
var ___HTML_LOADER_REPLACEMENT_1___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_0___, { maybeNeedQuotes: true });
30953094
var ___HTML_LOADER_REPLACEMENT_5___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_4___, { hash: "#icon-chevron-with-circle-up" });

0 commit comments

Comments
 (0)