Skip to content

Commit

Permalink
refactor: reuse export string
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Mar 1, 2024
1 parent 023d85c commit 9e1c005
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ function pitch(request) {
const exportsString = `export { ${identifiers
.map(([id, key]) => `${id} as ${JSON.stringify(key)}`)
.join(", ")} }`;
const exportDefaultString = `export default ${JSON.stringify(
locals
)}`;
const exportDefaultString = `export default { ${identifiers
.map(([id, key]) => `${JSON.stringify(key)}: ${id}`)
.join(", ")} }`;
return `${localsString}\n${exportsString}\n${exportDefaultString}\n`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __webpack_require__.r(__webpack_exports__);
var _1 = () => "class-name-a";
var _2 = () => "class-name-b";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "cnA": _1, "cnB": _2 });


/***/ })
Expand Down
6 changes: 3 additions & 3 deletions test/cases/es-module-concatenation-modules/expected/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ __webpack_require__.d(index_namespaceObject, {
// extracted by mini-css-extract-plugin
var _1 = "foo__a";

/* harmony default export */ const a = ({"a":"foo__a"});
/* harmony default export */ const a = ({ "a": _1 });

;// CONCATENATED MODULE: ./b.css
// extracted by mini-css-extract-plugin
var b_1 = "foo__b";

/* harmony default export */ const b = ({"b":"foo__b"});
/* harmony default export */ const b = ({ "b": b_1 });

;// CONCATENATED MODULE: ./c.css
// extracted by mini-css-extract-plugin
var c_1 = "foo__c";

/* harmony default export */ const c = ({"c":"foo__c"});
/* harmony default export */ const c = ({ "c": c_1 });

;// CONCATENATED MODULE: ./index.js
/* eslint-disable import/no-namespace */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _1 = "Xh041yLR4iCP4RGjge50";
var _2 = "NMuRsxoDwvW8BhSXhFAY";
var _3 = "ayWIv09rPsAqE2JznIsI";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"a-class":"Xh041yLR4iCP4RGjge50","b__class":"NMuRsxoDwvW8BhSXhFAY","cClass":"ayWIv09rPsAqE2JznIsI"});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "a-class": _1, "b__class": _2, "cClass": _3 });


/***/ })
Expand Down
2 changes: 1 addition & 1 deletion test/cases/es-named-export-as-is/expected/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _1 = "Xh041yLR4iCP4RGjge50";
var _2 = "NMuRsxoDwvW8BhSXhFAY";
var _3 = "ayWIv09rPsAqE2JznIsI";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"a-class":"Xh041yLR4iCP4RGjge50","b__class":"NMuRsxoDwvW8BhSXhFAY","cClass":"ayWIv09rPsAqE2JznIsI"});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "a-class": _1, "b__class": _2, "cClass": _3 });


/***/ })
Expand Down
2 changes: 1 addition & 1 deletion test/cases/es-named-export-output-module/expected/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var _1 = "foo__style__a-class";
var _2 = "foo__style__b__class";
var _3 = "foo__style__cClass";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"aClass":"foo__style__a-class","bClass":"foo__style__b__class","cClass":"foo__style__cClass"});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "aClass": _1, "bClass": _2, "cClass": _3 });


/***/ })
Expand Down
2 changes: 1 addition & 1 deletion test/cases/es-named-export/expected/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _1 = "foo__style__a-class";
var _2 = "foo__style__b__class";
var _3 = "foo__style__cClass";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"a-class":"foo__style__a-class","b__class":"foo__style__b__class","cClass":"foo__style__cClass"});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "a-class": _1, "b__class": _2, "cClass": _3 });


/***/ })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _1 = "foo__style__a-class";
var _2 = "foo__style__b__class";
var _3 = "foo__style__cClass";

/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"aClass":"foo__style__a-class","bClass":"foo__style__b__class","cClass":"foo__style__cClass"});
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "aClass": _1, "bClass": _2, "cClass": _3 });


/***/ })
Expand Down

0 comments on commit 9e1c005

Please sign in to comment.