Skip to content

Commit

Permalink
fix(runtime-generator): fix module not found errors for custom sprite…
Browse files Browse the repository at this point in the history
…Module or symbolModule

This change fixes module not found errors that could occur when specifying a custom spriteModule or
symbolModule. Previously the import statements this loader generated would only work for svg imports
made from certain directories.
  • Loading branch information
Mark Davis committed Apr 25, 2019
1 parent 48b1921 commit 44bbcfe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/runtime-generator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { isAbsolute, join } = require('path');
const { stringifyRequest } = require('loader-utils');
const {
stringify,
Expand All @@ -16,7 +17,7 @@ const {
* @return {string}
*/
function runtimeGenerator(params) {
const { symbol, config, context } = params;
const { symbol, config, context, loaderContext } = params;
const { extract, esModule, spriteModule, symbolModule, runtimeCompat, publicPath } = config;
let runtime;

Expand All @@ -33,8 +34,11 @@ function runtimeGenerator(params) {
}`;
runtime = generateExport(data, esModule);
} else {
const spriteModuleImport = stringifyRequest({ context }, spriteModule);
const symbolModuleImport = stringifyRequest({ context }, symbolModule);
const spriteModuleAbsPath = isAbsolute(spriteModule) ? spriteModule : join(context, spriteModule);
const symbolModuleAbsPath = isAbsolute(symbolModule) ? symbolModule : join(context, symbolModule);

const spriteModuleImport = stringifyRequest(loaderContext, spriteModuleAbsPath);
const symbolModuleImport = stringifyRequest(loaderContext, symbolModuleAbsPath);

runtime = [
generateImport('SpriteSymbol', symbolModuleImport, esModule),
Expand Down

0 comments on commit 44bbcfe

Please sign in to comment.