From 8ae810b9143aa3ce0625a2b0d52115f44b358c09 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Nov 2026 19:25:02 +0800 Subject: [PATCH 1/2] feat: add Solid JSX and refresh loaders for Rspack --- .github/workflows/test.yml | 3 + .gitignore | 1 + .node-version | 1 + LICENSE | 1 + README.md | 95 ++-- package.json | 30 +- playground/package.json | 14 +- playground/rspack.config.mjs | 45 ++ playground/rstack.config.ts | 7 - playground/src/Counter.tsx | 3 + playground/src/index.css | 26 -- playground/src/index.ts | 11 - playground/src/index.tsx | 10 + playground/tsconfig.json | 3 +- pnpm-lock.yaml | 841 ++++++++++++++++++++++++++++++++++- pnpm-workspace.yaml | 6 + rstack.config.ts | 3 + src/helpers.ts | 38 ++ src/index.ts | 100 ++++- src/refresh.ts | 50 +++ src/types.ts | 145 ++++++ test/basic/index.test.ts | 135 ++++-- test/basic/src/index.js | 1 - 23 files changed, 1435 insertions(+), 134 deletions(-) create mode 100644 .node-version create mode 100644 playground/rspack.config.mjs delete mode 100644 playground/rstack.config.ts create mode 100644 playground/src/Counter.tsx delete mode 100644 playground/src/index.css delete mode 100644 playground/src/index.ts create mode 100644 playground/src/index.tsx create mode 100644 src/helpers.ts create mode 100644 src/refresh.ts create mode 100644 src/types.ts delete mode 100644 test/basic/src/index.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 735e77e..b75a7da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,5 +40,8 @@ jobs: - name: Install Playwright run: pnpm exec playwright install chromium + - name: Build loaders + run: node --run build + - name: Run Test run: node --run test diff --git a/.gitignore b/.gitignore index 37660a9..a312e7f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ test-results !.vscode/settings.json !.vscode/extensions.json .idea +playground/test-temp-*/ diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +24 diff --git a/LICENSE b/LICENSE index b0f2622..3ec8288 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2024 Rspack Contrib +Copyright (c) 2023-present Bytedance, Inc. and its affiliates. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 60cdf90..d73c964 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,89 @@ -# rsbuild-plugin-example +# solid-loader -Example plugin for Rsbuild. - -

- - npm version - - license - downloads -

+Compile Solid 2 JSX and TSX in Rspack 2. The default loader uses the Solid native compiler. The package also provides a Babel backend and a separate loader for Solid Refresh. ## Usage -Install: +Install the loader in a Solid 2 application: -```bash -npm add rsbuild-plugin-example -D +```sh +pnpm add solid-js@2 @solidjs/web@2 +pnpm add -D solid-loader ``` -Add plugin to your `rsbuild.config.ts`: - -```ts -// rsbuild.config.ts -import { pluginExample } from 'rsbuild-plugin-example'; +Add the loader to the JSX rule in your Rspack config: +```js +// rspack.config.mjs export default { - plugins: [pluginExample()], + resolve: { + extensions: ['.tsx', '.jsx', '.ts', '...'], + conditionNames: ['solid', '...'], + }, + module: { + rules: [ + { + test: /\.[mc]?[jt]sx$/i, + use: [ + { loader: 'builtin:swc-loader', options: { detectSyntax: 'auto' } }, + 'solid-loader', + ], + }, + ], + }, }; ``` -## Options +Rspack runs the loaders from right to left. Solid compiles JSX first, then SWC removes TypeScript types and lowers JavaScript syntax. If you already have an SWC rule for TSX, add `solid-loader` to that rule. For TypeScript projects, set `jsx` to `"preserve"` and `jsxImportSource` to `"@solidjs/web"` in `tsconfig.json`. + +## Solid Refresh -### foo +For browser development builds with HMR enabled, add `development` to the resolve conditions alongside `solid` and register this extra rule. The pre-loader instruments components before JSX compilation. + +```js +{ + test: /\.[mc]?[jt]sx$/i, + enforce: 'pre', + exclude: /node_modules/, + dependency: { not: 'url' }, + resourceQuery: { not: /[?&]raw(?:&|=|$)/ }, + with: { type: { not: 'text' } }, + loader: 'solid-loader/refresh', +} +``` -Some description. +Refresh generates per-component metadata by default. Set `options: { granular: false }` on the refresh rule to disable it. The [playground](./playground/rspack.config.mjs) shows the full configuration for development and production. -- Type: `string` -- Default: `undefined` -- Example: +## Server-side rendering + +Set `options.solid` on the main loader for each build: + +| Build | Compiler options | +| ---------------------------- | --------------------------------------- | +| Server | `{ generate: 'ssr', hydratable: true }` | +| Client hydrating server HTML | `{ generate: 'dom', hydratable: true }` | + +To let the Solid runtime import hydration modules by URL, add the following rule: ```js -pluginExample({ - foo: 'bar', -}); +{ + descriptionData: { name: /^@solidjs\/web$/ }, + parser: { importDynamic: false }, +} ``` +## Loader options + +| Option | Behavior | +| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `compiler` | Defaults to `'native'`. Set to `'babel'` to use `@solidjs/babel-plugin`. | +| `solid` | Options for the Solid JSX compiler. By default it generates DOM output, with `dev` enabled in Rspack development mode. | +| `decoratorVersion` | Set to `'legacy'` to parse legacy decorators in the Babel backend. The default parser accepts standard decorators. | +| `scriptRegex` | Optional filename filter for integrations that share a rule with other script types. By default, the loader compiles every resource matched by the rule. | +| `transformFilename` | Filename to use for filtering and parser selection, e.g. `'data-uri.jsx'` for an inline module. Source maps still refer to the original resource. | + +The main entry exports the `SolidLoaderOptions`, `SolidCompiler`, and `SolidPresetOptions` types. The refresh entry exports `SolidRefreshLoaderOptions`. + ## License [MIT](./LICENSE). diff --git a/package.json b/package.json index 5635a9b..447efc0 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,18 @@ { - "name": "rsbuild-plugin-example", + "name": "solid-loader", "version": "0.0.0", - "repository": "https://github.com/rstackjs/rsbuild-plugin-template", + "description": "Solid JSX and refresh loaders for Rspack", + "repository": "https://github.com/rstackjs/solid-loader", "license": "MIT", "type": "module", "exports": { ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" + }, + "./refresh": { + "types": "./dist/refresh.d.ts", + "default": "./dist/refresh.js" } }, "types": "./dist/index.d.ts", @@ -24,22 +29,29 @@ "prepare": "rs hooks", "test": "rs test" }, + "dependencies": { + "@babel/core": "^7.29.13", + "@jridgewell/remapping": "^2.3.5", + "@solidjs/babel-plugin": "2.0.0", + "@solidjs/compiler": "2.0.0" + }, "devDependencies": { - "@rsbuild/core": "^2.3.2", + "@rspack/core": "catalog:", + "@rspack/dev-server": "catalog:", "@rstackjs/test-utils": "^1.0.0", "@rstest/playwright": "^0.12.6", + "@solidjs/web": "catalog:", + "@types/babel__core": "^7.20.5", "@types/node": "^24.19.2", "playwright": "^1.65.0", "rstack": "^0.9.1", + "solid-js": "catalog:", "typescript": "^7.0.2" }, "peerDependencies": { - "@rsbuild/core": "^2.0.0" - }, - "peerDependenciesMeta": { - "@rsbuild/core": { - "optional": true - } + "@rspack/core": "^2.0.0", + "@solidjs/web": "^2.0.0", + "solid-js": "^2.0.0" }, "packageManager": "pnpm@12.18.0", "publishConfig": { diff --git a/playground/package.json b/playground/package.json index 77f3063..2f0dfe1 100644 --- a/playground/package.json +++ b/playground/package.json @@ -4,7 +4,17 @@ "private": true, "type": "module", "scripts": { - "build": "rs build", - "dev": "rs dev" + "build": "rspack build", + "dev": "rspack serve --mode development" + }, + "dependencies": { + "@solidjs/web": "catalog:", + "solid-js": "catalog:" + }, + "devDependencies": { + "@rspack/cli": "~2.3.3", + "@rspack/core": "catalog:", + "@rspack/dev-server": "catalog:", + "solid-loader": "workspace:*" } } diff --git a/playground/rspack.config.mjs b/playground/rspack.config.mjs new file mode 100644 index 0000000..2a80619 --- /dev/null +++ b/playground/rspack.config.mjs @@ -0,0 +1,45 @@ +import { HtmlRspackPlugin } from '@rspack/core'; + +export default (_env, { mode }) => { + const dev = mode === 'development'; + const test = /\.[mc]?[jt]sx$/i; + + return { + context: import.meta.dirname, + mode, + entry: './src/index.tsx', + resolve: { + extensions: ['.tsx', '.jsx', '...'], + conditionNames: ['solid', ...(dev ? ['development'] : []), '...'], + }, + module: { + rules: [ + { + test, + use: [ + { loader: 'builtin:swc-loader', options: { detectSyntax: 'auto' } }, + 'solid-loader', + ], + }, + ...(dev + ? [ + { + test, + enforce: 'pre', + exclude: /node_modules/, + dependency: { not: 'url' }, + resourceQuery: { not: /[?&]raw(?:&|=|$)/ }, + with: { type: { not: 'text' } }, + loader: 'solid-loader/refresh', + }, + ] + : []), + { + descriptionData: { name: /^@solidjs\/web$/ }, + parser: { importDynamic: false }, + }, + ], + }, + plugins: [new HtmlRspackPlugin()], + }; +}; diff --git a/playground/rstack.config.ts b/playground/rstack.config.ts deleted file mode 100644 index 98f74dd..0000000 --- a/playground/rstack.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Configuration guide: https://rstack.rs/config -import { define } from 'rstack'; -import { pluginExample } from '../src/index.ts'; - -define.app({ - plugins: [pluginExample()], -}); diff --git a/playground/src/Counter.tsx b/playground/src/Counter.tsx new file mode 100644 index 0000000..eca04b0 --- /dev/null +++ b/playground/src/Counter.tsx @@ -0,0 +1,3 @@ +export function Counter(props: { count: number; increment: () => void }) { + return ; +} diff --git a/playground/src/index.css b/playground/src/index.css deleted file mode 100644 index 164c0a6..0000000 --- a/playground/src/index.css +++ /dev/null @@ -1,26 +0,0 @@ -body { - margin: 0; - color: #fff; - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; - background-image: linear-gradient(to bottom, #020917, #101725); -} - -.content { - display: flex; - min-height: 100vh; - line-height: 1.1; - text-align: center; - flex-direction: column; - justify-content: center; -} - -.content h1 { - font-size: 3.6rem; - font-weight: 700; -} - -.content p { - font-size: 1.2rem; - font-weight: 400; - opacity: 0.5; -} diff --git a/playground/src/index.ts b/playground/src/index.ts deleted file mode 100644 index 9b727fe..0000000 --- a/playground/src/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import './index.css'; - -const root = document.getElementById('root'); -if (root) { - root.innerHTML = ` -
-

