Skip to content

Commit ddb84c6

Browse files
test: added
1 parent 657af90 commit ddb84c6

File tree

12 files changed

+168
-25
lines changed

12 files changed

+168
-25
lines changed

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
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),
12-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11+
/* harmony export */ cnB: () => (/* binding */ _2)
1312
/* harmony export */ });
1413
// extracted by mini-css-extract-plugin
1514
var _1 = () => "class-name-a";
1615
var _2 = () => "class-name-b";
1716

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

2018

2119
/***/ })

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

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

5554
// NAMESPACE OBJECT: ./b.css
5655
var b_namespaceObject = {};
5756
__webpack_require__.r(b_namespaceObject);
5857
__webpack_require__.d(b_namespaceObject, {
59-
b: () => (b_1),
60-
"default": () => (b)
58+
b: () => (b_1)
6159
});
6260

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

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

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

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

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

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

9085
;// CONCATENATED MODULE: ./index.js
9186
/* eslint-disable import/no-namespace */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.foo__style__a-class {
2+
background: red;
3+
}
4+
5+
.foo__style__b__class {
6+
color: green;
7+
}
8+
9+
.foo__style__cClass {
10+
color: blue;
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/******/ (() => { // webpackBootstrap
2+
/******/ "use strict";
3+
/******/ var __webpack_modules__ = ([
4+
/* 0 */,
5+
/* 1 */
6+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7+
8+
__webpack_require__.r(__webpack_exports__);
9+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
10+
/* harmony export */ "a-class": () => (/* binding */ _1),
11+
/* harmony export */ b__class: () => (/* binding */ _2),
12+
/* harmony export */ cClass: () => (/* binding */ _3),
13+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
14+
/* harmony export */ });
15+
// extracted by mini-css-extract-plugin
16+
var _1 = "foo__style__a-class";
17+
var _2 = "foo__style__b__class";
18+
var _3 = "foo__style__cClass";
19+
20+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "a-class": _1, "b__class": _2, "cClass": _3 });
21+
22+
23+
/***/ })
24+
/******/ ]);
25+
/************************************************************************/
26+
/******/ // The module cache
27+
/******/ var __webpack_module_cache__ = {};
28+
/******/
29+
/******/ // The require function
30+
/******/ function __webpack_require__(moduleId) {
31+
/******/ // Check if module is in cache
32+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
33+
/******/ if (cachedModule !== undefined) {
34+
/******/ return cachedModule.exports;
35+
/******/ }
36+
/******/ // Create a new module (and put it into the cache)
37+
/******/ var module = __webpack_module_cache__[moduleId] = {
38+
/******/ // no module.id needed
39+
/******/ // no module.loaded needed
40+
/******/ exports: {}
41+
/******/ };
42+
/******/
43+
/******/ // Execute the module function
44+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
45+
/******/
46+
/******/ // Return the exports of the module
47+
/******/ return module.exports;
48+
/******/ }
49+
/******/
50+
/************************************************************************/
51+
/******/ /* webpack/runtime/define property getters */
52+
/******/ (() => {
53+
/******/ // define getter functions for harmony exports
54+
/******/ __webpack_require__.d = (exports, definition) => {
55+
/******/ for(var key in definition) {
56+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
57+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
58+
/******/ }
59+
/******/ }
60+
/******/ };
61+
/******/ })();
62+
/******/
63+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
64+
/******/ (() => {
65+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
66+
/******/ })();
67+
/******/
68+
/******/ /* webpack/runtime/make namespace object */
69+
/******/ (() => {
70+
/******/ // define __esModule on exports
71+
/******/ __webpack_require__.r = (exports) => {
72+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
73+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
74+
/******/ }
75+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
76+
/******/ };
77+
/******/ })();
78+
/******/
79+
/************************************************************************/
80+
var __webpack_exports__ = {};
81+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
82+
(() => {
83+
__webpack_require__.r(__webpack_exports__);
84+
/* harmony import */ var _style_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
85+
86+
87+
// eslint-disable-next-line no-console
88+
console.log({ css: _style_css__WEBPACK_IMPORTED_MODULE_0__["default"], aClass: _style_css__WEBPACK_IMPORTED_MODULE_0__["a-class"], bClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.b__class, cClass: _style_css__WEBPACK_IMPORTED_MODULE_0__.cClass });
89+
90+
})();
91+
92+
/******/ })()
93+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import css, {
2+
"a-class" as aClass,
3+
"b__class" as bClass,
4+
cClass,
5+
} from "./style.css";
6+
7+
// eslint-disable-next-line no-console
8+
console.log({ css, aClass, bClass, cClass });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.a-class {
2+
background: red;
3+
}
4+
5+
.b__class {
6+
color: green;
7+
}
8+
9+
.cClass {
10+
color: blue;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import Self from "../../../src";
2+
3+
module.exports = {
4+
entry: "./index.js",
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [
10+
{
11+
loader: Self.loader,
12+
options: {
13+
defaultExport: true,
14+
},
15+
},
16+
{
17+
loader: "css-loader",
18+
options: {
19+
esModule: true,
20+
modules: {
21+
namedExport: true,
22+
exportLocalsConvention: "asIs",
23+
localIdentName: "foo__[name]__[local]",
24+
},
25+
},
26+
},
27+
],
28+
},
29+
],
30+
},
31+
plugins: [
32+
new Self({
33+
filename: "[name].css",
34+
}),
35+
],
36+
};

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ __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),
11-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10+
/* harmony export */ cClass: () => (/* binding */ _3)
1211
/* harmony export */ });
1312
// extracted by mini-css-extract-plugin
1413
var _1 = "Xh041yLR4iCP4RGjge50";
1514
var _2 = "NMuRsxoDwvW8BhSXhFAY";
1615
var _3 = "ayWIv09rPsAqE2JznIsI";
1716

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

2018

2119
/***/ })

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ __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),
13-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
12+
/* harmony export */ cClass: () => (/* binding */ _3)
1413
/* harmony export */ });
1514
// extracted by mini-css-extract-plugin
1615
var _1 = "Xh041yLR4iCP4RGjge50";
1716
var _2 = "NMuRsxoDwvW8BhSXhFAY";
1817
var _3 = "ayWIv09rPsAqE2JznIsI";
1918

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

2220

2321
/***/ })

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ __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),
11-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10+
/* harmony export */ cClass: () => (/* binding */ _3)
1211
/* harmony export */ });
1312
// extracted by mini-css-extract-plugin
1413
var _1 = "foo__style__a-class";
1514
var _2 = "foo__style__b__class";
1615
var _3 = "foo__style__cClass";
1716

18-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "aClass": _1, "bClass": _2, "cClass": _3 });
1917

2018

2119
/***/ })

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ __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),
13-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
12+
/* harmony export */ cClass: () => (/* binding */ _3)
1413
/* harmony export */ });
1514
// extracted by mini-css-extract-plugin
1615
var _1 = "foo__style__a-class";
1716
var _2 = "foo__style__b__class";
1817
var _3 = "foo__style__cClass";
1918

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

2220

2321
/***/ })

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ __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),
13-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
12+
/* harmony export */ cClass: () => (/* binding */ _3)
1413
/* harmony export */ });
1514
// extracted by mini-css-extract-plugin
1615
var _1 = "foo__style__a-class";
1716
var _2 = "foo__style__b__class";
1817
var _3 = "foo__style__cClass";
1918

20-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ "aClass": _1, "bClass": _2, "cClass": _3 });
2119

2220

2321
/***/ })

0 commit comments

Comments
 (0)