vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { fileURLToPath } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import react from '@vitejs/plugin-react'
  4. const src = (rel: string): string => fileURLToPath(new URL(rel, import.meta.url))
  5. export default defineConfig({
  6. plugins: [react()],
  7. resolve: {
  8. // Workspace packages resolve to SOURCE: package.json exports point at lib
  9. // for Node/type consumers, but the browser bundle must compile src directly
  10. // so CSS rides vite's pipeline instead of the CSS-externalized lib bundle.
  11. // Only the shell's normal-package surface is aliased — plugin packages are
  12. // NEVER bundled here (web2 shell self-sufficiency); they arrive as runtime
  13. // bundles through the client module system. Order matters — subpath
  14. // aliases must win over bare-name prefixes.
  15. alias: [
  16. // Browserization of the vendored cordis Loader: its only node-only
  17. // import; the two process probes are mapped by `define` below.
  18. { find: /^node:module$/, replacement: src('./src/node-module-stub.ts') },
  19. { find: /^@deepseek-ai\/dsh-client-web$/, replacement: src('../../packages/client/web/src/boot.tsx') },
  20. { find: /^@deepseek-ai\/dsh-client-web-react$/, replacement: src('../../packages/client/web-react/src/index.ts') },
  21. { find: /^@deepseek-ai\/dsh-client-ui-slots$/, replacement: src('../../packages/client/ui-slots/src/index.ts') },
  22. { find: /^@deepseek-ai\/dsh-client-ui-primitives$/, replacement: src('../../packages/client/ui-primitives/src/index.ts') },
  23. { find: /^@deepseek-ai\/dsh-client-modules\/client$/, replacement: src('../../packages/client/modules/src/client/index.ts') },
  24. ],
  25. },
  26. define: {
  27. // vendored loader internal.ts: fromInternal() probes the Node major —
  28. // "0.0.0" takes neither branch, returning undefined (exactly the empty
  29. // internal slot the shell boot fills with the client module loader).
  30. 'process.versions.node': '"0.0.0"',
  31. 'process.execArgv': '[]',
  32. // vendored loader index.ts: envData falls to its default branch.
  33. 'process.env.CORDIS_SHARED': 'undefined',
  34. },
  35. })