From 79b44f148cbd2c1ba74d11bc0ab5d96d35e57afe Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 28 Apr 2021 16:25:29 +0300 Subject: [PATCH] fix: compatibility with named export and es5 --- src/loader.js | 2 +- .../expected/webpack-4/main.js | 6 +++--- .../expected/webpack-5-importModule/main.js | 6 +++--- .../expected/webpack-5/main.js | 6 +++--- test/cases/es-named-export-output-module/expected/main.js | 6 +++--- test/cases/es-named-export/expected/webpack-4/main.js | 6 +++--- .../es-named-export/expected/webpack-5-importModule/main.js | 6 +++--- test/cases/es-named-export/expected/webpack-5/main.js | 6 +++--- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/loader.js b/src/loader.js index 238700de..458217c0 100644 --- a/src/loader.js +++ b/src/loader.js @@ -155,7 +155,7 @@ export function pitch(request) { ? namedExport ? Object.keys(locals) .map( - (key) => `\nexport const ${key} = ${JSON.stringify(locals[key])};` + (key) => `\nexport var ${key} = ${JSON.stringify(locals[key])};` ) .join('') : `\n${ diff --git a/test/cases/es-module-concatenation-modules/expected/webpack-4/main.js b/test/cases/es-module-concatenation-modules/expected/webpack-4/main.js index 3296fa52..0552cd62 100644 --- a/test/cases/es-module-concatenation-modules/expected/webpack-4/main.js +++ b/test/cases/es-module-concatenation-modules/expected/webpack-4/main.js @@ -116,13 +116,13 @@ __webpack_require__.d(index_namespaceObject, "b", function() { return b_namespac // CONCATENATED MODULE: ./a.css // extracted by mini-css-extract-plugin -const a = "foo__a"; +var a = "foo__a"; // CONCATENATED MODULE: ./b.css // extracted by mini-css-extract-plugin -const b = "foo__b"; +var b = "foo__b"; // CONCATENATED MODULE: ./c.css // extracted by mini-css-extract-plugin -const c = "foo__c"; +var c = "foo__c"; // CONCATENATED MODULE: ./index.js /* eslint-disable import/no-namespace */ diff --git a/test/cases/es-module-concatenation-modules/expected/webpack-5-importModule/main.js b/test/cases/es-module-concatenation-modules/expected/webpack-5-importModule/main.js index 4f1059be..d289c825 100644 --- a/test/cases/es-module-concatenation-modules/expected/webpack-5-importModule/main.js +++ b/test/cases/es-module-concatenation-modules/expected/webpack-5-importModule/main.js @@ -69,13 +69,13 @@ __webpack_require__.d(index_namespaceObject, { ;// CONCATENATED MODULE: ./a.css // extracted by mini-css-extract-plugin -const a = "foo__a"; +var a = "foo__a"; ;// CONCATENATED MODULE: ./b.css // extracted by mini-css-extract-plugin -const b = "foo__b"; +var b = "foo__b"; ;// CONCATENATED MODULE: ./c.css // extracted by mini-css-extract-plugin -const c = "foo__c"; +var c = "foo__c"; ;// CONCATENATED MODULE: ./index.js /* eslint-disable import/no-namespace */ diff --git a/test/cases/es-module-concatenation-modules/expected/webpack-5/main.js b/test/cases/es-module-concatenation-modules/expected/webpack-5/main.js index 4f1059be..d289c825 100644 --- a/test/cases/es-module-concatenation-modules/expected/webpack-5/main.js +++ b/test/cases/es-module-concatenation-modules/expected/webpack-5/main.js @@ -69,13 +69,13 @@ __webpack_require__.d(index_namespaceObject, { ;// CONCATENATED MODULE: ./a.css // extracted by mini-css-extract-plugin -const a = "foo__a"; +var a = "foo__a"; ;// CONCATENATED MODULE: ./b.css // extracted by mini-css-extract-plugin -const b = "foo__b"; +var b = "foo__b"; ;// CONCATENATED MODULE: ./c.css // extracted by mini-css-extract-plugin -const c = "foo__c"; +var c = "foo__c"; ;// CONCATENATED MODULE: ./index.js /* eslint-disable import/no-namespace */ diff --git a/test/cases/es-named-export-output-module/expected/main.js b/test/cases/es-named-export-output-module/expected/main.js index 3c403159..b563e81c 100644 --- a/test/cases/es-named-export-output-module/expected/main.js +++ b/test/cases/es-named-export-output-module/expected/main.js @@ -11,9 +11,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ "cClass": () => (/* binding */ cClass) /* harmony export */ }); // extracted by mini-css-extract-plugin -const aClass = "foo__style__a-class"; -const bClass = "foo__style__b__class"; -const cClass = "foo__style__cClass"; +var aClass = "foo__style__a-class"; +var bClass = "foo__style__b__class"; +var cClass = "foo__style__cClass"; /***/ }) /******/ ]); diff --git a/test/cases/es-named-export/expected/webpack-4/main.js b/test/cases/es-named-export/expected/webpack-4/main.js index a2d0a1a8..9386c187 100644 --- a/test/cases/es-named-export/expected/webpack-4/main.js +++ b/test/cases/es-named-export/expected/webpack-4/main.js @@ -107,9 +107,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bClass", function() { return bClass; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cClass", function() { return cClass; }); // extracted by mini-css-extract-plugin -const aClass = "foo__style__a-class"; -const bClass = "foo__style__b__class"; -const cClass = "foo__style__cClass"; +var aClass = "foo__style__a-class"; +var bClass = "foo__style__b__class"; +var cClass = "foo__style__cClass"; /***/ }) /******/ ]); \ No newline at end of file diff --git a/test/cases/es-named-export/expected/webpack-5-importModule/main.js b/test/cases/es-named-export/expected/webpack-5-importModule/main.js index 5017ec83..8cf22c2c 100644 --- a/test/cases/es-named-export/expected/webpack-5-importModule/main.js +++ b/test/cases/es-named-export/expected/webpack-5-importModule/main.js @@ -12,9 +12,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ "cClass": () => (/* binding */ cClass) /* harmony export */ }); // extracted by mini-css-extract-plugin -const aClass = "foo__style__a-class"; -const bClass = "foo__style__b__class"; -const cClass = "foo__style__cClass"; +var aClass = "foo__style__a-class"; +var bClass = "foo__style__b__class"; +var cClass = "foo__style__cClass"; /***/ }) /******/ ]); diff --git a/test/cases/es-named-export/expected/webpack-5/main.js b/test/cases/es-named-export/expected/webpack-5/main.js index 5017ec83..8cf22c2c 100644 --- a/test/cases/es-named-export/expected/webpack-5/main.js +++ b/test/cases/es-named-export/expected/webpack-5/main.js @@ -12,9 +12,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ "cClass": () => (/* binding */ cClass) /* harmony export */ }); // extracted by mini-css-extract-plugin -const aClass = "foo__style__a-class"; -const bClass = "foo__style__b__class"; -const cClass = "foo__style__cClass"; +var aClass = "foo__style__a-class"; +var bClass = "foo__style__b__class"; +var cClass = "foo__style__cClass"; /***/ }) /******/ ]);