An esbuild plugin that bundles CSS Modules into JavaScript/TypeScript files using Lightning CSS for fast transformation. Version 3.1.5 requires Node >= 20 and esbuild as a peer dependency. It supports both bundled and unbundled builds, offering features like type declaration generation, camelCase class renaming, and named exports. Key differentiators: built on Lightning CSS for speed, works with `bundle: false` to produce standalone .css.js files, and provides full TypeScript type definitions. Release cadence is active with frequent updates.
npm install esbuild-css-modules-pluginVerified import paths — ran on the pinned version, not inferred.
Basic esbuild build with CSS Modules plugin, enabling named exports, type declarations, and camelCase class names.
Update imports to use ES module syntax: `import CssModulesPlugin from 'esbuild-css-modules-plugin'` and ensure your project uses ESM (e.g., `"type": "module"` in package.json).
Update Node.js to version 20 or later.
Replace `inject: true` with `force: true` in plugin options.
Ensure CSS class names only contain alphanumeric characters, $, and _, or set `localsConvention` to 'camelCaseOnly' to auto-convert.
To process any CSS file, set `force: true` in plugin options.
Switch to ESM imports or use dynamic import(): `const CssModulesPlugin = (await import('esbuild-css-modules-plugin')).default`.Use default import: `import CssModulesPlugin from 'esbuild-css-modules-plugin'` and call it as a function: `CssModulesPlugin({...})`.Run `npm install -D esbuild-css-modules-plugin` or check your package.json dependencies.