From c084ec71e1a048c70f53ad9ee611bfa8444490ec Mon Sep 17 00:00:00 2001 From: kisenka Date: Mon, 11 May 2020 23:02:37 +0300 Subject: [PATCH] fix: pass proper context param to runtime generator BREAKING CHANGE: Possible breaks third-party runtime generators. Earlier `context` param was containing _path to compilation root context_, e.g. folder where webpack compilation occurs. This is wrong behaviour, because meaning of this param is a _folder where svg image is located_. So it was changed in this commit. If your custom runtime generator breaks after this update use `loaderContext.rootContext` option instead of `context`. Closes: #186 --- lib/loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/loader.js b/lib/loader.js index 7b98ef2..3117b68 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -16,7 +16,7 @@ module.exports = function loader(content) { const done = this.async(); const loaderContext = this; - const { resourcePath, rootContext, loaderIndex } = loaderContext; + const { resourcePath, loaderIndex } = loaderContext; // webpack 1 compat const resourceQuery = loaderContext.resourceQuery || ''; const compiler = loaderContext._compiler; @@ -74,7 +74,7 @@ module.exports = function loader(content) { } svgCompiler.addSymbol({ id, content, path: resourcePath + resourceQuery }) .then((symbol) => { - const runtime = runtimeGenerator({ symbol, config, context: rootContext, loaderContext }); + const runtime = runtimeGenerator({ symbol, config, context: loaderContext.context, loaderContext }); done(null, runtime); }).catch(done); };