Skip to content

Commit 0343224

Browse files
refactor: enable esModules by default
1 parent 2c043d9 commit 0343224

10 files changed

+1238
-1286
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function loader(content, map, meta) {
4343
stringifyRequest(this, preRequester(options.importLoaders) + url);
4444

4545
const esModule =
46-
typeof options.esModule !== 'undefined' ? options.esModule : false;
46+
typeof options.esModule !== 'undefined' ? options.esModule : true;
4747

4848
let modulesOptions;
4949

test/__snapshots__/esModule-option.test.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ exports[`"esModule" option should work when not specified: errors 1`] = `Array [
6767
6868
exports[`"esModule" option should work when not specified: module 1`] = `
6969
"// Imports
70-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\");
71-
var ___CSS_LOADER_AT_RULE_IMPORT_0___ = require(\\"-!../../../src/index.js??[ident]!./imported.css\\");
72-
var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../../src/runtime/getUrl.js\\");
73-
var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./img.png\\");
74-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
70+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\";
71+
import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./imported.css\\";
72+
import ___CSS_LOADER_GET_URL_IMPORT___ from \\"../../../src/runtime/getUrl.js\\";
73+
import ___CSS_LOADER_URL_IMPORT_0___ from \\"./img.png\\";
74+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
7575
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___);
7676
var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);
7777
// Module
7878
___CSS_LOADER_EXPORT___.push([module.id, \\"@charset \\\\\\"UTF-8\\\\\\";\\\\n\\\\n/* Comment */\\\\n\\\\n.class {\\\\n color: red;\\\\n background: url(\\" + ___CSS_LOADER_URL_REPLACEMENT_0___ + \\");\\\\n}\\\\n\\", \\"\\"]);
7979
// Exports
80-
module.exports = ___CSS_LOADER_EXPORT___;
80+
export default ___CSS_LOADER_EXPORT___;
8181
"
8282
`;
8383

test/__snapshots__/icss.test.js.snap

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ exports[`ICSS show work with the case "duplicate-export": errors 1`] = `Array []
44

55
exports[`ICSS show work with the case "duplicate-export": module 1`] = `
66
"// Imports
7-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
8-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
7+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
8+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
99
// Module
1010
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
1111
// Exports
1212
___CSS_LOADER_EXPORT___.locals = {
1313
\\"_test\\": \\"_right_value\\"
1414
};
15-
module.exports = ___CSS_LOADER_EXPORT___;
15+
export default ___CSS_LOADER_EXPORT___;
1616
"
1717
`;
1818

