Skip to content

Commit

Permalink
Merge pull request #345 from bimbiltu/yarn-pnp
Browse files Browse the repository at this point in the history
Yarn pnp support
  • Loading branch information
kisenka authored Apr 27, 2019
2 parents 5528c3d + dc931e2 commit 316769f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
* @type {string}
* @autoconfigured
*/
spriteModule: 'svg-sprite-loader/runtime/browser-sprite.build',
spriteModule: require.resolve('../runtime/browser-sprite.build'),

/**
* Path to symbol module.
Expand All @@ -65,7 +65,7 @@ module.exports = {
* @type {string}
* @autoconfigured
*/
symbolModule: 'svg-baker-runtime/browser-symbol',
symbolModule: require.resolve('svg-baker-runtime/browser-symbol'),

/**
* Generated export format:
Expand Down
4 changes: 2 additions & 2 deletions lib/configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ const defaults = require('./config');
const utils = require('./utils');

const loaderDefaults = defaults.loader;
const isomorphicSpriteModule = 'svg-sprite-loader/runtime/sprite.build';
const isomorphicSymbolModule = 'svg-baker-runtime/symbol';
const isomorphicSpriteModule = require.resolve('../runtime/sprite.build');
const isomorphicSymbolModule = require.resolve('svg-baker-runtime/symbol');

const isTargetBrowser = target => target === 'web' || target === 'electron-renderer';

Expand Down
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
4 changes: 2 additions & 2 deletions test/configurator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ describe('configurator', () => {
strictEqual(config.symbolModule, loaderDefaults.symbolModule);

config = configure({ context, target: 'node' });
strictEqual(config.spriteModule, 'svg-sprite-loader/runtime/sprite.build');
strictEqual(config.symbolModule, 'svg-baker-runtime/symbol');
strictEqual(config.spriteModule, require.resolve('../runtime/sprite.build'));
strictEqual(config.symbolModule, require.resolve('svg-baker-runtime/symbol'));
});

it('should properly autodetect extract mode', () => {
Expand Down

0 comments on commit 316769f

Please sign in to comment.