Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,25 +631,27 @@ function PlaybackProgressSlider() {

```typescript
export default defineConfig({
plugins: [react(), wasm(), topLevelAwait()],
plugins: [react()],
resolve: { alias: { '@': path.resolve(__dirname, './src') } },
worker: { format: 'es', plugins: () => [wasm(), topLevelAwait()] },
worker: { format: 'es', plugins: () => [wasm()] },
build: {
rollupOptions: {
target: 'esnext',
rolldownOptions: {
output: {
manualChunks: {
'vendor-dockview': ['dockview'],
'vendor-three': ['three', '@react-three/fiber', '@react-three/drei'],
'vendor-uplot': ['uplot'],
'vendor-mcap': ['@mcap/core'],
'vendor-rosbag': ['@foxglove/rosbag', '@foxglove/rosbag2-web'],
codeSplitting: true,
manualChunks(id) {
if (id.includes('dockview')) return 'vendor-dockview';
if (id.includes('three')) return 'vendor-three';
// ...
},
},
},
},
});
```

> Worker bundles (including `@ioai/hdf5` Emscripten glue with native top-level await) rely on `build.target: 'esnext'` and ES module workers — no `vite-plugin-top-level-await` polyfill is required for Chrome/Edge targets.

### 7.2 Library Build (Embeddable Component)

`vite.lib.config.ts` — outputs an ESM library bundle for npm. **Type declarations are emitted in the same `vite build` run** via `vite-plugin-dts`. With `rollupTypes: true`, API Extractor rolls declarations up to a single `dist-lib/rosview.d.ts` (no separate post-build script).
Expand All @@ -665,7 +667,6 @@ export default defineConfig({
plugins: [
react(),
wasm(),
topLevelAwait(),
dts({
compilerOptions: { rootDir: path.join(packageDir, 'src') },
include: ['src/**/*.ts', 'src/**/*.tsx'],
Expand Down
26 changes: 12 additions & 14 deletions docs/ARCHITECTURE.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,34 +635,35 @@ function PlaybackProgressSlider() {
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import path from 'path';

export default defineConfig({
plugins: [react(), wasm(), topLevelAwait()],
plugins: [react()],
resolve: {
alias: { '@': path.resolve(__dirname, './src') },
},
worker: {
format: 'es',
plugins: () => [wasm(), topLevelAwait()],
plugins: () => [wasm()],
},
build: {
rollupOptions: {
target: 'esnext',
rolldownOptions: {
output: {
manualChunks: {
'vendor-dockview': ['dockview'],
'vendor-three': ['three', '@react-three/fiber', '@react-three/drei'],
'vendor-uplot': ['uplot'],
'vendor-mcap': ['@mcap/core'],
'vendor-rosbag': ['@foxglove/rosbag', '@foxglove/rosbag2-web'],
codeSplitting: true,
manualChunks(id) {
if (id.includes('dockview')) return 'vendor-dockview';
if (id.includes('three')) return 'vendor-three';
// ...
},
},
},
},
});
```

> Worker bundle(含 `@ioai/hdf5` Emscripten glue 的原生 top-level await)依赖 `build.target: 'esnext'` 与 ES Module Worker,面向 Chrome/Edge 目标时无需 `vite-plugin-top-level-await` polyfill。

### 7.2 库构建(嵌入式组件)

`vite.lib.config.ts` — 构建为可被 `app/` 引入的 ESM 库;**类型声明在同一轮 `vite build` 内**由 `vite-plugin-dts` 生成,`rollupTypes: true` 借助 API Extractor 合并为单一 `dist-lib/rosview.d.ts`(无需额外脚本)。
Expand All @@ -674,7 +675,6 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import dts from 'vite-plugin-dts';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';
import path from 'path';
import { fileURLToPath } from 'node:url';

Expand All @@ -685,7 +685,6 @@ export default defineConfig({
plugins: [
react(),
wasm(),
topLevelAwait(),
dts({
compilerOptions: { rootDir: path.join(packageDir, 'src') },
include: ['src/**/*.ts', 'src/**/*.tsx'],
Expand All @@ -703,7 +702,7 @@ export default defineConfig({
},
worker: {
format: 'es',
plugins: () => [wasm(), topLevelAwait()],
plugins: () => [wasm()],
},
build: {
outDir: 'dist-lib',
Expand Down Expand Up @@ -927,7 +926,6 @@ rosview/
"typescript-eslint": "^8.58.0",
"vite": "^8.0.4",
"vite-plugin-dts": "^4.5.4",
"vite-plugin-top-level-await": "^1.6.0",
"vite-plugin-wasm": "^3.5.0",
"vitest": "^4.0.0"
}
Expand Down
Loading
Loading