Skip to content

Commit

Permalink
fix: pass proper context param to runtime generator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kisenka committed May 11, 2020
1 parent a2b377b commit c084ec7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/loader.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit c084ec7

Please sign in to comment.