Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn pnp support #345

Merged
merged 2 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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