Vanilla Rsbuild

-

Start building amazing things with Rsbuild.

-
-`; -} diff --git a/playground/src/index.tsx b/playground/src/index.tsx new file mode 100644 index 0000000..1b710c9 --- /dev/null +++ b/playground/src/index.tsx @@ -0,0 +1,10 @@ +import { render } from '@solidjs/web'; +import { createSignal } from 'solid-js'; +import { Counter } from './Counter'; + +function App() { + const [count, setCount] = createSignal(0); + return setCount(count() + 1)} />; +} + +render(() => , document.body); diff --git a/playground/tsconfig.json b/playground/tsconfig.json index 4d1d672..9a757a3 100644 --- a/playground/tsconfig.json +++ b/playground/tsconfig.json @@ -4,7 +4,8 @@ "target": "ES2020", "noEmit": true, "skipLibCheck": true, - "types": ["rstack/types"], + "jsx": "preserve", + "jsxImportSource": "@solidjs/web", "useDefineForClassFields": true, /* modules */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3c56b2b..ef7401b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -162,19 +162,56 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + '@rspack/core': + specifier: ~2.3.3 + version: 2.3.3 + '@rspack/dev-server': + specifier: ^2.2.2 + version: 2.2.2 + '@solidjs/web': + specifier: ^2.0.0 + version: 2.0.0 + solid-js: + specifier: ^2.0.0 + version: 2.0.0 + importers: .: + dependencies: + '@babel/core': + specifier: ^7.29.13 + version: 7.29.13 + '@jridgewell/remapping': + specifier: ^2.3.5 + version: 2.3.5 + '@solidjs/babel-plugin': + specifier: 2.0.0 + version: 2.0.0(@babel/core@7.29.13) + '@solidjs/compiler': + specifier: 2.0.0 + version: 2.0.0 devDependencies: - '@rsbuild/core': - specifier: ^2.3.2 - version: 2.3.2 + '@rspack/core': + specifier: 'catalog:' + version: 2.3.3(@swc/helpers@0.5.24) + '@rspack/dev-server': + specifier: 'catalog:' + version: 2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24)) '@rstackjs/test-utils': specifier: ^1.0.0 version: 1.0.0 '@rstest/playwright': specifier: ^0.12.6 version: 0.12.6(@rstest/core@0.12.6)(playwright@1.65.0) + '@solidjs/web': + specifier: 'catalog:' + version: 2.0.0(solid-js@2.0.0) + '@types/babel__core': + specifier: ^7.20.5 + version: 7.20.5 '@types/node': specifier: ^24.19.2 version: 24.19.2 @@ -184,11 +221,34 @@ importers: rstack: specifier: ^0.9.1 version: 0.9.1(typescript@7.0.2) + solid-js: + specifier: 'catalog:' + version: 2.0.0 typescript: specifier: ^7.0.2 version: 7.0.2 - playground: {} + playground: + dependencies: + '@solidjs/web': + specifier: 'catalog:' + version: 2.0.0(solid-js@2.0.0) + solid-js: + specifier: 'catalog:' + version: 2.0.0 + devDependencies: + '@rspack/cli': + specifier: ~2.3.3 + version: 2.3.3(@rspack/core@2.3.3(@swc/helpers@0.5.24))(@rspack/dev-server@2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24))) + '@rspack/core': + specifier: 'catalog:' + version: 2.3.3(@swc/helpers@0.5.24) + '@rspack/dev-server': + specifier: 'catalog:' + version: 2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24)) + solid-loader: + specifier: workspace:* + version: link:.. packages: @@ -254,15 +314,121 @@ packages: resolution: {integrity: sha512-pdIyBOsQy9E46s8W9qcEH9ZDjx5nacxnn0cP+17qTuM6D1YoIvKlaz8n8yE1dkTAP59yjCp2t3cpMnacq2YJkw==} engines: {node: '>= 10'} + '@babel/code-frame@7.29.7': + resolution: {integrity: sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==} + engines: {node: '>=6.9.0'} + + '@babel/compat-data@7.29.7': + resolution: {integrity: sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==} + engines: {node: '>=6.9.0'} + + '@babel/core@7.29.13': + resolution: {integrity: sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==} + engines: {node: '>=6.9.0'} + + '@babel/generator@7.29.14': + resolution: {integrity: sha512-qSY56jgW5JnSXzuekLVil6zaOQxOCtOHidr65KkaMBw772IuAY28Qx4ZykAcDn8+FRF15qk80XzKwgSc/RYW6g==} + engines: {node: '>=6.9.0'} + + '@babel/helper-compilation-targets@7.29.13': + resolution: {integrity: sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==} + engines: {node: '>=6.9.0'} + + '@babel/helper-globals@7.29.7': + resolution: {integrity: sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-imports@7.18.6': + resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-imports@7.29.7': + resolution: {integrity: sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==} + engines: {node: '>=6.9.0'} + + '@babel/helper-module-transforms@7.29.14': + resolution: {integrity: sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + + '@babel/helper-plugin-utils@7.29.7': + resolution: {integrity: sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==} + engines: {node: '>=6.9.0'} + + '@babel/helper-string-parser@7.29.14': + resolution: {integrity: sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-identifier@7.29.7': + resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==} + engines: {node: '>=6.9.0'} + + '@babel/helper-validator-option@7.29.7': + resolution: {integrity: sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==} + engines: {node: '>=6.9.0'} + + '@babel/helpers@7.29.14': + resolution: {integrity: sha512-6E3Mi1r0B0umq6vmZa4/78q+64fqO2YY0THUdjDPKUCKhNb0yQy5NQIaPHCSD3ryTgiTss//P4JsWS80AsZ6LQ==} + engines: {node: '>=6.9.0'} + + '@babel/parser@7.29.14': + resolution: {integrity: sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==} + engines: {node: '>=6.0.0'} + hasBin: true + + '@babel/plugin-syntax-jsx@7.29.7': + resolution: {integrity: sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + + '@babel/template@7.29.7': + resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==} + engines: {node: '>=6.9.0'} + + '@babel/traverse@7.29.14': + resolution: {integrity: sha512-RAdQJrBgmIH1FWvN0X+1hoDxzMzlP4cv/1Zi4dn4tG1H0cTb+rw7CzUxQJhp1f4ANd8j5vH3fy8BAWFGkBDEsA==} + engines: {node: '>=6.9.0'} + + '@babel/types@7.29.14': + resolution: {integrity: sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==} + engines: {node: '>=6.9.0'} + + '@emnapi/core@1.11.3': + resolution: {integrity: sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==} + '@emnapi/core@2.0.0-beta.3': resolution: {integrity: sha512-KA+gOBtbifRATmUa/Gpf5C2B2EJ0r4brHUT3XSgACeHREcuiObXH56xd+B3fFsEFbUT04VBEe6MuZiCtMp0tQg==} + '@emnapi/runtime@1.11.3': + resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==} + '@emnapi/runtime@2.0.0-beta.3': resolution: {integrity: sha512-ayb/PyyLzpwRyFVxeC0uoEHu59QlB1iWGcGsOpXQcaB/Dc+uGfBmNmpCHp3HmTT0t8lSsMmg3j7+tdJW/TlHjQ==} + '@emnapi/wasi-threads@1.2.3': + resolution: {integrity: sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==} + '@emnapi/wasi-threads@2.2.0': resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + + '@jridgewell/remapping@2.3.5': + resolution: {integrity: sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==} + + '@jridgewell/resolve-uri@3.1.3': + resolution: {integrity: sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.6.0': + resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + '@napi-rs/wasm-runtime@1.2.7': resolution: {integrity: sha512-zJccwplOAbgfZju95IUHazLnx9RAPtPN2YGJXI6UbrgeaR9QfPjGrQL6ERkSAtnVCA4Q+83ApGyaX5zdpCaKkQ==} engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} @@ -351,81 +517,171 @@ packages: cpu: [arm64] os: [darwin] + '@rspack/binding-darwin-arm64@2.3.3': + resolution: {integrity: sha512-G9WcBOP/6ZWeqTM/G0/rkJRY4DWmYQvk2untzcpj92uO12tqjZ9BSMgtBFvwElwagfQBkX8PPutkAZgtnlAoWA==} + cpu: [arm64] + os: [darwin] + '@rspack/binding-darwin-x64@2.3.2': resolution: {integrity: sha512-C9dhmWDeuuXjmSos2hJ2OBOcafGLxB5HKbW9JprVcd0ZIBx3KSv2Wr4/BsQE1Gxx0JSTRYeeBs0Wpmqi2p24BQ==} cpu: [x64] os: [darwin] + '@rspack/binding-darwin-x64@2.3.3': + resolution: {integrity: sha512-6agI5XDoihay+84vzZgIwwpQQ3xBWbe2HTWBRc0n42LzynIj9h7Qv8CJzf1gSDV1Ts0jzDgAJCYUFJ6Ya5F6MA==} + cpu: [x64] + os: [darwin] + '@rspack/binding-linux-arm64-gnu@2.3.2': resolution: {integrity: sha512-+W67rrYxpKv+7Owe3Yi+GNHmvipCVJ+BxJuGi6VBL6R9Y4MP4ur/U2xxULE3Fe29hUrsq5xaiXAFAssocI63AA==} cpu: [arm64] os: [linux] libc: [glibc] + '@rspack/binding-linux-arm64-gnu@2.3.3': + resolution: {integrity: sha512-VdjK1mDq+GBexd041lmWBFmAvcWIZy7kepTJbJgxLeHYYOnI3KmBG15kemhlK0pBySa+bePX7p2w8uYtl1HsCA==} + cpu: [arm64] + os: [linux] + libc: [glibc] + '@rspack/binding-linux-arm64-musl@2.3.2': resolution: {integrity: sha512-A1c3WMnAGVCUyKvqded3bUf4WWnAU4qKWJXoU2AtTa9KSfURbi2svn3hFk5PT9M/QVDwHEGkz29TgfX2FSc/zw==} cpu: [arm64] os: [linux] libc: [musl] + '@rspack/binding-linux-arm64-musl@2.3.3': + resolution: {integrity: sha512-xF4Wy4XwGjC3m13tFm1q9p9Qpm31qrk6f5zEMPZC31UVabb+2jrgTI1pfZ8IRuo9x/Qw9s+Zq3hyDbtJvvD8Pg==} + cpu: [arm64] + os: [linux] + libc: [musl] + '@rspack/binding-linux-ppc64-gnu@2.3.2': resolution: {integrity: sha512-p+m1JbiKUN0l2Q0I2ielf+spuVv4OKW0dEJUZ6Pxm/KbFEENptAdwOvjrAmUwFFAiNJN6phEDY6/PAcP+DkmIQ==} cpu: [ppc64] os: [linux] libc: [glibc] + '@rspack/binding-linux-ppc64-gnu@2.3.3': + resolution: {integrity: sha512-jVmn+LpF44D4FdZyT91rlT/tPMdHIfPfQTgVzwPB5nDICp4b57SFjVBApuAPIxnLT1pKLkv/LIcdvGSdAeX12w==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + '@rspack/binding-linux-riscv64-gnu@2.3.2': resolution: {integrity: sha512-3aPE11BZ0GxJfaAXS6OjpgUpUE2twRRPR+Lx5YfSMVcLw/m74m4U4bE8q39TsR4+LbaKSn7fhZ7xK06yA1o+kg==} cpu: [riscv64] os: [linux] libc: [glibc] + '@rspack/binding-linux-riscv64-gnu@2.3.3': + resolution: {integrity: sha512-JcQJm8M634jkbG6zJ3TfziKYsCINEAh3FwKuxLljvBgGDEupBxPuB0n2bXBIUeI8P9C33B45IYX6BwWYXll/zw==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + '@rspack/binding-linux-riscv64-musl@2.3.2': resolution: {integrity: sha512-mFRYh2zIuNmaTPIsgXMpZP1NYhysyDEsmheiG/Zr5XE1nQEMj/otxrGl3pj5EFuab4GnwWlBo5M8F0ppvsizYw==} cpu: [riscv64] os: [linux] libc: [musl] + '@rspack/binding-linux-riscv64-musl@2.3.3': + resolution: {integrity: sha512-YMIOS7rFvCDnpeyxoVEVbM7U/TwcC2VDtN3Oiq9BenRsNTEvk0imINhuVRFanh15+wkiQHk9h0b+pzcggYLAsA==} + cpu: [riscv64] + os: [linux] + libc: [musl] + '@rspack/binding-linux-s390x-gnu@2.3.2': resolution: {integrity: sha512-c6aamcvr9vFdccsOX4cPecG1G06aZxsmMWKzQRkcvbrNYR+RwNTGa5iM13KkopktCZgZX7MJo1UNYEN+UK3JHw==} cpu: [s390x] os: [linux] libc: [glibc] + '@rspack/binding-linux-s390x-gnu@2.3.3': + resolution: {integrity: sha512-tHGtIG6GGHsk2KvSleQp/BrVqiGdjDsLJuMKR7hE7W1uJW6WDJ+a+Z23Rk5kHXh5BjeFLjXxcufGuokvmLmTag==} + cpu: [s390x] + os: [linux] + libc: [glibc] + '@rspack/binding-linux-x64-gnu@2.3.2': resolution: {integrity: sha512-l/WCW3RSfJn5eAcWciqZGazhLIj1d8KjfzTAic8XwDFj5JlVwT5i2BhrOSf9b42WNrKrxtsRPFw9UoCKAunDzg==} cpu: [x64] os: [linux] libc: [glibc] + '@rspack/binding-linux-x64-gnu@2.3.3': + resolution: {integrity: sha512-spe8SjywfO+dD7Sk+vIpPaOXf56wstrgeuztfJdiI9zTeQmf/lhdaNUUSUAXlGIaLjrN/PhV8i5kbQ7VaAkenw==} + cpu: [x64] + os: [linux] + libc: [glibc] + '@rspack/binding-linux-x64-musl@2.3.2': resolution: {integrity: sha512-iHPYQWl6pwlzn1NNNvC+ag42uoAoQs0iPP1OEmBIYT2unXpWHnGhr4t8+uN7epD2fNYZ8HZQw1lPAgB6z7LNgA==} cpu: [x64] os: [linux] libc: [musl] + '@rspack/binding-linux-x64-musl@2.3.3': + resolution: {integrity: sha512-4E4OJodrmsS52zkSAWShG/F07etr0OG4oSrIN+/2BBgc0qR2wwu2T+rAs308IL3lbywlS+J+cynrRcsSFMD+Kg==} + cpu: [x64] + os: [linux] + libc: [musl] + '@rspack/binding-wasm32-wasi@2.3.2': resolution: {integrity: sha512-es9ts6uw29/JNd5lZcb5bviCZYgUf1W6TAnbZB1HQjJvh7+DPYtD+27tLKzpSjlkqkPfIWyzNnR4aM9NZWoFrA==} cpu: [wasm32] + '@rspack/binding-wasm32-wasi@2.3.3': + resolution: {integrity: sha512-AhlsPjW31TGP8N+J7OmbCPaamARUl+OQNiT3xo0PL5Dz5oMm+bEfYLostpehKyy8MNDrmJcY97M9pDb5MDMA0w==} + cpu: [wasm32] + '@rspack/binding-win32-arm64-msvc@2.3.2': resolution: {integrity: sha512-nAzwd0tslZF8vUeYYUWrxrulfB+ZInCT+jsUNq3AoH3D4fQRRq327omaxOD0ngtHtiiX/mwdmobNlLBHNgZ+RA==} cpu: [arm64] os: [win32] + '@rspack/binding-win32-arm64-msvc@2.3.3': + resolution: {integrity: sha512-Zqbj7GBPtkJ8GlUKAjFgvmOxKkQwjfS3XfjwGBcmoIAUb4IxUsmMqvi+gfKrvI45SjYVFZaJnTpOJw6GL79K+Q==} + cpu: [arm64] + os: [win32] + '@rspack/binding-win32-ia32-msvc@2.3.2': resolution: {integrity: sha512-yihZFNqOHwZd0I/z3MphJy/l5iNvuYsG0Gv3VuuqIgxZX4yS2DokqpDaWf2DnrZxB3yGSBt+IqZWQg/qzITBoA==} cpu: [ia32] os: [win32] + '@rspack/binding-win32-ia32-msvc@2.3.3': + resolution: {integrity: sha512-sJJmbrdzH6kI48mCsUu5a2+BzEktLmHrHUmWGkAPAi0zhi4anA7sOdS1+uERbkkd/XAzs0bdn3JXyT2djY+3IA==} + cpu: [ia32] + os: [win32] + '@rspack/binding-win32-x64-msvc@2.3.2': resolution: {integrity: sha512-I/aOF3eXODB+4zjiSSf5KXxQG4NeNoeyYOOmRyxQxdPU9/yjCSBKrKpcS6ZerK2DCYdl5V6+mwO50E25TvpVXg==} cpu: [x64] os: [win32] + '@rspack/binding-win32-x64-msvc@2.3.3': + resolution: {integrity: sha512-1r3wxV1pBNykqpbEbZWqcrZd13PKLq0e7Ku6qv8IGKKeftuf3RUxTkeM5AzppGMGEIA9sw8mRdN7NvEXxqLLxw==} + cpu: [x64] + os: [win32] + '@rspack/binding@2.3.2': resolution: {integrity: sha512-JlzyN4N6sRykZVwEFz3Kb8IsrTg8mlbNd/AqVmVyqr35Pg7OvxelTcYRL/Dpb2IMhmfpbzYbFigHyXS2CzibVQ==} + '@rspack/binding@2.3.3': + resolution: {integrity: sha512-wwF++36a3rqYi0G9zj+rUavn/GIMzbzXehelGS1jkYeKPHyPXrVYwRHqwEKNKMD9z+FdW4YJKQcfFkPlHEiwUg==} + + '@rspack/cli@2.3.3': + resolution: {integrity: sha512-9JmGVKBbeS0OAZyS+OlcHDVVCO0fCSAkrQmCOweXDlVaqOw4C/b0BT0YZG95bUa3BOht98dbGGIwqBrm4//ipQ==} + hasBin: true + peerDependencies: + '@rspack/core': ^2.3.0-0 + '@rspack/dev-server': ^2.0.0-0 + peerDependenciesMeta: + '@rspack/dev-server': + optional: true + '@rspack/core@2.3.2': resolution: {integrity: sha512-1gnot46X+O6z1qtnMw7KAFSuNDTaybn+I5rc1o0czwmRu80wbXNTCtPRstwmeQOuUU6tp5gYFRTIPrFH1YUxaQ==} engines: {node: ^20.19.0 || >=22.12.0} @@ -438,6 +694,37 @@ packages: '@swc/helpers': optional: true + '@rspack/core@2.3.3': + resolution: {integrity: sha512-stAYr0SXf+ZFXFsWTv+Ljxoj/nQs2p7gX9V1kBwlO2IXlRAAhabLONYibT3ZeEGybx3kowrs7uJkcOQsuHgghw==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 + '@swc/helpers': ^0.5.23 + peerDependenciesMeta: + '@module-federation/runtime-tools': + optional: true + '@swc/helpers': + optional: true + + '@rspack/dev-middleware@2.0.6': + resolution: {integrity: sha512-Rcx7dlDZQ9ddUJGuutFvnSeAKl+ZOc1fnC3htibs8yew3zMD9VgvSUe4MAwEn94Gb390l5heA+s/j5KhoSG5MQ==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@rspack/core': ^2.0.0 + peerDependenciesMeta: + '@rspack/core': + optional: true + + '@rspack/dev-server@2.2.2': + resolution: {integrity: sha512-pK4V9YJW8dkfjy6WYJ2T6DrPkcIn2yjA1HiaU146141j8UCxHok5lsplyqudLzerOhvwqMrNFmnsuXLnFbfn4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@rspack/core': ^2.0.0 + selfsigned: ^5.0.0 + peerDependenciesMeta: + selfsigned: + optional: true + '@rstackjs/cli-darwin-arm64@0.9.1': resolution: {integrity: sha512-apUQklMrSR+2ytWI/ksWzSeJvgsOYs3/tphnGTZrUrMhbrv4OLA4dmKNuS+2VLWRN3bTBDKVzFjxulzoigm73A==} engines: {node: ^20.19.0 || >=22.12.0} @@ -547,6 +834,59 @@ packages: '@rstest/core': ^0.12.0 playwright: ^1.49.1 + '@solidjs/babel-plugin@2.0.0': + resolution: {integrity: sha512-ucX1GQofDDbu+S7d12h3H2lUARagSleaY/GQ+2sG2EthAMkqBXeX92hhkHVJPK+KtiJeCXQxdzfvKhFCzudirQ==} + peerDependencies: + '@babel/core': ^7.20.12 || ^8.0.0 + '@tsrx/core': 0.1.63 + peerDependenciesMeta: + '@tsrx/core': + optional: true + + '@solidjs/compiler-darwin-arm64@2.0.0': + resolution: {integrity: sha512-pPHERRXgCcsfCsaC8sgK94uVlp4WGUcHTfMeBiAfme2amQ7vFn7dpjSD3TIVKY4jeYQTKjIKOYP0c5mqIR1LeA==} + cpu: [arm64] + os: [darwin] + + '@solidjs/compiler-darwin-x64@2.0.0': + resolution: {integrity: sha512-Ndwy+pQs8v6BIfaAbQ+weu9HGBTM40HFCyu0XV2qX7U5XC+o+3fc4O6+8ZZyUzl+qvT6XU+wh2bQ6MI2lV+KBQ==} + cpu: [x64] + os: [darwin] + + '@solidjs/compiler-linux-arm64-gnu@2.0.0': + resolution: {integrity: sha512-H/R9SUmuqd4P/IuuXTlRM1LhgUWe2EjLP3iMUo+L4IO1rmOSqfMUZp9h52eQnDsOdoIZCaKsw+b0qC5WooxDlg==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@solidjs/compiler-linux-x64-gnu@2.0.0': + resolution: {integrity: sha512-gafr9+2bP2sv2hRAvDgzab0mpQi4MiyWrie9bfYjadsK7qZKJBeMzEQCLNd4dTYlgirCj6Frzu2pfET7+ZUyNQ==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@solidjs/compiler-wasm32-wasi@2.0.0': + resolution: {integrity: sha512-JnF21DJ/jx5fghYKIB6ANihHMM4aWg4JFe5pFLGDvqSeURZJdJGjwyyxOv3siEMUdkBzVGHXotTsviTcRyB5hQ==} + engines: {node: '>=14.0.0'} + + '@solidjs/compiler-win32-x64-msvc@2.0.0': + resolution: {integrity: sha512-RkiUXt/LmJ1lk1fECa/iDVGCOv3UiwW5ocZgkhpayUviTSrceFjFHhiM9sFXq0at3kHI7Z8awN6zTaF5IStDAQ==} + cpu: [x64] + os: [win32] + + '@solidjs/compiler@2.0.0': + resolution: {integrity: sha512-Spgqz1+eojQ2pDl4yajnajIjX/kSusjTK/6mC6Fm7sAZ3YBI0yP4/epRR1hV08TU3YAH4xLBmZ6wjb1zC134Sw==} + + '@solidjs/signals@2.0.0': + resolution: {integrity: sha512-jrcT6XTVvsYRpesRp0At/mSUnsWr6jiprK8C93Oat56B8n7X9BMSe58Rxl6qSZUhBN0L+sxm8GzeO7HdhBXvDw==} + engines: {node: '>=22.12.0'} + + '@solidjs/web@2.0.0': + resolution: {integrity: sha512-R0+JMCD6ukEXaID/sH5PVQe9bCIN9pRzJry+F6Sb6YvtlkAp9DEyVI7AeZYiV0cd6TSL98kpbCyLDiZnaAKGrA==} + engines: {node: '>=22.12.0'} + peerDependencies: + solid-js: ^2.0.0 + '@swc-next/decoder@0.6.1': resolution: {integrity: sha512-ut8hg4qHuTuwGev9ILvjPvoCfAo5ij0MqfM/S8rNfFA3fnnV/itm6lhG/eTOd8SDE5ej1pWKZfe2YZ4KI6mxuA==} @@ -640,6 +980,18 @@ packages: '@tybys/wasm-util@0.10.3': resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==} + '@types/babel__core@7.20.5': + resolution: {integrity: sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==} + + '@types/babel__generator@7.27.0': + resolution: {integrity: sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==} + + '@types/babel__template@7.4.4': + resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==} + + '@types/babel__traverse@7.28.0': + resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} + '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} @@ -773,9 +1125,84 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} + baseline-browser-mapping@2.11.38: + resolution: {integrity: sha512-rMgy5YW7x28SMfXHLlVZDBqlWzYZ0x2rVR/6FWrNBF0chjigARK1H6nM0hKA1Um3kPOlkQFVtjJs00d2N1ezuw==} + engines: {node: '>=6.0.0'} + hasBin: true + + browserslist@4.29.6: + resolution: {integrity: sha512-CmVVIQ3RVc5HxYEc9X84GvxK/C8C1wH8TlKAiO7uTxF8PDwt7r8t9Qk3J9NkMOVzX5O/HbLv3yzxZg9HPrnI9w==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + caniuse-lite@1.0.30001826: + resolution: {integrity: sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==} + cjs-module-lexer@2.3.0: resolution: {integrity: sha512-lmNyBzi6iYiqyrExTctfmjd8tInx+dHu9PBomTfH5RXS53c27JMFJgzNv5TyAnm3PgGf+MLy0+Ws41/HlVxdKQ==} + convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + + csstype@3.2.4: + resolution: {integrity: sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==} + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + electron-to-chromium@1.5.487: + resolution: {integrity: sha512-qWotOhQYeYEj+DK4+Y+cfPj44qiC6ETIiWtJLfmDJydED2BJJ7loPA4SfBbbrMI6X/X3tryJgxnY9nxsO545Zw==} + + entities@6.0.1: + resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} + engines: {node: '>=0.12'} + + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + + gensync@1.0.0-beta.2: + resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} + engines: {node: '>=6.9.0'} + + html-entities@2.3.3: + resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==} + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + + json5@2.2.3: + resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==} + engines: {node: '>=6'} + hasBin: true + + lru-cache@5.1.1: + resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + node-releases@2.0.64: + resolution: {integrity: sha512-zAPCKqMcnqs2nGy6nlkm7JduFseiBJy3EXHGLh+8pFR+TxGCBxxiEN21+UROU5CKwX/f4TlUcYjiM+vs/tsyxw==} + engines: {node: '>=18'} + + parse5@7.3.0: + resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + playwright-core@1.65.0: resolution: {integrity: sha512-vNSKgH6YqtN7cdT/L334zo0a+YwkrpicyrHJlWWPIm/Q+Nn2SWInil01oT0mbu96U4GgoRtCYQD9CzJQgju+lA==} engines: {node: '>=20'} @@ -814,6 +1241,24 @@ packages: '@rspress/core': optional: true + semver@6.3.2: + resolution: {integrity: sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==} + hasBin: true + + seroval-plugins@1.8.0: + resolution: {integrity: sha512-96vBb12rDvPPwdKUgWw1op3fGq8AVBFOr0IllbnM72yR5J9WWXF18cQ4g1XfDO7HCyh2dt70P3XdtyRayP8FWg==} + engines: {node: '>=20'} + peerDependencies: + seroval: ^1.8.0 + + seroval@1.8.1: + resolution: {integrity: sha512-7z9x1flFYfZBz+LfDkXNfm5UIhZJ/97ASaV8Q1wctoVkeqVfv+tLPsWebeMXBNw6XprvwxDE5wC5Ylqmr+iSrA==} + engines: {node: '>=20'} + + solid-js@2.0.0: + resolution: {integrity: sha512-9zN4uH2OQeQAYbF4BmIzoaa+L5Hb8Dp6kkP6ZXobHQ1FZVICdmzREPDVDBJY7umzdAE8D6zbFfWhxGtagkyslA==} + engines: {node: '>=22.12.0'} + tinypool@2.2.0: resolution: {integrity: sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ==} engines: {node: ^20.0.0 || >=22.0.0} @@ -829,6 +1274,15 @@ packages: undici-types@7.24.6: resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} + update-browserslist-db@1.4.0: + resolution: {integrity: sha512-WPJuOnjI9FWDct4fB+ej4Mz8opLaw5CDcZ2t44tFZ0vIQVYWzBhWR3mkixuUj/A7+vY4V9+ApOZ2YYLwdgq46w==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + yallist@3.1.1: + resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} + snapshots: '@ast-grep/napi-darwin-arm64@0.51.1': @@ -870,22 +1324,175 @@ snapshots: '@ast-grep/napi-win32-ia32-msvc': 0.51.1 '@ast-grep/napi-win32-x64-msvc': 0.51.1 + '@babel/code-frame@7.29.7': + dependencies: + '@babel/helper-validator-identifier': 7.29.7 + js-tokens: 4.0.0 + picocolors: 1.1.1 + + '@babel/compat-data@7.29.7': {} + + '@babel/core@7.29.13': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.14 + '@babel/helper-compilation-targets': 7.29.13 + '@babel/helper-module-transforms': 7.29.14(@babel/core@7.29.13) + '@babel/helpers': 7.29.14 + '@babel/parser': 7.29.14 + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.14 + '@babel/types': 7.29.14 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.3 + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.2 + transitivePeerDependencies: + - supports-color + + '@babel/generator@7.29.14': + dependencies: + '@babel/parser': 7.29.14 + '@babel/types': 7.29.14 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + jsesc: 3.1.0 + + '@babel/helper-compilation-targets@7.29.13': + dependencies: + '@babel/compat-data': 7.29.7 + '@babel/helper-validator-option': 7.29.7 + browserslist: 4.29.6 + lru-cache: 5.1.1 + semver: 6.3.2 + + '@babel/helper-globals@7.29.7': {} + + '@babel/helper-module-imports@7.18.6': + dependencies: + '@babel/types': 7.29.14 + + '@babel/helper-module-imports@7.29.7': + dependencies: + '@babel/traverse': 7.29.14 + '@babel/types': 7.29.14 + transitivePeerDependencies: + - supports-color + + '@babel/helper-module-transforms@7.29.14(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13 + '@babel/helper-module-imports': 7.29.7 + '@babel/helper-validator-identifier': 7.29.7 + '@babel/traverse': 7.29.14 + transitivePeerDependencies: + - supports-color + + '@babel/helper-plugin-utils@7.29.7': {} + + '@babel/helper-string-parser@7.29.14': {} + + '@babel/helper-validator-identifier@7.29.7': {} + + '@babel/helper-validator-option@7.29.7': {} + + '@babel/helpers@7.29.14': + dependencies: + '@babel/template': 7.29.7 + '@babel/types': 7.29.14 + + '@babel/parser@7.29.14': + dependencies: + '@babel/types': 7.29.14 + + '@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13 + '@babel/helper-plugin-utils': 7.29.7 + + '@babel/template@7.29.7': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/parser': 7.29.14 + '@babel/types': 7.29.14 + + '@babel/traverse@7.29.14': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.14 + '@babel/helper-globals': 7.29.7 + '@babel/parser': 7.29.14 + '@babel/template': 7.29.7 + '@babel/types': 7.29.14 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + '@babel/types@7.29.14': + dependencies: + '@babel/helper-string-parser': 7.29.14 + '@babel/helper-validator-identifier': 7.29.7 + + '@emnapi/core@1.11.3': + dependencies: + '@emnapi/wasi-threads': 1.2.3 + tslib: 2.8.1 + optional: true + '@emnapi/core@2.0.0-beta.3': dependencies: '@emnapi/wasi-threads': 2.2.0 tslib: 2.8.1 optional: true + '@emnapi/runtime@1.11.3': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/runtime@2.0.0-beta.3': dependencies: tslib: 2.8.1 optional: true + '@emnapi/wasi-threads@1.2.3': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/wasi-threads@2.2.0': dependencies: tslib: 2.8.1 optional: true + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/remapping@2.3.5': + dependencies: + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/resolve-uri@3.1.3': {} + + '@jridgewell/sourcemap-codec@1.6.0': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.3 + '@jridgewell/sourcemap-codec': 1.6.0 + + '@napi-rs/wasm-runtime@1.2.7(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': + dependencies: + '@emnapi/core': 1.11.3 + '@emnapi/runtime': 1.11.3 + '@tybys/wasm-util': 0.10.3 + optional: true + '@napi-rs/wasm-runtime@1.2.7(@emnapi/core@2.0.0-beta.3)(@emnapi/runtime@2.0.0-beta.3)': dependencies: '@emnapi/core': 2.0.0-beta.3 @@ -948,33 +1555,63 @@ snapshots: '@rspack/binding-darwin-arm64@2.3.2': optional: true + '@rspack/binding-darwin-arm64@2.3.3': + optional: true + '@rspack/binding-darwin-x64@2.3.2': optional: true + '@rspack/binding-darwin-x64@2.3.3': + optional: true + '@rspack/binding-linux-arm64-gnu@2.3.2': optional: true + '@rspack/binding-linux-arm64-gnu@2.3.3': + optional: true + '@rspack/binding-linux-arm64-musl@2.3.2': optional: true + '@rspack/binding-linux-arm64-musl@2.3.3': + optional: true + '@rspack/binding-linux-ppc64-gnu@2.3.2': optional: true + '@rspack/binding-linux-ppc64-gnu@2.3.3': + optional: true + '@rspack/binding-linux-riscv64-gnu@2.3.2': optional: true + '@rspack/binding-linux-riscv64-gnu@2.3.3': + optional: true + '@rspack/binding-linux-riscv64-musl@2.3.2': optional: true + '@rspack/binding-linux-riscv64-musl@2.3.3': + optional: true + '@rspack/binding-linux-s390x-gnu@2.3.2': optional: true + '@rspack/binding-linux-s390x-gnu@2.3.3': + optional: true + '@rspack/binding-linux-x64-gnu@2.3.2': optional: true + '@rspack/binding-linux-x64-gnu@2.3.3': + optional: true + '@rspack/binding-linux-x64-musl@2.3.2': optional: true + '@rspack/binding-linux-x64-musl@2.3.3': + optional: true + '@rspack/binding-wasm32-wasi@2.3.2': dependencies: '@emnapi/core': 2.0.0-beta.3 @@ -982,15 +1619,31 @@ snapshots: '@napi-rs/wasm-runtime': 1.2.7(@emnapi/core@2.0.0-beta.3)(@emnapi/runtime@2.0.0-beta.3) optional: true + '@rspack/binding-wasm32-wasi@2.3.3': + dependencies: + '@emnapi/core': 2.0.0-beta.3 + '@emnapi/runtime': 2.0.0-beta.3 + '@napi-rs/wasm-runtime': 1.2.7(@emnapi/core@2.0.0-beta.3)(@emnapi/runtime@2.0.0-beta.3) + optional: true + '@rspack/binding-win32-arm64-msvc@2.3.2': optional: true + '@rspack/binding-win32-arm64-msvc@2.3.3': + optional: true + '@rspack/binding-win32-ia32-msvc@2.3.2': optional: true + '@rspack/binding-win32-ia32-msvc@2.3.3': + optional: true + '@rspack/binding-win32-x64-msvc@2.3.2': optional: true + '@rspack/binding-win32-x64-msvc@2.3.3': + optional: true + '@rspack/binding@2.3.2': optionalDependencies: '@rspack/binding-darwin-arm64': 2.3.2 @@ -1008,12 +1661,50 @@ snapshots: '@rspack/binding-win32-ia32-msvc': 2.3.2 '@rspack/binding-win32-x64-msvc': 2.3.2 + '@rspack/binding@2.3.3': + optionalDependencies: + '@rspack/binding-darwin-arm64': 2.3.3 + '@rspack/binding-darwin-x64': 2.3.3 + '@rspack/binding-linux-arm64-gnu': 2.3.3 + '@rspack/binding-linux-arm64-musl': 2.3.3 + '@rspack/binding-linux-ppc64-gnu': 2.3.3 + '@rspack/binding-linux-riscv64-gnu': 2.3.3 + '@rspack/binding-linux-riscv64-musl': 2.3.3 + '@rspack/binding-linux-s390x-gnu': 2.3.3 + '@rspack/binding-linux-x64-gnu': 2.3.3 + '@rspack/binding-linux-x64-musl': 2.3.3 + '@rspack/binding-wasm32-wasi': 2.3.3 + '@rspack/binding-win32-arm64-msvc': 2.3.3 + '@rspack/binding-win32-ia32-msvc': 2.3.3 + '@rspack/binding-win32-x64-msvc': 2.3.3 + + '@rspack/cli@2.3.3(@rspack/core@2.3.3(@swc/helpers@0.5.24))(@rspack/dev-server@2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24)))': + dependencies: + '@rspack/core': 2.3.3(@swc/helpers@0.5.24) + optionalDependencies: + '@rspack/dev-server': 2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24)) + '@rspack/core@2.3.2(@swc/helpers@0.5.24)': dependencies: '@rspack/binding': 2.3.2 optionalDependencies: '@swc/helpers': 0.5.24 + '@rspack/core@2.3.3(@swc/helpers@0.5.24)': + dependencies: + '@rspack/binding': 2.3.3 + optionalDependencies: + '@swc/helpers': 0.5.24 + + '@rspack/dev-middleware@2.0.6(@rspack/core@2.3.3(@swc/helpers@0.5.24))': + optionalDependencies: + '@rspack/core': 2.3.3(@swc/helpers@0.5.24) + + '@rspack/dev-server@2.2.2(@rspack/core@2.3.3(@swc/helpers@0.5.24))': + dependencies: + '@rspack/core': 2.3.3(@swc/helpers@0.5.24) + '@rspack/dev-middleware': 2.0.6(@rspack/core@2.3.3(@swc/helpers@0.5.24)) + '@rstackjs/cli-darwin-arm64@0.9.1': optional: true @@ -1069,6 +1760,55 @@ snapshots: '@rstest/core': 0.12.6 playwright: 1.65.0 + '@solidjs/babel-plugin@2.0.0(@babel/core@7.29.13)': + dependencies: + '@babel/core': 7.29.13 + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.13) + '@babel/types': 7.29.14 + html-entities: 2.3.3 + parse5: 7.3.0 + + '@solidjs/compiler-darwin-arm64@2.0.0': + optional: true + + '@solidjs/compiler-darwin-x64@2.0.0': + optional: true + + '@solidjs/compiler-linux-arm64-gnu@2.0.0': + optional: true + + '@solidjs/compiler-linux-x64-gnu@2.0.0': + optional: true + + '@solidjs/compiler-wasm32-wasi@2.0.0': + dependencies: + '@emnapi/core': 1.11.3 + '@emnapi/runtime': 1.11.3 + '@napi-rs/wasm-runtime': 1.2.7(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) + optional: true + + '@solidjs/compiler-win32-x64-msvc@2.0.0': + optional: true + + '@solidjs/compiler@2.0.0': + optionalDependencies: + '@solidjs/compiler-darwin-arm64': 2.0.0 + '@solidjs/compiler-darwin-x64': 2.0.0 + '@solidjs/compiler-linux-arm64-gnu': 2.0.0 + '@solidjs/compiler-linux-x64-gnu': 2.0.0 + '@solidjs/compiler-wasm32-wasi': 2.0.0 + '@solidjs/compiler-win32-x64-msvc': 2.0.0 + + '@solidjs/signals@2.0.0': {} + + '@solidjs/web@2.0.0(solid-js@2.0.0)': + dependencies: + csstype: 3.2.4 + seroval: 1.8.1 + seroval-plugins: 1.8.0(seroval@1.8.1) + solid-js: 2.0.0 + '@swc-next/decoder@0.6.1': dependencies: '@swc-next/types': 0.6.1 @@ -1140,6 +1880,27 @@ snapshots: tslib: 2.8.1 optional: true + '@types/babel__core@7.20.5': + dependencies: + '@babel/parser': 7.29.14 + '@babel/types': 7.29.14 + '@types/babel__generator': 7.27.0 + '@types/babel__template': 7.4.4 + '@types/babel__traverse': 7.28.0 + + '@types/babel__generator@7.27.0': + dependencies: + '@babel/types': 7.29.14 + + '@types/babel__template@7.4.4': + dependencies: + '@babel/parser': 7.29.14 + '@babel/types': 7.29.14 + + '@types/babel__traverse@7.28.0': + dependencies: + '@babel/types': 7.29.14 + '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 @@ -1213,8 +1974,58 @@ snapshots: assertion-error@2.0.1: {} + baseline-browser-mapping@2.11.38: {} + + browserslist@4.29.6: + dependencies: + baseline-browser-mapping: 2.11.38 + caniuse-lite: 1.0.30001826 + electron-to-chromium: 1.5.487 + node-releases: 2.0.64 + update-browserslist-db: 1.4.0(browserslist@4.29.6) + + caniuse-lite@1.0.30001826: {} + cjs-module-lexer@2.3.0: {} + convert-source-map@2.0.0: {} + + csstype@3.2.4: {} + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + electron-to-chromium@1.5.487: {} + + entities@6.0.1: {} + + escalade@3.2.0: {} + + gensync@1.0.0-beta.2: {} + + html-entities@2.3.3: {} + + js-tokens@4.0.0: {} + + jsesc@3.1.0: {} + + json5@2.2.3: {} + + lru-cache@5.1.1: + dependencies: + yallist: 3.1.1 + + ms@2.1.3: {} + + node-releases@2.0.64: {} + + parse5@7.3.0: + dependencies: + entities: 6.0.1 + + picocolors@1.1.1: {} + playwright-core@1.65.0: {} playwright@1.65.0: @@ -1263,6 +2074,20 @@ snapshots: - jsdom - typescript + semver@6.3.2: {} + + seroval-plugins@1.8.0(seroval@1.8.1): + dependencies: + seroval: 1.8.1 + + seroval@1.8.1: {} + + solid-js@2.0.0: + dependencies: + '@solidjs/signals': 2.0.0 + seroval: 1.8.1 + seroval-plugins: 1.8.0(seroval@1.8.1) + tinypool@2.2.0: {} tslib@2.8.1: @@ -1292,3 +2117,11 @@ snapshots: '@typescript/typescript-win32-x64': 7.0.2 undici-types@7.24.6: {} + + update-browserslist-db@1.4.0(browserslist@4.29.6): + dependencies: + browserslist: 4.29.6 + escalade: 3.2.0 + picocolors: 1.1.1 + + yallist@3.1.1: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index be1ed93..67f18b8 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -17,3 +17,9 @@ minimumReleaseAgeExclude: - 'rsbuild-plugin-*' - rstack - typescript + +catalog: + '@rspack/core': '~2.3.3' + '@rspack/dev-server': '^2.2.2' + '@solidjs/web': '^2.0.0' + solid-js: '^2.0.0' diff --git a/rstack.config.ts b/rstack.config.ts index 41566b2..ea12ada 100644 --- a/rstack.config.ts +++ b/rstack.config.ts @@ -2,6 +2,9 @@ import { define } from 'rstack'; define.lib({ + source: { + entry: { index: './src/index.ts', refresh: './src/refresh.ts' }, + }, dts: true, syntax: 'es2023', }); diff --git a/src/helpers.ts b/src/helpers.ts new file mode 100644 index 0000000..96eac66 --- /dev/null +++ b/src/helpers.ts @@ -0,0 +1,38 @@ +import type { RawSourceMap } from '@rspack/core'; +import remapping from '@jridgewell/remapping'; + +const DEFAULT_SOLID_SCRIPT_REGEX = /\.(?:jsx|tsx)$/i; + +// Native transforms infer the parser from a standard JSX/TSX extension. +export const getTransformFilename = (filename: string): string => + DEFAULT_SOLID_SCRIPT_REGEX.test(filename) + ? filename + : `${filename}${/\.[mc]?tsx$/i.test(filename) ? '.tsx' : '.jsx'}`; + +export const normalizeSourceMap = ( + sourceMap: RawSourceMap | string | null | undefined, +): RawSourceMap | undefined => + typeof sourceMap === 'string' + ? (JSON.parse(sourceMap) as RawSourceMap) + : (sourceMap ?? undefined); + +export const mergeSourceMaps = ( + sourceMap: RawSourceMap | undefined, + generatedMap: string | null | undefined, + filename: string, +): RawSourceMap | undefined => { + if (!generatedMap) { + return sourceMap; + } + + const parsedMap = JSON.parse(generatedMap) as RawSourceMap; + parsedMap.sources = [filename]; + if (!sourceMap) { + return parsedMap; + } + + return remapping( + [parsedMap, sourceMap] as Parameters[0], + () => null, + ) as RawSourceMap; +}; diff --git a/src/index.ts b/src/index.ts index f2173b3..e7c8ccd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,16 +1,92 @@ -import type { RsbuildPlugin } from '@rsbuild/core'; +import { createRequire } from 'node:module'; +import type { TransformOptions } from '@babel/core'; +import type { LoaderDefinition } from '@rspack/core'; +import type { TransformOptions as NativeTransformOptions } from '@solidjs/compiler'; +import { + getTransformFilename, + mergeSourceMaps, + normalizeSourceMap, +} from './helpers.js'; +import type { SolidCompiler, SolidPresetOptions } from './types.js'; -export type PluginExampleOptions = { - foo?: string; - bar?: boolean; +export type { SolidCompiler, SolidPresetOptions } from './types.js'; + +const require = createRequire(import.meta.url); +const TSX_REGEX = /\.tsx$/i; + +export type SolidLoaderOptions = { + compiler?: SolidCompiler; + solid?: SolidPresetOptions; + scriptRegex?: RegExp; + decoratorVersion?: 'legacy' | '2022-03' | '2023-11'; + transformFilename?: string; }; -export const pluginExample = ( - options: PluginExampleOptions = {}, -): RsbuildPlugin => ({ - name: 'plugin-example', +const solidLoader: LoaderDefinition = async function ( + source, + sourceMap, +): Promise { + const callback = this.async(); + const options = this.getOptions(); + const sourceFilename = this.resourcePath; + const resourceFilename = options.transformFilename ?? sourceFilename; + + if (options.scriptRegex && !options.scriptRegex.test(resourceFilename)) { + callback(null, source, sourceMap); + return; + } + + const filename = getTransformFilename(resourceFilename); + const { compiler = 'native', decoratorVersion } = options; + const solid = { dev: this.mode === 'development', ...options.solid }; + const inputSourceMap = normalizeSourceMap(sourceMap); + + try { + if (compiler === 'babel') { + const { transformAsync } = await import('@babel/core'); + const parserPlugins: NonNullable< + NonNullable['plugins'] + > = [decoratorVersion === 'legacy' ? 'decorators-legacy' : 'decorators']; + + parserPlugins.push('jsx'); + + if (TSX_REGEX.test(filename)) { + parserPlugins.push('typescript'); + } + + const result = await transformAsync(source, { + filename, + sourceFileName: sourceFilename, + sourceMaps: this.sourceMap || Boolean(sourceMap), + inputSourceMap, + ast: false, + babelrc: false, + configFile: false, + parserOpts: { + plugins: parserPlugins, + }, + plugins: [[require.resolve('@solidjs/babel-plugin'), solid]], + }); + + callback(null, result?.code ?? source, result?.map ?? inputSourceMap); + return; + } + + const { transformAsync } = await import('@solidjs/compiler'); + const result = await transformAsync(source, { + ...solid, + filename, + sourceMap: this.sourceMap || Boolean(sourceMap), + } as NativeTransformOptions); + + callback( + null, + result.code, + mergeSourceMaps(inputSourceMap, result.map, sourceFilename), + ); + } catch (error) { + callback(error instanceof Error ? error : new Error(String(error))); + } +}; - setup() { - console.log('Hello Rsbuild!', options); - }, -}); +export default solidLoader; diff --git a/src/refresh.ts b/src/refresh.ts new file mode 100644 index 0000000..0379cab --- /dev/null +++ b/src/refresh.ts @@ -0,0 +1,50 @@ +import { transformRefreshAsync } from '@solidjs/compiler'; +import type { LoaderDefinition } from '@rspack/core'; +import { + getTransformFilename, + mergeSourceMaps, + normalizeSourceMap, +} from './helpers.js'; + +const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/; + +export type SolidRefreshLoaderOptions = { + granular?: boolean; +}; + +const solidRefreshLoader: LoaderDefinition = + async function (source, sourceMap): Promise { + const callback = this.async(); + const { granular } = this.getOptions(); + + if (NODE_MODULES_REGEX.test(this.resourcePath)) { + callback(null, source, sourceMap); + return; + } + + try { + const result = await transformRefreshAsync(source, { + filename: getTransformFilename(this.resourcePath), + bundler: 'standard', + fixRender: true, + ...(typeof granular === 'boolean' ? { granular } : {}), + jsx: false, + importSource: 'solid-js/refresh', + sourceMap: this.sourceMap || Boolean(sourceMap), + }); + + callback( + null, + result.code, + mergeSourceMaps( + normalizeSourceMap(sourceMap), + result.map, + this.resourcePath, + ), + ); + } catch (error) { + callback(error instanceof Error ? error : new Error(String(error))); + } + }; + +export default solidRefreshLoader; diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..996c02b --- /dev/null +++ b/src/types.ts @@ -0,0 +1,145 @@ +import type { TransformOptions } from '@solidjs/compiler'; + +export type SolidCompiler = 'babel' | 'native'; + +/** + * Options passed to the Solid JSX compiler. + * + * The option types are aligned with `@solidjs/compiler` and adjusted + * for `@solidjs/babel-plugin`. + * + * https://github.com/solidjs/solid/blob/next/packages/compiler/types.d.ts + * https://github.com/solidjs/solid/tree/next/packages/babel-plugin + */ +export type SolidPresetOptions = { + /** + * The runtime module from which compiler helpers are imported. + * @default '@solidjs/web' + */ + moduleName?: string; + /** + * Whether to generate development-only runtime checks and metadata. + * Defaults to true in Rspack development mode. + */ + dev?: boolean; + /** + * Include component names, binding names, and source locations in compiler output. + * Defaults to the compiler's `dev` setting. + */ + sourceNames?: TransformOptions['sourceNames']; + /** + * The output mode of the compiler. + * - `dom` generates DOM operations. + * - `ssr` generates HTML strings for server-side rendering. + * - `universal` generates output for a custom renderer. + * - `dynamic` routes configured native elements to the DOM renderer and + * uses the universal renderer as a fallback. + * + * @default 'dom' + */ + generate?: 'dom' | 'ssr' | 'universal' | 'dynamic'; + /** + * Whether to include hydration markers in the generated output. + * @default false + */ + hydratable?: boolean; + /** + * Whether to automatically delegate supported events. + * @default true + */ + delegateEvents?: boolean; + /** + * Additional event names that should always use delegation. + * @default [] + */ + delegatedEvents?: string[]; + /** + * Whether to optimize simple boolean expressions and ternaries in JSX. + * @default true + */ + wrapConditionals?: boolean; + /** + * Whether to set the current render context on custom elements and slots. + * @default true + */ + contextToCustomElements?: boolean; + /** + * Component export names that should be recognized and automatically + * imported from the runtime module. + * @default `['For', 'Show', 'Switch', 'Match', 'Loading', 'Reveal', 'Portal', 'Repeat', 'Dynamic', 'Errored']` + */ + builtIns?: string[]; + /** + * The runtime helper used for reactive effect wrapping. + * Set to `false` to disable effect wrapping. + * @default 'effect' + */ + effectWrapper?: string | false; + /** + * The comment marker used to assert that an expression is static and does + * not need reactive wrapping. + * @default '@static' + */ + staticMarker?: string; + /** + * The runtime helper used to memoize derived expressions. + * Set to `false` to disable memo wrapping. + * @default 'memo' + */ + memoWrapper?: string | false; + /** + * Whether to validate HTML nesting in generated templates. + * @default true + */ + validate?: boolean; + /** + * Whether to omit unnecessary nested closing tags from template strings. + * More information: + * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates + * + * @default false + */ + omitNestedClosingTags?: boolean; + /** + * Whether to omit the final closing tag from template strings when safe. + * Disable this for compatibility with parsers that require explicit closing + * tags. + * + * @default true + */ + omitLastClosingTag?: boolean; + /** + * Whether to omit quotes around attribute values when safe. + * Disable this for compatibility with parsers that require quoted values. + * + * @default true + */ + omitQuotes?: boolean; + /** + * Whether quoted attributes may omit the following separator space. + * Set to `false` for strict HTML or SVG parsers. + * @default true + */ + omitAttributeSpacing?: boolean; + /** + * Whether to inline static style values into generated template strings. + * When disabled, style values are applied at runtime. + * @default true + */ + inlineStyles?: boolean; + /** + * Restrict JSX transformation to files whose `@jsxImportSource` pragma + * matches this value. Set to `false` to disable this check. + * @default false + */ + requireImportSource?: false | string; + /** + * Renderer configurations used by the `dynamic` output mode. + * @default [] + */ + renderers?: Array<{ + name: string; + moduleName?: string; + elements: string[]; + }>; +}; diff --git a/test/basic/index.test.ts b/test/basic/index.test.ts index d7bdd75..bd62840 100644 --- a/test/basic/index.test.ts +++ b/test/basic/index.test.ts @@ -1,40 +1,109 @@ +import { cp, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import { rspack } from '@rspack/core'; +import { RspackDevServer } from '@rspack/dev-server'; import { expect, test } from '@rstest/playwright'; -import { createRsbuild } from '@rsbuild/core'; -import { pluginExample } from '../../src'; import { getRandomPort } from '@rstackjs/test-utils'; +import playgroundConfig from '../../playground/rspack.config.mjs'; -test('should render page as expected', async ({ page }) => { - const rsbuild = await createRsbuild({ - cwd: import.meta.dirname, - rsbuildConfig: { - plugins: [pluginExample()], - server: { - port: await getRandomPort(), - }, - }, - }); - - const { server, urls } = await rsbuild.startDevServer(); +const playground = path.resolve(import.meta.dirname, '../../playground'); - await page.goto(urls[0]); - expect(await page.evaluate('window.test')).toBe(1); - - await server.close(); -}); - -test('should build succeed', async ({ page }) => { - const rsbuild = await createRsbuild({ - cwd: import.meta.dirname, - rsbuildConfig: { - plugins: [pluginExample()], - }, +for (const compiler of ['native', 'babel']) { + test(`renders typed SSR output with ${compiler}`, async () => { + const cwd = await mkdtemp(path.join(playground, 'test-temp-')); + try { + await writeFile( + path.join(cwd, 'app.tsx'), + ` + import { renderToString } from '@solidjs/web'; + const title: string = 'Hello'; + export const html = renderToString(() =>

{title}

); + `, + ); + await new Promise((resolve, reject) => { + rspack( + { + context: cwd, + mode: 'production', + target: 'node', + entry: './app.tsx', + devtool: 'source-map', + output: { + path: cwd, + filename: 'app.cjs', + library: { type: 'commonjs2' }, + }, + resolve: { conditionNames: ['solid', '...'] }, + module: { + rules: [ + { + test: /\.tsx$/, + use: [ + { + loader: 'builtin:swc-loader', + options: { detectSyntax: 'auto' }, + }, + { + loader: 'solid-loader', + options: { compiler, solid: { generate: 'ssr' } }, + }, + ], + }, + ], + }, + }, + (err, stats) => { + if (err) reject(err); + else if (stats?.hasErrors()) + reject(new Error(stats.toString({ all: false, errors: true }))); + else resolve(); + }, + ); + }); + const { html } = createRequire(import.meta.url)( + path.join(cwd, 'app.cjs'), + ); + expect(html).toBe('

Hello

'); + const map = JSON.parse( + await readFile(path.join(cwd, 'app.cjs.map'), 'utf8'), + ); + expect(map.sources).toContainEqual(expect.stringMatching(/app\.tsx$/)); + } finally { + await rm(cwd, { recursive: true, force: true }); + } }); +} - await rsbuild.build(); - const { server, urls } = await rsbuild.preview(); - - await page.goto(urls[0]); - expect(await page.evaluate('window.test')).toBe(1); - - await server.close(); +test('updates a component and preserves its parent state', async ({ page }) => { + const cwd = await mkdtemp(path.join(playground, 'test-temp-')); + try { + await cp(path.join(playground, 'src'), path.join(cwd, 'src'), { + recursive: true, + }); + const port = await getRandomPort(); + const compiler = rspack({ + ...playgroundConfig({}, { mode: 'development' }), + context: cwd, + }); + const server = new RspackDevServer( + { host: '127.0.0.1', port, hot: true }, + compiler, + ); + await server.start(); + try { + await page.goto(`http://127.0.0.1:${port}`); + const button = page.getByRole('button'); + await button.click(); + await expect(button).toHaveText('Count: 1'); + const file = path.join(cwd, 'src/Counter.tsx'); + const source = await readFile(file, 'utf8'); + await writeFile(file, source.replace('Count:', 'Updated:')); + await expect(button).toHaveText('Updated: 1'); + } finally { + await server.stop(); + } + } finally { + await rm(cwd, { recursive: true, force: true }); + } }); diff --git a/test/basic/src/index.js b/test/basic/src/index.js deleted file mode 100644 index 5482fa1..0000000 --- a/test/basic/src/index.js +++ /dev/null @@ -1 +0,0 @@ -window.test = 1; From 84c0d92e6ef8781a3b93f5ce7099051722ddc264 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 18 Nov 2026 21:17:54 +0800 Subject: [PATCH 2/2] chore: use a TypeScript Rspack config in the playground --- README.md | 12 ++++---- .../{rspack.config.mjs => rspack.config.ts} | 29 +++++++++---------- playground/tsconfig.json | 3 +- test/basic/index.test.ts | 2 +- 4 files changed, 24 insertions(+), 22 deletions(-) rename playground/{rspack.config.mjs => rspack.config.ts} (59%) diff --git a/README.md b/README.md index d73c964..4e25161 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,11 @@ pnpm add -D solid-loader Add the loader to the JSX rule in your Rspack config: -```js -// rspack.config.mjs -export default { +```ts +// rspack.config.ts +import { defineConfig } from '@rspack/cli'; + +export default defineConfig({ resolve: { extensions: ['.tsx', '.jsx', '.ts', '...'], conditionNames: ['solid', '...'], @@ -31,7 +33,7 @@ export default { }, ], }, -}; +}); ``` Rspack runs the loaders from right to left. Solid compiles JSX first, then SWC removes TypeScript types and lowers JavaScript syntax. If you already have an SWC rule for TSX, add `solid-loader` to that rule. For TypeScript projects, set `jsx` to `"preserve"` and `jsxImportSource` to `"@solidjs/web"` in `tsconfig.json`. @@ -52,7 +54,7 @@ For browser development builds with HMR enabled, add `development` to the resolv } ``` -Refresh generates per-component metadata by default. Set `options: { granular: false }` on the refresh rule to disable it. The [playground](./playground/rspack.config.mjs) shows the full configuration for development and production. +Refresh generates per-component metadata by default. Set `options: { granular: false }` on the refresh rule to disable it. The [playground](./playground/rspack.config.ts) shows the full configuration for development and production. ## Server-side rendering diff --git a/playground/rspack.config.mjs b/playground/rspack.config.ts similarity index 59% rename from playground/rspack.config.mjs rename to playground/rspack.config.ts index 2a80619..a56def8 100644 --- a/playground/rspack.config.mjs +++ b/playground/rspack.config.ts @@ -1,6 +1,9 @@ -import { HtmlRspackPlugin } from '@rspack/core'; +import { type Configuration, HtmlRspackPlugin } from '@rspack/core'; -export default (_env, { mode }) => { +export default ( + _env: unknown, + { mode }: Pick, +): Configuration => { const dev = mode === 'development'; const test = /\.[mc]?[jt]sx$/i; @@ -21,19 +24,15 @@ export default (_env, { mode }) => { 'solid-loader', ], }, - ...(dev - ? [ - { - test, - enforce: 'pre', - exclude: /node_modules/, - dependency: { not: 'url' }, - resourceQuery: { not: /[?&]raw(?:&|=|$)/ }, - with: { type: { not: 'text' } }, - loader: 'solid-loader/refresh', - }, - ] - : []), + dev && { + test, + enforce: 'pre', + exclude: /node_modules/, + dependency: { not: 'url' }, + resourceQuery: { not: /[?&]raw(?:&|=|$)/ }, + with: { type: { not: 'text' } }, + loader: 'solid-loader/refresh', + }, { descriptionData: { name: /^@solidjs\/web$/ }, parser: { importDynamic: false }, diff --git a/playground/tsconfig.json b/playground/tsconfig.json index 9a757a3..bd46cca 100644 --- a/playground/tsconfig.json +++ b/playground/tsconfig.json @@ -4,6 +4,7 @@ "target": "ES2020", "noEmit": true, "skipLibCheck": true, + "types": ["node"], "jsx": "preserve", "jsxImportSource": "@solidjs/web", "useDefineForClassFields": true, @@ -19,5 +20,5 @@ "noUnusedLocals": true, "noUnusedParameters": true }, - "include": ["src"] + "include": ["src", "rspack.config.ts"] } diff --git a/test/basic/index.test.ts b/test/basic/index.test.ts index bd62840..37abd1b 100644 --- a/test/basic/index.test.ts +++ b/test/basic/index.test.ts @@ -5,7 +5,7 @@ import { rspack } from '@rspack/core'; import { RspackDevServer } from '@rspack/dev-server'; import { expect, test } from '@rstest/playwright'; import { getRandomPort } from '@rstackjs/test-utils'; -import playgroundConfig from '../../playground/rspack.config.mjs'; +import playgroundConfig from '../../playground/rspack.config.ts'; const playground = path.resolve(import.meta.dirname, '../../playground');