From 3a945f5d238dbcbdc5e2be641ce4a8a553e2a227 Mon Sep 17 00:00:00 2001 From: alwaysalearner1234 Date: Wed, 28 Jan 2026 09:55:36 +0530 Subject: [PATCH 1/2] Update README with ES module usage details Added information about ES module syntax and its benefits. --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1d42739..9342cb1b 100644 --- a/README.md +++ b/README.md @@ -1759,6 +1759,14 @@ Default: `true` By default, `css-loader` generates JS modules that use the ES modules syntax. +This means you can import CSS using standard ES `import` syntax, which is the +recommended approach for modern JavaScript applications and frameworks +like React, Vue, and Angular. + +Set `esModule: false` only if your environment expects CommonJS syntax +(for example, when using `require()` instead of `import`). + + There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/). You can enable CommonJS module syntax using: @@ -1780,7 +1788,7 @@ module.exports = { }, }; ``` - +hh ### `exportType` Type: @@ -2336,6 +2344,8 @@ import * as styles from "Component.module.scss"; // Somewhere in JavaScript canvas drawing code use the variable directly // const ctx = mountsCanvas.current.getContext('2d',{alpha: false}); ctx.fillStyle = `${svars.colorBackgroundCanvas}`; + +kjk ``` ## Contributing From 0d6f8ced4874523a040cdebe4d3a543a7b8b2c55 Mon Sep 17 00:00:00 2001 From: alwaysalearner1234 Date: Sun, 1 Feb 2026 21:40:30 +0530 Subject: [PATCH 2/2] Update README with ES modules benefits Add information about benefits of using ES modules and CommonJS. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9342cb1b..2d68280c 100644 --- a/README.md +++ b/README.md @@ -1766,6 +1766,12 @@ like React, Vue, and Angular. Set `esModule: false` only if your environment expects CommonJS syntax (for example, when using `require()` instead of `import`). +Using ES modules can be beneficial in some scenarios, such as module concatenation +and more consistent optimizations in modern JavaScript tooling. However, +tree-shaking may also work with CommonJS depending on the bundler configuration. +The `esModule` option primarily controls the export syntax generated by `css-loader`, +rather than enabling or disabling optimizations by itself. + There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).