Skip to content

Commit

Permalink
fix: context for loader without resource (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 2, 2021
1 parent e5d5fd8 commit eb08a58
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit eb08a58

Please sign in to comment.