Skip to content

Commit d14131a

Browse files
committed
feat: remove defaultExport option
1 parent 1787dab commit d14131a

File tree

13 files changed

+29
-171
lines changed

13 files changed

+29
-171
lines changed

src/loader.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ function pitch(request) {
124124
const esModule =
125125
typeof options.esModule !== "undefined" ? options.esModule : true;
126126

127-
const defaultExport =
128-
typeof options.defaultExport !== "undefined"
129-
? options.defaultExport
130-
: false;
131-
132127
/**
133128
* @param {Dependency[] | [null, object][]} dependencies
134129
*/
@@ -276,10 +271,10 @@ function pitch(request) {
276271
const exportsString = `export { ${identifiers
277272
.map(([id, key]) => `${id} as ${JSON.stringify(key)}`)
278273
.join(", ")} }`;
279-
const exportDefaultString = defaultExport
280-
? `export default ${JSON.stringify(locals)}\n`
281-
: "";
282-
return `${localsString}\n${exportsString}\n${exportDefaultString}`;
274+
const exportDefaultString = `export default ${JSON.stringify(
275+
locals
276+
)}`;
277+
return `${localsString}\n${exportsString}\n${exportDefaultString}\n`;
283278
}
284279

285280
return `\n${

test/cases/custom-loader-with-functional-exports/expected/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
__webpack_require__.r(__webpack_exports__);
99
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1010
/* harmony export */ cnA: () => (/* binding */ _1),
11-
/* harmony export */ cnB: () => (/* binding */ _2)
11+
/* harmony export */ cnB: () => (/* binding */ _2),
12+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1213
/* harmony export */ });
1314
// extracted by mini-css-extract-plugin
1415
var _1 = () => "class-name-a";
1516
var _2 = () => "class-name-b";
1617

18+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({});
1719

1820

1921
/***/ })

test/cases/es-module-concatenation-modules/expected/main.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@ __webpack_require__.d(__webpack_exports__, {
4848
var a_namespaceObject = {};
4949
__webpack_require__.r(a_namespaceObject);
5050
__webpack_require__.d(a_namespaceObject, {
51-
a: () => (_1)
51+
a: () => (_1),
52+
"default": () => (a)
5253
});
5354

5455
// NAMESPACE OBJECT: ./b.css
5556
var b_namespaceObject = {};
5657
__webpack_require__.r(b_namespaceObject);
5758
__webpack_require__.d(b_namespaceObject, {
58-
b: () => (b_1)
59+
b: () => (b_1),
60+
"default": () => (b)
5961
});
6062

6163
// NAMESPACE OBJECT: ./index.js
@@ -71,16 +73,19 @@ __webpack_require__.d(index_namespaceObject, {
7173
// extracted by mini-css-extract-plugin
7274
var _1 = "foo__a";
7375

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

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

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

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

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

8590
;// CONCATENATED MODULE: ./index.js
8691
/* eslint-disable import/no-namespace */

test/cases/es-named-export-as-is-output-module/expected/main.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ __webpack_require__.r(__webpack_exports__);
77
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
88
/* harmony export */ "a-class": () => (/* binding */ _1),
99
/* harmony export */ b__class: () => (/* binding */ _2),
10-
/* harmony export */ cClass: () => (/* binding */ _3)
10+
/* harmony export */ cClass: () => (/* binding */ _3),
11+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1112
/* harmony export */ });
1213
// extracted by mini-css-extract-plugin
1314
var _1 = "Xh041yLR4iCP4RGjge50";
1415
var _2 = "NMuRsxoDwvW8BhSXhFAY";
1516
var _3 = "ayWIv09rPsAqE2JznIsI";
1617

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

1820

1921
/***/ })

test/cases/es-named-export-as-is/expected/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ __webpack_require__.r(__webpack_exports__);
99
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1010
/* harmony export */ "a-class": () => (/* binding */ _1),
1111
/* harmony export */ b__class: () => (/* binding */ _2),
12-
/* harmony export */ cClass: () => (/* binding */ _3)
12+
/* harmony export */ cClass: () => (/* binding */ _3),
13+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1314
/* harmony export */ });
1415
// extracted by mini-css-extract-plugin
1516
var _1 = "Xh041yLR4iCP4RGjge50";
1617
var _2 = "NMuRsxoDwvW8BhSXhFAY";
1718
var _3 = "ayWIv09rPsAqE2JznIsI";
1819

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

2022

2123
/***/ })

test/cases/es-named-export-output-module/expected/main.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ __webpack_require__.r(__webpack_exports__);
77
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
88
/* harmony export */ aClass: () => (/* binding */ _1),
99
/* harmony export */ bClass: () => (/* binding */ _2),
10-
/* harmony export */ cClass: () => (/* binding */ _3)
10+
/* harmony export */ cClass: () => (/* binding */ _3),
11+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1112
/* harmony export */ });
1213
// extracted by mini-css-extract-plugin
1314
var _1 = "foo__style__a-class";
1415
var _2 = "foo__style__b__class";
1516
var _3 = "foo__style__cClass";
1617

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

1820

1921
/***/ })

test/cases/es-named-export-with-default/expected/main.css

-12
This file was deleted.

test/cases/es-named-export-with-default/expected/main.js

-91
This file was deleted.

test/cases/es-named-export-with-default/index.js

-4
This file was deleted.

test/cases/es-named-export-with-default/style.css

-11
This file was deleted.

test/cases/es-named-export-with-default/webpack.config.js

-36
This file was deleted.

test/cases/es-named-export/expected/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ __webpack_require__.r(__webpack_exports__);
99
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1010
/* harmony export */ "a-class": () => (/* binding */ _1),
1111
/* harmony export */ b__class: () => (/* binding */ _2),
12-
/* harmony export */ cClass: () => (/* binding */ _3)
12+
/* harmony export */ cClass: () => (/* binding */ _3),
13+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1314
/* harmony export */ });
1415
// extracted by mini-css-extract-plugin
1516
var _1 = "foo__style__a-class";
1617
var _2 = "foo__style__b__class";
1718
var _3 = "foo__style__cClass";
1819

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

2022

2123
/***/ })

test/cases/export-only-locals-and-es-named-export/expected/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ __webpack_require__.r(__webpack_exports__);
99
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
1010
/* harmony export */ aClass: () => (/* binding */ _1),
1111
/* harmony export */ bClass: () => (/* binding */ _2),
12-
/* harmony export */ cClass: () => (/* binding */ _3)
12+
/* harmony export */ cClass: () => (/* binding */ _3),
13+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1314
/* harmony export */ });
1415
// extracted by mini-css-extract-plugin
1516
var _1 = "foo__style__a-class";
1617
var _2 = "foo__style__b__class";
1718
var _3 = "foo__style__cClass";
1819

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

2022

2123
/***/ })

0 commit comments

Comments
 (0)