From 27aba9cb7fc373443a3a70a28398250d2a680fc1 Mon Sep 17 00:00:00 2001 From: Christian Alfoni Date: Sun, 19 Mar 2017 21:56:14 +0100 Subject: [PATCH] Fixed zip download with presets --- src/createLoaders.js | 16 ++++++++-------- src/sessionBundler.js | 2 +- src/zip.js | 3 ++- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/createLoaders.js b/src/createLoaders.js index 4ab0a4a..703e591 100644 --- a/src/createLoaders.js +++ b/src/createLoaders.js @@ -1,5 +1,5 @@ -module.exports = function (currentLoaders) { +module.exports = function (currentLoaders, resolve) { var loaders = []; @@ -19,29 +19,29 @@ module.exports = function (currentLoaders) { } }; if (currentLoaders.babel.es2015) { - loader.query.presets.push(require.resolve('babel-preset-es2015')); + loader.query.presets.push(resolve('babel-preset-es2015')); } if (currentLoaders.babel.react) { - loader.query.presets.push(require.resolve('babel-preset-react')); + loader.query.presets.push(resolve('babel-preset-react')); } if (currentLoaders.babel.stage0) { - loader.query.presets.push(require.resolve('babel-preset-stage-0')); + loader.query.presets.push(resolve('babel-preset-stage-0')); } if (currentLoaders.babel.jsx) { loader.query.plugins.push([ - require.resolve('babel-plugin-transform-react-jsx'), { + resolve('babel-plugin-transform-react-jsx'), { pragma: currentLoaders.babel.jsx.pragma } ]); } if (currentLoaders.babel.decorators) { - loader.query.plugins.push(require.resolve('babel-plugin-transform-decorators-legacy')) + loader.query.plugins.push(resolve('babel-plugin-transform-decorators-legacy')) } if (currentLoaders.babel.classProperties) { - loader.query.plugins.push(require.resolve('babel-plugin-transform-class-properties')) + loader.query.plugins.push(resolve('babel-plugin-transform-class-properties')) } if (currentLoaders.babel.inferno) { - loader.query.plugins.push(require.resolve('babel-plugin-inferno')) + loader.query.plugins.push(resolve('babel-plugin-inferno')) } loaders.push(loader); diff --git a/src/sessionBundler.js b/src/sessionBundler.js index ac0db20..49647b3 100644 --- a/src/sessionBundler.js +++ b/src/sessionBundler.js @@ -36,7 +36,7 @@ module.exports = { modules: [path.resolve('node_modules'), path.join('/', 'node_modules')] }, module: { - loaders: createLoaders(session.loaders) + loaders: createLoaders(session.loaders, require.resolve.bind(require)) }, plugins: manifest ? [ new webpack.DllReferencePlugin({ diff --git a/src/zip.js b/src/zip.js index a7eae01..ff10be7 100644 --- a/src/zip.js +++ b/src/zip.js @@ -33,7 +33,8 @@ module.exports = function (req, res) { "license": "ISC" }; - var loaders = createLoaders(req.session.loaders || {}).map(function (loader) { + var resolve = function (value) { return value; }; + var loaders = createLoaders(req.session.loaders || {}, resolve).map(function (loader) { loader.test = '$$' + loader.test.toString() + '$$'; if (loader.exclude) { loader.exclude = '$$' + loader.exclude.toString() + '$$';