From b2cd1970c4112c4783aa5e7592e725a3ba1c2eba Mon Sep 17 00:00:00 2001 From: yangxingyuan Date: Sat, 20 Jan 2024 15:36:12 +0800 Subject: [PATCH 1/2] feat: framework agnostic component preview solution --- .../plugin/doc/components/component.jsx | 2 - e2e/fixtures/plugin/doc/components/guide.mdx | 18 -- e2e/fixtures/plugin/doc/index.md | 9 - e2e/fixtures/plugin/doc/index.mdx | 13 ++ e2e/fixtures/plugin/package.json | 8 +- e2e/fixtures/plugin/rspress.config.ts | 1 + e2e/fixtures/plugin/tsconfig.json | 2 +- packages/plugin-preview/modern.config.ts | 5 + packages/plugin-preview/package.json | 14 +- packages/plugin-preview/src/codeToDemo.ts | 61 ++++- packages/plugin-preview/src/utils.ts | 3 +- packages/plugin-preview/tsconfig.json | 2 +- packages/runtime/tsconfig.json | 2 +- pnpm-lock.yaml | 218 ++++++++++++++---- 14 files changed, 273 insertions(+), 85 deletions(-) delete mode 100644 e2e/fixtures/plugin/doc/index.md create mode 100644 e2e/fixtures/plugin/doc/index.mdx diff --git a/e2e/fixtures/plugin/doc/components/component.jsx b/e2e/fixtures/plugin/doc/components/component.jsx index cd46eceff..41aa5c7ea 100644 --- a/e2e/fixtures/plugin/doc/components/component.jsx +++ b/e2e/fixtures/plugin/doc/components/component.jsx @@ -1,5 +1,3 @@ -import React from 'react'; - export default function HelloWorld() { return
Hello World
; } diff --git a/e2e/fixtures/plugin/doc/components/guide.mdx b/e2e/fixtures/plugin/doc/components/guide.mdx index 5f1a1c99e..8c0d02fad 100644 --- a/e2e/fixtures/plugin/doc/components/guide.mdx +++ b/e2e/fixtures/plugin/doc/components/guide.mdx @@ -1,19 +1 @@ # Guide - -```jsx -import React from 'react'; - -export default function HelloWorld() { - return
Hello
; -} -``` - -```jsx -import React from 'react'; - -export default function HelloWorld() { - return
World
; -} -``` - - diff --git a/e2e/fixtures/plugin/doc/index.md b/e2e/fixtures/plugin/doc/index.md deleted file mode 100644 index 6bd39fdba..000000000 --- a/e2e/fixtures/plugin/doc/index.md +++ /dev/null @@ -1,9 +0,0 @@ -# Hello World - -```jsx -import React from 'react'; - -export default function HelloWorld() { - return
Hello World
; -} -``` diff --git a/e2e/fixtures/plugin/doc/index.mdx b/e2e/fixtures/plugin/doc/index.mdx new file mode 100644 index 000000000..1e63495e9 --- /dev/null +++ b/e2e/fixtures/plugin/doc/index.mdx @@ -0,0 +1,13 @@ +# Hello World + +```jsx +export default function HelloWorld() { + return
这是 solidjs 渲染的结果
; +} +``` + +```jsx +export default function HelloWorld() { + return
这是 solidjs 渲染的结果
; +} +``` diff --git a/e2e/fixtures/plugin/package.json b/e2e/fixtures/plugin/package.json index c231adb6a..dff3f35f4 100644 --- a/e2e/fixtures/plugin/package.json +++ b/e2e/fixtures/plugin/package.json @@ -8,13 +8,13 @@ "preview": "rspress preview" }, "dependencies": { + "@rspress/plugin-playground": "workspace:*", + "@rspress/plugin-preview": "workspace:*", + "@rspress/shared": "workspace:*", "react": "^18", "react-dom": "^18", "react-transition-group": "4.4.5", - "rspress": "workspace:*", - "@rspress/shared": "workspace:*", - "@rspress/plugin-preview": "workspace:*", - "@rspress/plugin-playground": "workspace:*" + "rspress": "workspace:*" }, "devDependencies": { "@types/node": "^14" diff --git a/e2e/fixtures/plugin/rspress.config.ts b/e2e/fixtures/plugin/rspress.config.ts index 9aff11461..c041177b8 100644 --- a/e2e/fixtures/plugin/rspress.config.ts +++ b/e2e/fixtures/plugin/rspress.config.ts @@ -14,4 +14,5 @@ export default defineConfig({ }), // pluginPlayground(), ], + }); diff --git a/e2e/fixtures/plugin/tsconfig.json b/e2e/fixtures/plugin/tsconfig.json index b72f56555..bf6c01040 100644 --- a/e2e/fixtures/plugin/tsconfig.json +++ b/e2e/fixtures/plugin/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "esModuleInterop": true, - "jsx": "react-jsx" + "jsx": "preserve" } } diff --git a/packages/plugin-preview/modern.config.ts b/packages/plugin-preview/modern.config.ts index 83d94ae40..14bf2670e 100644 --- a/packages/plugin-preview/modern.config.ts +++ b/packages/plugin-preview/modern.config.ts @@ -7,6 +7,11 @@ export default defineConfig({ format: 'cjs', sourceMap: true, input: ['./src/index.ts'], + externals: [ + '@rsbuild/core', + '@rsbuild/plugin-babel', + '@rsbuild/plugin-solid', + ], target: 'es2020', dts: { respectExternal: false, diff --git a/packages/plugin-preview/package.json b/packages/plugin-preview/package.json index fe1317c44..68279456e 100644 --- a/packages/plugin-preview/package.json +++ b/packages/plugin-preview/package.json @@ -37,19 +37,23 @@ "dependencies": { "@mdx-js/mdx": "2.2.1", "@rspress/shared": "workspace:*", + "lodash": "4.17.21", "qrcode.react": "^3.1.0", "remark-gfm": "3.0.1", "rspack-plugin-virtual-module": "0.1.12", - "lodash": "4.17.21" + "solid-js": "1.8.11" }, "devDependencies": { + "@biomejs/biome": "1.5.2", + "@rsbuild/core": "0.3.1", + "@rsbuild/plugin-solid": "0.3.1", + "@rsbuild/plugin-babel": "0.3.1", + "@types/lodash": "4.14.200", "@types/mdast": "^3.0.10", "@types/node": "^18.11.17", - "@types/lodash": "4.14.200", "@types/react": "^18", "@types/react-dom": "^18", "mdast-util-mdxjs-esm": "^1.3.0", - "@biomejs/biome": "1.5.2", "react": "^18", "react-dom": "^18", "react-router-dom": "^6.8.1", @@ -58,9 +62,9 @@ "unist-util-visit": "^4.1.1" }, "peerDependencies": { + "@rspress/core": "^1.0.2", "react": ">=17", - "react-router-dom": "^6.8.1", - "@rspress/core": "^1.0.2" + "react-router-dom": "^6.8.1" }, "files": [ "dist", diff --git a/packages/plugin-preview/src/codeToDemo.ts b/packages/plugin-preview/src/codeToDemo.ts index 169b158e2..37b24b5c8 100644 --- a/packages/plugin-preview/src/codeToDemo.ts +++ b/packages/plugin-preview/src/codeToDemo.ts @@ -9,15 +9,19 @@ import { import type { Plugin } from 'unified'; import type { Root } from 'mdast'; import type { MdxjsEsm } from 'mdast-util-mdxjs-esm'; +import rsbuild, { createRsbuild } from '@rsbuild/core'; +import { pluginSolid } from '@rsbuild/plugin-solid'; +import { pluginBabel } from '@rsbuild/plugin-babel'; import { injectDemoBlockImport, generateId } from './utils'; import { demoBlockComponentPath } from './constant'; import { demoRoutes } from '.'; +const rsbuildInstanceMap = new Map(); + // FIXME: remove it const json = JSON.parse( fs.readFileSync(resolve(process.cwd(), './package.json'), 'utf8'), ); - /** * remark plugin to transform code to demo */ @@ -187,6 +191,14 @@ export const remarkCodeToDemo: Plugin< ); const id = generateId(pageName, index++); const virtualModulePath = join(demoDir, `${id}.tsx`); + const virtualEntryPath = join(demoDir, `${id}.entry.tsx`); + + const entryContent = ` + import { render } from 'solid-js/web'; + import Demo from '${virtualModulePath}'; + + render(() => , document.getElementById('root')); +`; fs.ensureDirSync(join(demoDir)); // Only when the content of the file changes, the file will be written // Avoid to trigger the hmr indefinitely @@ -195,7 +207,54 @@ export const remarkCodeToDemo: Plugin< if (content !== value) { fs.writeFileSync(virtualModulePath, value); } + fs.writeFileSync(virtualEntryPath, entryContent); + } + + if (rsbuildInstanceMap.has(virtualEntryPath)) { + return; } + + createRsbuild({ + rsbuildConfig: { + source: { + entry: { + [id]: virtualEntryPath, + }, + alias: { + 'solid-js/web': `${require.resolve( + 'solid-js/web/dist/web.js', + )}`, + }, + }, + output: { + distPath: { + root: 'demo_build', + }, + assetPrefix: 'https://cdn.example.com/assets/', + }, + dev: {}, + tools: { + rspack: { + output: { + publicPath: '/demos', + }, + }, + }, + }, + }).then(async ins => { + console.log('start dev server'); + ins.addPlugins([ + pluginBabel({ + include: /\.(?:jsx|tsx)$/, + }), + pluginSolid(), + ]); + rsbuildInstanceMap.set(virtualEntryPath, ins); + // const server = await ins.startDevServer({ + // getPortSilently: true, + // }); + await ins.build(); + }); constructDemoNode(id, virtualModulePath, node, isMobileMode); } }); diff --git a/packages/plugin-preview/src/utils.ts b/packages/plugin-preview/src/utils.ts index 52db778f7..826409ad1 100644 --- a/packages/plugin-preview/src/utils.ts +++ b/packages/plugin-preview/src/utils.ts @@ -27,9 +27,8 @@ export const normalizeId = (routePath: string) => { return toValidVarName(result); }; -export const injectDemoBlockImport = (str: string, path: string): string => { +export const injectDemoBlockImport = (str: string, _path: string): string => { return ` - import DemoBlock from '${path}'; ${str} `; }; diff --git a/packages/plugin-preview/tsconfig.json b/packages/plugin-preview/tsconfig.json index 8f8382c89..6c7afd7bb 100644 --- a/packages/plugin-preview/tsconfig.json +++ b/packages/plugin-preview/tsconfig.json @@ -4,7 +4,7 @@ "declaration": false, "module": "ESNext", "target": "ESNext", - "jsx": "react-jsx", + "jsx": "preserve", "baseUrl": "src", "rootDir": ".", "lib": ["ESNext", "DOM"], diff --git a/packages/runtime/tsconfig.json b/packages/runtime/tsconfig.json index 60aaf80f3..538e79c9f 100644 --- a/packages/runtime/tsconfig.json +++ b/packages/runtime/tsconfig.json @@ -4,7 +4,7 @@ "rootDir": "src", "baseUrl": ".", "skipLibCheck": true, - "jsx": "react-jsx", + "jsx": "preserve", "esModuleInterop": true }, "include": ["./src/**/*"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df3798fb4..4d6cb3ee9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,10 +16,10 @@ importers: version: 2.2.0 '@modern-js-app/eslint-config': specifier: 2.46.1 - version: 2.46.1(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3)(typescript@5.0.4) + version: 2.46.1(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3)(typescript@5.0.4) '@modern-js/eslint-config': specifier: 2.46.1 - version: 2.46.1(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3)(typescript@5.0.4) + version: 2.46.1(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3)(typescript@5.0.4) '@modern-js/generator-utils': specifier: 3.3.8 version: 3.3.8(@modern-js/codesmith@2.3.3)(typescript@5.0.4) @@ -912,10 +912,22 @@ importers: rspack-plugin-virtual-module: specifier: 0.1.12 version: 0.1.12 + solid-js: + specifier: 1.8.11 + version: 1.8.11 devDependencies: '@biomejs/biome': specifier: 1.5.2 version: 1.5.2 + '@rsbuild/core': + specifier: 0.3.1 + version: 0.3.1 + '@rsbuild/plugin-babel': + specifier: 0.3.1 + version: 0.3.1(@swc/helpers@0.5.3) + '@rsbuild/plugin-solid': + specifier: 0.3.1 + version: 0.3.1(@babel/core@7.23.2)(@rsbuild/core@0.3.1)(@swc/helpers@0.5.3)(solid-js@1.8.11) '@types/lodash': specifier: 4.14.200 version: 4.14.200 @@ -1534,14 +1546,14 @@ packages: dependencies: '@ampproject/remapping': 2.2.1 '@babel/code-frame': 7.22.13 - '@babel/generator': 7.23.0 + '@babel/generator': 7.23.6 '@babel/helper-compilation-targets': 7.22.15 '@babel/helper-module-transforms': 7.23.0(@babel/core@7.23.2) '@babel/helpers': 7.23.2 '@babel/parser': 7.23.0 '@babel/template': 7.22.15 '@babel/traverse': 7.23.2 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 convert-source-map: 2.0.0 debug: 4.3.4 gensync: 1.0.0-beta.2 @@ -1585,18 +1597,27 @@ packages: '@jridgewell/trace-mapping': 0.3.19 jsesc: 2.5.2 + /@babel/generator@7.23.6: + resolution: {integrity: sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.23.6 + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.19 + jsesc: 2.5.2 + /@babel/helper-annotate-as-pure@7.22.5: resolution: {integrity: sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 dev: true /@babel/helper-builder-binary-assignment-operator-visitor@7.22.10: resolution: {integrity: sha512-Av0qubwDQxC56DoUReVDeLfMEjYYSN1nZrTUrWkXd7hpU73ymRANkbuDm3yni9npkn+RXy9nNbEJZEzXr7xrfQ==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 dev: true /@babel/helper-compilation-targets@7.22.15: @@ -1663,26 +1684,33 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/helper-hoist-variables@7.22.5: resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/helper-member-expression-to-functions@7.22.15: resolution: {integrity: sha512-qLNsZbgrNh0fDQBCPocSL8guki1hcPvltGDv/NxvUoABwFq7GkKSu1nRXeJkVZc+wJvne2E0RKQz+2SQrz6eAA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 + dev: true + + /@babel/helper-module-imports@7.18.6: + resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.23.6 dev: true /@babel/helper-module-imports@7.22.15: resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/helper-module-transforms@7.23.0(@babel/core@7.23.2): resolution: {integrity: sha512-WhDWw1tdrlT0gMgUJSlX0IQvoO1eN279zrAUbVB+KpV2c3Tylz8+GnKOLllCS6Z/iZQEyVYxhZVUdPTqs2YYPw==} @@ -1701,7 +1729,7 @@ packages: resolution: {integrity: sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 dev: true /@babel/helper-plugin-utils@7.22.5: @@ -1737,25 +1765,29 @@ packages: resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/helper-skip-transparent-expression-wrappers@7.22.5: resolution: {integrity: sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 dev: true /@babel/helper-split-export-declaration@7.22.6: resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/helper-string-parser@7.22.5: resolution: {integrity: sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==} engines: {node: '>=6.9.0'} + /@babel/helper-string-parser@7.23.4: + resolution: {integrity: sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ==} + engines: {node: '>=6.9.0'} + /@babel/helper-validator-identifier@7.22.20: resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} engines: {node: '>=6.9.0'} @@ -1770,7 +1802,7 @@ packages: dependencies: '@babel/helper-function-name': 7.23.0 '@babel/template': 7.22.15 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 dev: true /@babel/helpers@7.23.2: @@ -1779,7 +1811,7 @@ packages: dependencies: '@babel/template': 7.22.15 '@babel/traverse': 7.23.2 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 transitivePeerDependencies: - supports-color @@ -2748,7 +2780,7 @@ packages: '@babel/plugin-transform-unicode-regex': 7.22.5(@babel/core@7.23.2) '@babel/plugin-transform-unicode-sets-regex': 7.22.5(@babel/core@7.23.2) '@babel/preset-modules': 0.1.6-no-external-plugins(@babel/core@7.23.2) - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 babel-plugin-polyfill-corejs2: 0.4.6(@babel/core@7.23.2) babel-plugin-polyfill-corejs3: 0.8.5(@babel/core@7.23.2) babel-plugin-polyfill-regenerator: 0.5.3(@babel/core@7.23.2) @@ -2765,7 +2797,7 @@ packages: dependencies: '@babel/core': 7.23.2 '@babel/helper-plugin-utils': 7.22.5 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 esutils: 2.0.3 dev: true @@ -2799,7 +2831,7 @@ packages: dependencies: '@babel/code-frame': 7.22.13 '@babel/parser': 7.23.0 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 /@babel/traverse@7.23.2: resolution: {integrity: sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==} @@ -2835,6 +2867,14 @@ packages: '@babel/helper-validator-identifier': 7.22.20 to-fast-properties: 2.0.0 + /@babel/types@7.23.6: + resolution: {integrity: sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.23.4 + '@babel/helper-validator-identifier': 7.22.20 + to-fast-properties: 2.0.0 + /@biomejs/biome@1.5.2: resolution: {integrity: sha512-LhycxGQBQLmfv6M3e4tMfn/XKcUWyduDYOlCEBrHXJ2mMth2qzYt1JWypkWp+XmU/7Hl2dKvrP4mZ5W44+nWZw==} engines: {node: '>=14.*'} @@ -4051,7 +4091,7 @@ packages: react: 18.2.0 dev: false - /@modern-js-app/eslint-config@2.46.1(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3)(typescript@5.0.4): + /@modern-js-app/eslint-config@2.46.1(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3)(typescript@5.0.4): resolution: {integrity: sha512-TxU47cr1IGC/jCW85tlkIgwRdmogQtIZKm0CzY2gtjg9GHbpSZ/UZsQV4UKeaoYXH5dILLgMRGs8BFtQq8LUvw==} peerDependencies: typescript: ^4 || ^5 @@ -4059,7 +4099,7 @@ packages: '@babel/core': 7.23.2 '@babel/eslint-parser': 7.22.15(@babel/core@7.23.2)(eslint@8.46.0) '@babel/eslint-plugin': 7.22.10(@babel/eslint-parser@7.22.15)(eslint@8.46.0) - '@rsbuild/babel-preset': 0.3.4(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3) + '@rsbuild/babel-preset': 0.3.4(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3) '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.46.0)(typescript@5.0.4) '@typescript-eslint/parser': 5.62.0(eslint@8.46.0)(typescript@5.0.4) eslint: 8.46.0 @@ -4152,10 +4192,10 @@ packages: '@swc/helpers': 0.5.3 dev: true - /@modern-js/eslint-config@2.46.1(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3)(typescript@5.0.4): + /@modern-js/eslint-config@2.46.1(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3)(typescript@5.0.4): resolution: {integrity: sha512-cVudBdjvZVNSfrKMbVtEKQrmRVjQp4A3hmE7EIRKnBAFBByI6tXGmNKOubtUN5Zj6XPOnYUXqyT2JE/jhT2G2g==} dependencies: - '@modern-js-app/eslint-config': 2.46.1(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3)(typescript@5.0.4) + '@modern-js-app/eslint-config': 2.46.1(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3)(typescript@5.0.4) transitivePeerDependencies: - '@rsbuild/core' - '@swc/helpers' @@ -4292,7 +4332,7 @@ packages: '@ampproject/remapping': 2.2.1 '@ast-grep/napi': 0.16.0 '@babel/core': 7.23.2 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 '@modern-js/core': 2.46.1 '@modern-js/new-action': 2.46.1(typescript@5.0.4) '@modern-js/plugin': 2.46.1 @@ -5079,7 +5119,7 @@ packages: picomatch: 2.3.1 dev: true - /@rsbuild/babel-preset@0.3.4(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3): + /@rsbuild/babel-preset@0.3.4(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3): resolution: {integrity: sha512-lGYVxjuf5SmWt10cBu/agYxpXNfFrvgcl7r9pnObWF9bRwsuaI1S+EuigjFeBUVPdNs4OMQy46sQaTpMfp4p0A==} dependencies: '@babel/core': 7.23.2 @@ -5091,8 +5131,8 @@ packages: '@babel/preset-env': 7.23.2(@babel/core@7.23.2) '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) '@babel/runtime': 7.23.2 - '@babel/types': 7.23.0 - '@rsbuild/plugin-babel': 0.3.4(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3) + '@babel/types': 7.23.6 + '@rsbuild/plugin-babel': 0.3.4(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3) '@rsbuild/shared': 0.3.4(@swc/helpers@0.5.3) '@types/babel__core': 7.20.3 babel-plugin-dynamic-import-node: 2.3.3 @@ -5114,14 +5154,13 @@ packages: core-js: 3.32.2 html-webpack-plugin: /html-rspack-plugin@5.5.7 postcss: 8.4.31 - dev: false - /@rsbuild/core@0.3.4: - resolution: {integrity: sha512-FrAFuu0q9l1/lTqSNU8/qYPVDXYFOBz4abOjd61ycLjVtFaMhOWDjKxqI+c6k3XG3pZQ+CmjSfT4m50gA20+nA==} + /@rsbuild/core@0.3.5: + resolution: {integrity: sha512-Fz6uyi3zsu9XK6zFKEy9WIiDi0dKCNtuetW169hVwZk5PAljQ/CmEKSGv4P6W+2Bd0H3652tIdS9bTA+gCsKyw==} engines: {node: '>=14.0.0'} hasBin: true dependencies: - '@rsbuild/shared': 0.3.4(@swc/helpers@0.5.3) + '@rsbuild/shared': 0.3.5(@swc/helpers@0.5.3) '@rspack/core': 0.5.0(@swc/helpers@0.5.3) '@swc/helpers': 0.5.3 core-js: 3.32.2 @@ -5129,14 +5168,27 @@ packages: postcss: 8.4.33 dev: true - /@rsbuild/plugin-babel@0.3.4(@rsbuild/core@0.3.4)(@swc/helpers@0.5.3): + /@rsbuild/plugin-babel@0.3.1(@swc/helpers@0.5.3): + resolution: {integrity: sha512-OKyveb8oXgNkxpcroeqPco7Ce6ydPmXNarDdjdT596pjNe2pxJTACgRnIdWlwgBHTALa2dOemzw7+EDlttVcOQ==} + dependencies: + '@babel/core': 7.23.2 + '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) + '@rsbuild/shared': 0.3.1(@swc/helpers@0.5.3) + '@types/babel__core': 7.20.3 + upath: 2.0.1 + transitivePeerDependencies: + - '@swc/helpers' + - supports-color + dev: true + + /@rsbuild/plugin-babel@0.3.4(@rsbuild/core@0.3.5)(@swc/helpers@0.5.3): resolution: {integrity: sha512-N6frB1R9mK1K/leaA73eNF2Vo9hy4B1i4+CGFUCbP4msS0DGasAlZ1fUlNWvCi7a07Q9R2QbWc38RG1yRyKYBw==} peerDependencies: '@rsbuild/core': ^0.3.4 dependencies: '@babel/core': 7.23.2 '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) - '@rsbuild/core': 0.3.4 + '@rsbuild/core': 0.3.5 '@rsbuild/shared': 0.3.4(@swc/helpers@0.5.3) '@types/babel__core': 7.20.3 upath: 2.0.1 @@ -5155,6 +5207,23 @@ packages: - '@swc/helpers' dev: false + /@rsbuild/plugin-solid@0.3.1(@babel/core@7.23.2)(@rsbuild/core@0.3.1)(@swc/helpers@0.5.3)(solid-js@1.8.11): + resolution: {integrity: sha512-3KmNi+HrACaVo6jRFvGMEbTyBpL8RQVqafKuPtqSFfwi+pDSLhdrm0tPf+hjQLYHsnlexBhbRD/2F3VoPrT14g==} + peerDependencies: + '@rsbuild/core': 0.x + dependencies: + '@rsbuild/core': 0.3.1 + '@rsbuild/plugin-babel': 0.3.1(@swc/helpers@0.5.3) + '@rsbuild/shared': 0.3.1(@swc/helpers@0.5.3) + babel-preset-solid: 1.8.9(@babel/core@7.23.2) + solid-refresh: 0.6.3(solid-js@1.8.11) + transitivePeerDependencies: + - '@babel/core' + - '@swc/helpers' + - solid-js + - supports-color + dev: true + /@rsbuild/plugin-svgr@0.3.1(@swc/helpers@0.5.3): resolution: {integrity: sha512-uzlfrymQmIXMmZ8PL4OaY83V8TNDSohh+hfGElcbgVSLBZ11+lZ9weQUv/rQqX0sCjQgc9xIt+4w3DEnuus7Yg==} dependencies: @@ -5176,7 +5245,6 @@ packages: postcss: 8.4.31 transitivePeerDependencies: - '@swc/helpers' - dev: false /@rsbuild/shared@0.3.4(@swc/helpers@0.5.3): resolution: {integrity: sha512-rvm+B2pGHsRSW3LiqPzOnyg/PQMNZsrX2QvuZLUovuF3DpvzKJoBsrj0ih1c0ymlIEitEcoBqiJbQUVQI3iDUQ==} @@ -5189,6 +5257,17 @@ packages: - '@swc/helpers' dev: true + /@rsbuild/shared@0.3.5(@swc/helpers@0.5.3): + resolution: {integrity: sha512-VGfZx8AufGLP19t86A3a9PUmA5aIKZB1r/zpnkmkP5F4yW22J1KmMO8fyzj5cg+EB8OSqKhSO7FTgTspmologg==} + dependencies: + '@rspack/core': 0.5.0(@swc/helpers@0.5.3) + caniuse-lite: 1.0.30001561 + lodash: 4.17.21 + postcss: 8.4.33 + transitivePeerDependencies: + - '@swc/helpers' + dev: true + /@rspack/binding-darwin-arm64@0.5.0: resolution: {integrity: sha512-zRx4efhn2eCjdhHt6avhdkKur6FZvYy1TgPhNKpWbTg7fnrvtNGzcVQCAOnPUUPkJjnss3veOhZlWJ3paX0EDQ==} cpu: [arm64] @@ -5207,7 +5286,6 @@ packages: resolution: {integrity: sha512-97xFbF7RjJc2VvX+0Hvb7Jzsk+eEE8oEUcc5Dnb7OIwGZulWKk6cLNcRkNfmL/F9kk1QEKlUTNC/VQI7ljf2tA==} cpu: [arm64] os: [linux] - libc: [glibc] requiresBuild: true optional: true @@ -5215,7 +5293,6 @@ packages: resolution: {integrity: sha512-lk0IomCy276EoynmksoBwg0IcHvvVXuZPMeq7OgRPTvs33mdTExSzSTPtrGzx/D00bX1ybUqLQwJhcgGt6erPQ==} cpu: [arm64] os: [linux] - libc: [musl] requiresBuild: true optional: true @@ -5223,7 +5300,6 @@ packages: resolution: {integrity: sha512-r15ddpse0S/8wHtfL85uJrVotvPVIMnQX06KlXyGUSw1jWrjxV+NXFDJ4xXnHCvk/YV6lCFTotAssk4wJEE0Fw==} cpu: [x64] os: [linux] - libc: [glibc] requiresBuild: true optional: true @@ -5231,7 +5307,6 @@ packages: resolution: {integrity: sha512-lB9Dn1bi4xyzEe6Bf/GQ7Ktlrq4Kmt1LHwN+t0m6iVYH3Vb/3g8uQGDSkwnjP8NmlAtldK1cmvRMhR7flUrgZA==} cpu: [x64] os: [linux] - libc: [musl] requiresBuild: true optional: true @@ -5586,7 +5661,7 @@ packages: resolution: {integrity: sha512-EbDKwO9GpfWP4jN9sGdYwPBU0kdomaPIL2Eu4YwmgP+sJeXT+L7bMwJUBnhzfH8Q2qMBqZ4fJwpCyYsAN3mt2Q==} engines: {node: '>=14'} dependencies: - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 entities: 4.5.0 /@svgr/plugin-jsx@8.0.1(@svgr/core@8.0.0): @@ -5694,7 +5769,7 @@ packages: resolution: {integrity: sha512-54fjTSeSHwfan8AyHWrKbfBWiEUrNTZsUwPTDSNaaP1QDQIZbeNUg3a59E9D+375MzUw/x1vx2/0F5LBz+AeYA==} dependencies: '@babel/parser': 7.23.0 - '@babel/types': 7.23.0 + '@babel/types': 7.23.6 '@types/babel__generator': 7.6.4 '@types/babel__template': 7.4.1 '@types/babel__traverse': 7.20.1 @@ -6771,6 +6846,19 @@ packages: object.assign: 4.1.4 dev: true + /babel-plugin-jsx-dom-expressions@0.37.13(@babel/core@7.23.2): + resolution: {integrity: sha512-oAEMMIgU0h1DmHn4ZDaBBFc08nsVJciLq9pF7g0ZdpeIDKfY4zXjXr8+/oBjKhXG8nyomhnTodPjeG+/ZXcWXQ==} + peerDependencies: + '@babel/core': ^7.20.12 + dependencies: + '@babel/core': 7.23.2 + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.22.5(@babel/core@7.23.2) + '@babel/types': 7.23.6 + html-entities: 2.3.3 + validate-html-nesting: 1.2.2 + dev: true + /babel-plugin-macros@3.1.0: resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==} engines: {node: '>=10', npm: '>=6'} @@ -6816,6 +6904,15 @@ packages: - supports-color dev: true + /babel-preset-solid@1.8.9(@babel/core@7.23.2): + resolution: {integrity: sha512-1awR1QCoryXtAdnjsrx/eVBTYz+tpHUDOdBXqG9oVV7S0ojf2MV/woR0+8BG+LMXVzIr60oKYzCZ9UZGafxmpg==} + peerDependencies: + '@babel/core': ^7.0.0 + dependencies: + '@babel/core': 7.23.2 + babel-plugin-jsx-dom-expressions: 0.37.13(@babel/core@7.23.2) + dev: true + /bail@2.0.2: resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==} @@ -9120,6 +9217,10 @@ packages: lru-cache: 6.0.0 dev: false + /html-entities@2.3.3: + resolution: {integrity: sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==} + dev: true + /html-entities@2.4.0: resolution: {integrity: sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==} dev: false @@ -10811,6 +10912,7 @@ packages: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + dev: true /natural-compare-lite@1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} @@ -11525,7 +11627,7 @@ packages: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} dependencies: - nanoid: 3.3.7 + nanoid: 3.3.6 picocolors: 1.0.0 source-map-js: 1.0.2 @@ -12829,6 +12931,18 @@ packages: dependencies: randombytes: 2.1.0 + /seroval-plugins@1.0.4(seroval@1.0.4): + resolution: {integrity: sha512-DQ2IK6oQVvy8k+c2V5x5YCtUa/GGGsUwUBNN9UqohrZ0rWdUapBFpNMYP1bCyRHoxOJjdKGl+dieacFIpU/i1A==} + engines: {node: '>=10'} + peerDependencies: + seroval: ^1.0 + dependencies: + seroval: 1.0.4 + + /seroval@1.0.4: + resolution: {integrity: sha512-qQs/N+KfJu83rmszFQaTxcoJoPn6KNUruX4KmnmyD0oZkUoiNvJ1rpdYKDf4YHM05k+HOgCxa3yvf15QbVijGg==} + engines: {node: '>=10'} + /set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: true @@ -12948,6 +13062,24 @@ packages: dot-case: 3.0.4 tslib: 2.6.1 + /solid-js@1.8.11: + resolution: {integrity: sha512-WdwmER+TwBJiN4rVQTVBxocg+9pKlOs41KzPYntrC86xO5sek8TzBYozPEZPL1IRWDouf2lMrvSbIs3CanlPvQ==} + dependencies: + csstype: 3.1.2 + seroval: 1.0.4 + seroval-plugins: 1.0.4(seroval@1.0.4) + + /solid-refresh@0.6.3(solid-js@1.8.11): + resolution: {integrity: sha512-F3aPsX6hVw9ttm5LYlth8Q15x6MlI/J3Dn+o3EQyRTtTxidepSTwAYdozt01/YA+7ObcciagGEyXIopGZzQtbA==} + peerDependencies: + solid-js: ^1.3 + dependencies: + '@babel/generator': 7.23.6 + '@babel/helper-module-imports': 7.22.15 + '@babel/types': 7.23.6 + solid-js: 1.8.11 + dev: true + /source-map-js@1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} @@ -13934,6 +14066,10 @@ packages: resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==} dev: true + /validate-html-nesting@1.2.2: + resolution: {integrity: sha512-hGdgQozCsQJMyfK5urgFcWEqsSSrK63Awe0t/IMR0bZ0QMtnuaiHzThW81guu3qx9abLi99NEuiaN6P9gVYsNg==} + dev: true + /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: From e157a30ea10bf304d86db3fefc7dc64fa513864b Mon Sep 17 00:00:00 2001 From: yangxingyuan Date: Sat, 20 Jan 2024 16:47:02 +0800 Subject: [PATCH 2/2] chore: preserve demo snopshot --- e2e/fixtures/plugin/doc/index.mdx | 3 +- e2e/fixtures/plugin/rspress.config.ts | 1 - packages/core/src/node/dev.ts | 11 +++- packages/plugin-preview/src/codeToDemo.ts | 78 +++++------------------ packages/plugin-preview/src/index.ts | 49 +++++++++++++- 5 files changed, 77 insertions(+), 65 deletions(-) diff --git a/e2e/fixtures/plugin/doc/index.mdx b/e2e/fixtures/plugin/doc/index.mdx index 1e63495e9..6b488a865 100644 --- a/e2e/fixtures/plugin/doc/index.mdx +++ b/e2e/fixtures/plugin/doc/index.mdx @@ -2,11 +2,12 @@ ```jsx export default function HelloWorld() { - return
这是 solidjs 渲染的结果
; + return
这是 solidjs 渲染的结果11
; } ``` ```jsx +// 如果要引入自定义的外部组件,可以使用 tsconfig.json 中的 paths 别名配置 export default function HelloWorld() { return
这是 solidjs 渲染的结果
; } diff --git a/e2e/fixtures/plugin/rspress.config.ts b/e2e/fixtures/plugin/rspress.config.ts index c041177b8..73a91caa5 100644 --- a/e2e/fixtures/plugin/rspress.config.ts +++ b/e2e/fixtures/plugin/rspress.config.ts @@ -12,7 +12,6 @@ export default defineConfig({ isMobile: true, iframePosition: 'fixed', }), - // pluginPlayground(), ], }); diff --git a/packages/core/src/node/dev.ts b/packages/core/src/node/dev.ts index 2ca3d05bd..2a2d4c463 100644 --- a/packages/core/src/node/dev.ts +++ b/packages/core/src/node/dev.ts @@ -34,12 +34,21 @@ export async function dev(options: DevOptions): Promise { false, extraBuilderConfig, ); + builder.addPlugins([ + { + name: 'rspress:afterBuild', + setup(api) { + api.onDevCompileDone(async () => { + await pluginDriver.afterBuild(); + }); + }, + }, + ]); const { server } = await builder.startDevServer({ // We will support the following options in the future getPortSilently: true, }); - await pluginDriver.afterBuild(); return server; } finally { await writeSearchIndex(config); diff --git a/packages/plugin-preview/src/codeToDemo.ts b/packages/plugin-preview/src/codeToDemo.ts index 37b24b5c8..c575eb562 100644 --- a/packages/plugin-preview/src/codeToDemo.ts +++ b/packages/plugin-preview/src/codeToDemo.ts @@ -9,14 +9,13 @@ import { import type { Plugin } from 'unified'; import type { Root } from 'mdast'; import type { MdxjsEsm } from 'mdast-util-mdxjs-esm'; -import rsbuild, { createRsbuild } from '@rsbuild/core'; -import { pluginSolid } from '@rsbuild/plugin-solid'; -import { pluginBabel } from '@rsbuild/plugin-babel'; + import { injectDemoBlockImport, generateId } from './utils'; import { demoBlockComponentPath } from './constant'; -import { demoRoutes } from '.'; +// import { demoRoutes } from '.'; -const rsbuildInstanceMap = new Map(); +export const demoEntryMap: Record = {}; +export const DEMO_SERVER_PORT = '7890'; // FIXME: remove it const json = JSON.parse( @@ -60,15 +59,15 @@ export const remarkCodeToDemo: Plugin< // Only for external demo externalDemoIndex?: number, ) { - const demoRoute = `/~demo/${demoId}`; - if (isMobileMode) { - // only add demoRoutes in mobile mode - demoRoutes.push({ - path: demoRoute, - }); - } else { - demos.push(getASTNodeImport(`Demo${demoId}`, demoPath)); - } + // const demoRoute = `/~demo/${demoId}`; + // if (isMobileMode) { + // // only add demoRoutes in mobile mode + // demoRoutes.push({ + // path: demoRoute, + // }); + // } else { + // demos.push(getASTNodeImport(`Demo${demoId}`, demoPath)); + // } // get external demo content const tempVar = `externalDemoContent${externalDemoIndex}`; @@ -96,7 +95,7 @@ export const remarkCodeToDemo: Plugin< { type: 'mdxJsxAttribute', name: 'url', - value: demoRoute, + value: demoPath, }, { type: 'mdxJsxAttribute', @@ -209,53 +208,10 @@ export const remarkCodeToDemo: Plugin< } fs.writeFileSync(virtualEntryPath, entryContent); } + demoEntryMap[id] = virtualEntryPath; - if (rsbuildInstanceMap.has(virtualEntryPath)) { - return; - } - - createRsbuild({ - rsbuildConfig: { - source: { - entry: { - [id]: virtualEntryPath, - }, - alias: { - 'solid-js/web': `${require.resolve( - 'solid-js/web/dist/web.js', - )}`, - }, - }, - output: { - distPath: { - root: 'demo_build', - }, - assetPrefix: 'https://cdn.example.com/assets/', - }, - dev: {}, - tools: { - rspack: { - output: { - publicPath: '/demos', - }, - }, - }, - }, - }).then(async ins => { - console.log('start dev server'); - ins.addPlugins([ - pluginBabel({ - include: /\.(?:jsx|tsx)$/, - }), - pluginSolid(), - ]); - rsbuildInstanceMap.set(virtualEntryPath, ins); - // const server = await ins.startDevServer({ - // getPortSilently: true, - // }); - await ins.build(); - }); - constructDemoNode(id, virtualModulePath, node, isMobileMode); + const demoPath = `http://localhost:${DEMO_SERVER_PORT}/demos/${id}.html`; + constructDemoNode(id, demoPath, node, isMobileMode); } }); diff --git a/packages/plugin-preview/src/index.ts b/packages/plugin-preview/src/index.ts index 9229f312d..e2cd8d82d 100644 --- a/packages/plugin-preview/src/index.ts +++ b/packages/plugin-preview/src/index.ts @@ -8,7 +8,10 @@ import { normalizePosixPath, } from '@rspress/shared'; import { uniqBy } from 'lodash'; -import { remarkCodeToDemo } from './codeToDemo'; +import { createRsbuild } from '@rsbuild/core'; +import { pluginSolid } from '@rsbuild/plugin-solid'; +import { pluginBabel } from '@rsbuild/plugin-babel'; +import { DEMO_SERVER_PORT, demoEntryMap, remarkCodeToDemo } from './codeToDemo'; import { generateId, injectDemoBlockImport } from './utils'; import { demoBlockComponentPath, @@ -308,6 +311,50 @@ import Demo from ${JSON.stringify(demoComponentPath)} } return demoRoutes; }, + async afterBuild() { + // Create demo dev server + const rsbuildInstance = await createRsbuild({ + rsbuildConfig: { + dev: { + client: { + port: DEMO_SERVER_PORT, + }, + progressBar: false, + }, + server: { + // Don't display the demo server log + printUrls: () => undefined, + }, + source: { + entry: demoEntryMap, + alias: { + 'solid-js/web': `${require.resolve('solid-js/web/dist/web.js')}`, + }, + }, + output: { + distPath: { + root: 'demo_build', + }, + }, + tools: { + rspack: { + output: { + publicPath: '/demos', + }, + }, + }, + }, + }); + rsbuildInstance.addPlugins([ + pluginBabel({ + include: /\.(?:jsx|tsx)$/, + }), + pluginSolid(), + ]); + await rsbuildInstance.startDevServer({ + getPortSilently: true, + }); + }, }; }