From 78f4cec6ea34a9e6424331a31d4a89e396999952 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 2 Nov 2021 17:44:24 +0300 Subject: [PATCH] fix: context for loader without resource --- src/utils.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index 4b7977d1..4febb66e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1169,13 +1169,14 @@ export function getImportCode(html, loaderContext, imports, options) { return ""; } - // TODO simplif in the next major release + // TODO simpify in the next major release const getURLRuntime = require.resolve("./runtime/getUrl.js"); + const context = loaderContext.context || loaderContext.rootContext; const fileURLToHelper = typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function" - ? loaderContext.utils.contextify(loaderContext.context, getURLRuntime) - : contextify(loaderContext.context, getURLRuntime); + ? loaderContext.utils.contextify(context, getURLRuntime) + : contextify(context, getURLRuntime); let code = options.esModule ? `import ${GET_SOURCE_FROM_IMPORT_NAME} from "${fileURLToHelper}";\n`