@@ -33,15 +33,15 @@ exports[`ICSS show work with the case "duplicate-export-in-multiple-export": err
3333

3434
exports[`ICSS show work with the case "duplicate-export-in-multiple-export": module 1`] = `
3535
"// Imports
36-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
37-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
36+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
37+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
3838
// Module
3939
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
4040
// Exports
4141
___CSS_LOADER_EXPORT___.locals = {
4242
\\"_test\\": \\"_right_value\\"
4343
};
44-
module.exports = ___CSS_LOADER_EXPORT___;
44+
export default ___CSS_LOADER_EXPORT___;
4545
"
4646
`;
4747

@@ -62,12 +62,12 @@ exports[`ICSS show work with the case "empty-export": errors 1`] = `Array []`;
6262

6363
exports[`ICSS show work with the case "empty-export": module 1`] = `
6464
"// Imports
65-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
66-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
65+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
66+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
6767
// Module
6868
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
6969
// Exports
70-
module.exports = ___CSS_LOADER_EXPORT___;
70+
export default ___CSS_LOADER_EXPORT___;
7171
"
7272
`;
7373

@@ -88,12 +88,12 @@ exports[`ICSS show work with the case "empty-import": errors 1`] = `Array []`;
8888

8989
exports[`ICSS show work with the case "empty-import": module 1`] = `
9090
"// Imports
91-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
92-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
91+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
92+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
9393
// Module
9494
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
9595
// Exports
96-
module.exports = ___CSS_LOADER_EXPORT___;
96+
export default ___CSS_LOADER_EXPORT___;
9797
"
9898
`;
9999

@@ -114,15 +114,15 @@ exports[`ICSS show work with the case "export": errors 1`] = `Array []`;
114114

115115
exports[`ICSS show work with the case "export": module 1`] = `
116116
"// Imports
117-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
118-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
117+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
118+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
119119
// Module
120120
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
121121
// Exports
122122
___CSS_LOADER_EXPORT___.locals = {
123123
\\"_test\\": \\"_test\\"
124124
};
125-
module.exports = ___CSS_LOADER_EXPORT___;
125+
export default ___CSS_LOADER_EXPORT___;
126126
"
127127
`;
128128

@@ -143,16 +143,16 @@ exports[`ICSS show work with the case "export-reserved-keywords": errors 1`] = `
143143

144144
exports[`ICSS show work with the case "export-reserved-keywords": module 1`] = `
145145
"// Imports
146-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
147-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
146+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
147+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
148148
// Module
149149
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
150150
// Exports
151151
___CSS_LOADER_EXPORT___.locals = {
152152
\\"constructor\\": \\"constructor\\",
153153
\\"toString\\": \\"toString\\"
154154
};
155-
module.exports = ___CSS_LOADER_EXPORT___;
155+
export default ___CSS_LOADER_EXPORT___;
156156
"
157157
`;
158158

@@ -173,17 +173,17 @@ exports[`ICSS show work with the case "import": errors 1`] = `Array []`;
173173

174174
exports[`ICSS show work with the case "import": module 1`] = `
175175
"// Imports
176-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
177-
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??[ident]!./vars.css\\");
178-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
176+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
177+
import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\";
178+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
179179
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
180180
// Module
181181
___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
182182
// Exports
183183
___CSS_LOADER_EXPORT___.locals = {
184184
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\"
185185
};
186-
module.exports = ___CSS_LOADER_EXPORT___;
186+
export default ___CSS_LOADER_EXPORT___;
187187
"
188188
`;
189189

@@ -212,9 +212,9 @@ exports[`ICSS show work with the case "import-reserved-keywords": errors 1`] = `
212212

213213
exports[`ICSS show work with the case "import-reserved-keywords": module 1`] = `
214214
"// Imports
215-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
216-
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??[ident]!./vars.css\\");
217-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
215+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
216+
import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\";
217+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
218218
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
219219
// Module
220220
___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n display: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
@@ -223,7 +223,7 @@ ___CSS_LOADER_EXPORT___.locals = {
223223
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\",
224224
\\"secondary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\"\\"
225225
};
226-
module.exports = ___CSS_LOADER_EXPORT___;
226+
export default ___CSS_LOADER_EXPORT___;
227227
"
228228
`;
229229

@@ -253,16 +253,16 @@ exports[`ICSS show work with the case "multiple-export": errors 1`] = `Array []`
253253

254254
exports[`ICSS show work with the case "multiple-export": module 1`] = `
255255
"// Imports
256-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
257-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
256+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
257+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
258258
// Module
259259
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
260260
// Exports
261261
___CSS_LOADER_EXPORT___.locals = {
262262
\\"_test\\": \\"_test\\",
263263
\\"_foo\\": \\"_bar\\"
264264
};
265-
module.exports = ___CSS_LOADER_EXPORT___;
265+
export default ___CSS_LOADER_EXPORT___;
266266
"
267267
`;
268268

@@ -283,8 +283,8 @@ exports[`ICSS show work with the case "multiple-keys-values-in-export": errors 1
283283

284284
exports[`ICSS show work with the case "multiple-keys-values-in-export": module 1`] = `
285285
"// Imports
286-
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
287-
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
286+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
287+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
288288
// Module
289289
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
290290
// Exports
@@ -295,7 +295,7 @@ ___CSS_LOADER_EXPORT___.locals = {
295295
\\"_test3\\": \\"1px 2px 3px\\",
296296
\\"_test4\\": \\"1px 2px 3px, 1px 2px 3px\\"
297297
};
298-
module.exports = ___CSS_LOADER_EXPORT___;
298+
export default ___CSS_LOADER_EXPORT___;
299299
"
300300
`;
301301

0 commit comments

Comments
 (0)