From 97c9a95c32af565fcc35fe73c2ec4e509aad6f0d Mon Sep 17 00:00:00 2001 From: Diogo Franco Date: Mon, 5 Mar 2018 13:36:32 +0900 Subject: [PATCH] fix(loader): Correctly preserve CSS module locals The handling was there, but the property it tried to access was being clobbered by the .map's result. --- src/loader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/loader.js b/src/loader.js index 48f678e6..c954c2c5 100644 --- a/src/loader.js +++ b/src/loader.js @@ -87,9 +87,10 @@ export function pitch(request) { if (!source) { return callback(new Error("Didn't get a result from child compiler")); } - let text; + let text, locals; try { text = exec(this, source, request); + locals = text && text.locals; if (!Array.isArray(text)) { text = [[null, text]]; } else { @@ -108,8 +109,8 @@ export function pitch(request) { return callback(e); } let resultSource = '// extracted by mini-css-extract-plugin'; - if (text.locals && typeof resultSource !== 'undefined') { - resultSource = `module.exports = ${JSON.stringify(text.locals)};`; + if (locals && typeof resultSource !== 'undefined') { + resultSource += `\nmodule.exports = ${JSON.stringify(locals)};`; } return callback(null, resultSource);