{"_id":"@dz-web/rspack-plugin-stylename","name":"@dz-web/rspack-plugin-stylename","dist-tags":{"latest":"4.1.2"},"versions":{"4.1.2":{"name":"@dz-web/rspack-plugin-stylename","version":"4.1.2","description":"Rust-based SWC plugin for transforming styleName to className in JSX","author":{"name":"Roc"},"license":"ISC","repository":{"type":"git","directory":"packages/rspack-plugin-stylename"},"keywords":["rspack","swc","plugin","stylename","css-modules","jsx","wasm"],"main":"transform.wasm","scripts":{"build":"cargo build --target wasm32-wasip1 --release && cp target/wasm32-wasip1/release/rspack_plugin_stylename.wasm transform.wasm"},"_id":"@dz-web/rspack-plugin-stylename@4.1.2","_integrity":"sha512-7F6eUHW643+OQoxH6fSXeHsrGJPrQyCHEkDlSCXolMbUtMIWgU7wyzd8lhUMlLya4b/DsV8xWSjPQekgPfLt5A==","_resolved":"/private/var/folders/9j/_plnlj351q73lhk4rtb6k04r0000gn/T/e88e590b1f2dd6bf7e0a55844a8be07f/dz-web-rspack-plugin-stylename-4.1.2.tgz","_from":"file:dz-web-rspack-plugin-stylename-4.1.2.tgz","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-7F6eUHW643+OQoxH6fSXeHsrGJPrQyCHEkDlSCXolMbUtMIWgU7wyzd8lhUMlLya4b/DsV8xWSjPQekgPfLt5A==","shasum":"fd914d34f8f85553a13a5081fc7e6e212b1a8bff","tarball":"https://registry.npmjs.org/@dz-web/rspack-plugin-stylename/-/rspack-plugin-stylename-4.1.2.tgz","fileCount":4,"unpackedSize":1583552,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCapnTFs/ycrUJ2RpcEfjPxzfIHhBf88wcTlw+P1xaMpwIgM3ZP1xSMXD2I4Icv/vme9nuwoqdPao6xbRDGy7aL8Ig="}]},"_npmUser":{"name":"moonlitusun2","email":"moonlitusun@gmail.com"},"directories":{},"maintainers":[{"name":"webpatch","email":"webpatch@sina.com"},{"name":"moonlitusun2","email":"moonlitusun@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rspack-plugin-stylename_4.1.2_1773040971751_0.9474546465656579"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-09T07:22:51.668Z","4.1.2":"2026-03-09T07:22:51.924Z","modified":"2026-03-09T07:22:52.163Z"},"maintainers":[{"name":"webpatch","email":"webpatch@sina.com"},{"name":"moonlitusun2","email":"moonlitusun@gmail.com"}],"description":"Rust-based SWC plugin for transforming styleName to className in JSX","keywords":["rspack","swc","plugin","stylename","css-modules","jsx","wasm"],"repository":{"type":"git","directory":"packages/rspack-plugin-stylename"},"author":{"name":"Roc"},"license":"ISC","readme":"# Rspack StyleName Plugin\n\nA Rust-based SWC plugin for transforming `styleName` attributes to `className` in JSX, compiled to WebAssembly for optimal performance.\n\n## Features\n\n- ✅ Transforms `styleName` to `className` at compile time\n- ✅ Supports CSS Modules with scoped class names\n- ✅ Zero runtime overhead\n- ✅ Written in Rust, compiled to WASM\n- ✅ Compatible with Rspack's `builtin:swc-loader`\n\n## Installation\n\n```bash\npnpm add @dz-web/rspack-plugin-stylename\n```\n\n## Usage\n\nConfigure in your Rspack configuration:\n\n```javascript\n// rspack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(jsx|tsx)$/,\n        use: [{\n          loader: 'builtin:swc-loader',\n          options: {\n            jsc: {\n              experimental: {\n                plugins: [\n                  [\n                    require.resolve('@dz-web/rspack-plugin-stylename/transform.wasm'),\n                    {\n                      hashPattern: '[name]__[local]___[hash:base64:5]'\n                    }\n                  ]\n                ]\n              }\n            }\n          }\n        }]\n      }\n    ]\n  }\n};\n```\n\n## Example\n\nInput:\n\n```jsx\nimport styles from './Button.scss';\n\nfunction Button() {\n  return <button styleName=\"primary large\">Click me</button>;\n}\n```\n\nOutput:\n\n```jsx\nimport styles from './Button.scss';\n\nfunction Button() {\n  return <button className=\"Button__primary___a1b2c Button__large___d3e4f\">Click me</button>;\n}\n```\n\n## Configuration\n\n### `hashPattern`\n\nPattern for generating scoped class names. Default: `[name]__[local]___[hash:base64:5]`\n\nPlaceholders:\n- `[name]` - File name\n- `[local]` - Original class name\n- `[hash:base64:N]` - Hash of the content (N = length)\n\n## Development\n\n### Building\n\n```bash\npnpm run build\n```\n\nThis compiles the Rust code to WASM and copies it to `transform.wasm`.\n\n### Requirements\n\n- Rust toolchain with `wasm32-wasi` target\n- `cargo` build tool\n\n## License\n\nISC\n","readmeFilename":"README.md","_rev":"1-3e6673deb0e4e3214205c62cf1500bd8"}