Skip to content

esModule option enable by default #1111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: enable esModules by default
  • Loading branch information
cap-Bernardito committed Jul 16, 2020
commit 1a225acfc6f18140f9e77ab43d70faf7e5b892a9
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function loader(content, map, meta) {
stringifyRequest(this, preRequester(options.importLoaders) + url);

const esModule =
typeof options.esModule !== 'undefined' ? options.esModule : false;
typeof options.esModule !== 'undefined' ? options.esModule : true;

let modulesOptions;

Expand Down
12 changes: 6 additions & 6 deletions test/__snapshots__/esModule-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ exports[`"esModule" option should work when not specified: errors 1`] = `Array [

exports[`"esModule" option should work when not specified: module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../src/runtime/api.js\\");
var ___CSS_LOADER_AT_RULE_IMPORT_0___ = require(\\"-!../../../src/index.js??[ident]!./imported.css\\");
var ___CSS_LOADER_GET_URL_IMPORT___ = require(\\"../../../src/runtime/getUrl.js\\");
var ___CSS_LOADER_URL_IMPORT_0___ = require(\\"./img.png\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../src/runtime/api.js\\";
import ___CSS_LOADER_AT_RULE_IMPORT_0___ from \\"-!../../../src/index.js??[ident]!./imported.css\\";
import ___CSS_LOADER_GET_URL_IMPORT___ from \\"../../../src/runtime/getUrl.js\\";
import ___CSS_LOADER_URL_IMPORT_0___ from \\"./img.png\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_AT_RULE_IMPORT_0___);
var ___CSS_LOADER_URL_REPLACEMENT_0___ = ___CSS_LOADER_GET_URL_IMPORT___(___CSS_LOADER_URL_IMPORT_0___);
// Module
___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\\", \\"\\"]);
// Exports
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

Expand Down
64 changes: 32 additions & 32 deletions test/__snapshots__/icss.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ exports[`ICSS show work with the case "duplicate-export": errors 1`] = `Array []

exports[`ICSS show work with the case "duplicate-export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"_test\\": \\"_right_value\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "duplicate-export-in-multiple-export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"_test\\": \\"_right_value\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "empty-export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "empty-import": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"_test\\": \\"_test\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "export-reserved-keywords": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"constructor\\": \\"constructor\\",
\\"toString\\": \\"toString\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "import": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??[ident]!./vars.css\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\".className {\\\\n color: \\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\";\\\\n}\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "import-reserved-keywords": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
var ___CSS_LOADER_ICSS_IMPORT_0___ = require(\\"-!../../../../../src/index.js??[ident]!./vars.css\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
import ___CSS_LOADER_ICSS_IMPORT_0___ from \\"-!../../../../../src/index.js??[ident]!./vars.css\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
___CSS_LOADER_EXPORT___.i(___CSS_LOADER_ICSS_IMPORT_0___, \\"\\", true);
// Module
___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\\", \\"\\"]);
Expand All @@ -223,7 +223,7 @@ ___CSS_LOADER_EXPORT___.locals = {
\\"primary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"primary-color\\"] + \\"\\",
\\"secondary-color\\": \\"\\" + ___CSS_LOADER_ICSS_IMPORT_0___.locals[\\"secondary-color\\"] + \\"\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "multiple-export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
___CSS_LOADER_EXPORT___.locals = {
\\"_test\\": \\"_test\\",
\\"_foo\\": \\"_bar\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

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

exports[`ICSS show work with the case "multiple-keys-values-in-export": module 1`] = `
"// Imports
var ___CSS_LOADER_API_IMPORT___ = require(\\"../../../../../src/runtime/api.js\\");
___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../../src/runtime/api.js\\";
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(false);
// Module
___CSS_LOADER_EXPORT___.push([module.id, \\"\\\\n\\", \\"\\"]);
// Exports
Expand All @@ -295,7 +295,7 @@ ___CSS_LOADER_EXPORT___.locals = {
\\"_test3\\": \\"1px 2px 3px\\",
\\"_test4\\": \\"1px 2px 3px, 1px 2px 3px\\"
};
module.exports = ___CSS_LOADER_EXPORT___;
export default ___CSS_LOADER_EXPORT___;
"
`;

Expand Down
Loading