diff --git a/src/index.js b/src/index.js index 81eb253b..8d9c2f4d 100644 --- a/src/index.js +++ b/src/index.js @@ -55,10 +55,11 @@ options.insert = ${insert}; var content = require(${loaderUtils.stringifyRequest(this, `!!${request}`)}); content = content.__esModule ? content.default : content; -var update = require(${loaderUtils.stringifyRequest( +var api = require(${loaderUtils.stringifyRequest( this, `!${path.join(__dirname, 'runtime/injectStylesIntoLinkTag.js')}` - )})(content, options); + )}); +var update = api(content, options); ${hmrCode}`; } @@ -113,10 +114,11 @@ if (content.locals) { exports.use = function() { if (!(refs++)) { - dispose = require(${loaderUtils.stringifyRequest( + var api = require(${loaderUtils.stringifyRequest( this, `!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` - )})(content, options); + )}); + dispose = api(content, options); } return exports; @@ -180,10 +182,11 @@ var options = ${JSON.stringify(options)} options.insert = ${insert}; options.singleton = ${isSingleton}; -var update = require(${loaderUtils.stringifyRequest( +var api = require(${loaderUtils.stringifyRequest( this, `!${path.join(__dirname, 'runtime/injectStylesIntoStyleTag.js')}` - )})(content, options); + )}); +var update = api(content, options); if (content.locals) { module.exports = content.locals; diff --git a/test/manual/webpack.config.js b/test/manual/webpack.config.js index cdd5271b..f66938a9 100644 --- a/test/manual/webpack.config.js +++ b/test/manual/webpack.config.js @@ -28,7 +28,7 @@ module.exports = { ], use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), }, { loader: 'css-loader', @@ -44,7 +44,7 @@ module.exports = { exclude: [/\.lazy\.css$/i, /\.link\.css$/i, /\.lazy\.module\.css$/i], use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), }, { loader: 'css-loader', @@ -60,7 +60,7 @@ module.exports = { test: /\.lazy\.css$/i, use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), options: { injectType: 'lazyStyleTag' }, }, { @@ -76,7 +76,7 @@ module.exports = { test: /\.lazy\.module\.css$/i, use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), options: { injectType: 'lazyStyleTag' }, }, { @@ -94,7 +94,7 @@ module.exports = { test: /\.link\.css$/i, use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), options: { injectType: 'linkTag' }, }, { @@ -107,7 +107,7 @@ module.exports = { exclude: /\.lazy\.scss$/i, use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), }, { loader: 'css-loader', @@ -130,7 +130,7 @@ module.exports = { test: /\.lazy\.scss$/i, use: [ { - loader: require.resolve('../../dist/index.js'), + loader: require.resolve('../../dist/cjs.js'), options: { injectType: 'lazyStyleTag' }, }, {