Explorar el Código

fix(editor): lazy-load ws in vite config to fix build mode

Move `ws` import from top-level static import to dynamic require inside
the dev-only plugin, preventing ERR_MODULE_NOT_FOUND when running
`vite build --mode dev` in CI where ws is not a direct dependency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Yuki Takei hace 1 mes
padre
commit
119291e9b6
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      packages/editor/vite.config.ts

+ 2 - 1
packages/editor/vite.config.ts

@@ -5,7 +5,6 @@ import { nodeExternals } from 'rollup-plugin-node-externals';
 import type { Plugin } from 'vite';
 import { defineConfig } from 'vite';
 import dts from 'vite-plugin-dts';
-import { WebSocketServer } from 'ws';
 
 const excludeFiles = [
   '**/components/playground/*',
@@ -21,6 +20,8 @@ const devWebSocketPlugin = (): Plugin => ({
 
     // eslint-disable-next-line @typescript-eslint/no-require-imports
     const { setupWSConnection } = require('y-websocket/bin/utils');
+    // eslint-disable-next-line @typescript-eslint/no-require-imports
+    const { WebSocketServer } = require('ws');
 
     const wss = new WebSocketServer({ noServer: true });