🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(vite): stop assuming node_modules sits at the repo root (#19325)
Innei6329f97e142b
diff --git a/apps/desktop/pnpm-workspace.yaml b/apps/desktop/pnpm-workspace.yamlindex f61c7c64785..6e83b0705d1 100644--- a/apps/desktop/pnpm-workspace.yaml+++ b/apps/desktop/pnpm-workspace.yaml@@ -20,7 +20,7 @@ packages:- '../../packages/tool-runtime'- '../../packages/prompts'- '../../packages/ssrf-safe-fetch'- - './stubs/business-const'+ - 'stubs/business-const'- '../../packages/types'- '../../packages/model-bank'- '../../packages/utils'diff --git a/package.json b/package.jsonindex c9eace66909..0c6c3fa7a9d 100644--- a/package.json+++ b/package.json@@ -310,7 +310,7 @@"@lobehub/analytics": "^1.6.4","@lobehub/charts": "^5.4.0","@lobehub/desktop-ipc-typings": "workspace:*",- "@lobehub/editor": "^4.26.1",+ "@lobehub/editor": "^4.27.0","@lobehub/icons": "^5.18.0","@lobehub/market-sdk": "0.41.0","@lobehub/tts": "^5.1.2",diff --git a/plugins/vite/lobeUiImports.ts b/plugins/vite/lobeUiImports.tsindex 171801fcec1..738c6cc547c 100644--- a/plugins/vite/lobeUiImports.ts+++ b/plugins/vite/lobeUiImports.ts@@ -1,6 +1,6 @@import { readFileSync, realpathSync } from 'node:fs';+import { createRequire } from 'node:module';import path from 'node:path';-import { fileURLToPath } from 'node:url';import transformImports from '@rolldown/plugin-transform-imports';import type { Plugin, PluginOption } from 'vite';@@ -54,10 +54,10 @@ export const parseBarrel = (code: string, barrelDir: string): BarrelMap => {};const loadBarrelMaps = () => {+ // Resolve through the package rather than a path into node_modules: overlay+ // builds mount this repo as a submodule and hoist the install above it.// realpath so bare specifiers resolve from pnpm's isolated store, not the root symlink- const esRoot = realpathSync(- path.resolve(fileURLToPath(import.meta.url), '../../../node_modules/@lobehub/ui/es'),- );+ const esRoot = realpathSync(path.dirname(createRequire(import.meta.url).resolve('@lobehub/ui')));const maps: Record<string, Barrel> = {};for (const barrel of BARRELS) {const barrelDir = barrel ? `${barrel}/` : '';diff --git a/plugins/vite/sharedRendererConfig.test.ts b/plugins/vite/sharedRendererConfig.test.tsindex 59f5be46de1..868e6f2aff1 100644--- a/plugins/vite/sharedRendererConfig.test.ts+++ b/plugins/vite/sharedRendererConfig.test.ts@@ -21,6 +21,33 @@ describe('sharedRendererPlugins', () => {});});+describe('lobe-dev-editor-provider', () => {+ it('sends the provider entry back to the one prebundled editor bundle', async () => {+ const plugin = sharedRendererPlugins({ platform: 'web' })+ .flat(Number.POSITIVE_INFINITY)+ .find(+ (+ item,+ ): item is { name: string; resolveId: (source: string, importer: string) => unknown } =>+ Boolean(item) &&+ typeof item === 'object' &&+ (item as { name?: string }).name === 'lobe-dev-editor-provider',+ );++ const resolve = async (source: string) =>+ plugin!.resolveId.call(+ { resolve: async (id: string) => ({ id }) },+ source,+ '/repo/src/layout/GlobalProvider/Editor.tsx',+ );++ await expect(resolve('@lobehub/editor/react/EditorProvider')).resolves.toEqual({+ id: '@lobehub/editor/react',+ });+ await expect(resolve('@lobehub/editor/react')).resolves.toBeNull();+ });+});+describe('sharedOptimizeDeps', () => {it('pre-bundles the root and base-ui entrypoints together', () => {expect(sharedOptimizeDeps.include).toEqual(diff --git a/plugins/vite/sharedRendererConfig.ts b/plugins/vite/sharedRendererConfig.tsindex 763f3915b99..eef12a95ffe 100644--- a/plugins/vite/sharedRendererConfig.ts+++ b/plugins/vite/sharedRendererConfig.ts@@ -408,17 +408,16 @@ export function sharedRendererPlugins(options: SharedRendererOptions) {viteNodeModuleStub(),vitePlatformResolve(options.platform),- // GlobalProvider/Editor.tsx reaches @lobehub/editor's provider by file path- // (the export map has no provider-only entry) so the editor runtime stays- // off the first screen. In dev that path is served raw while the editors- // use the prebundled @lobehub/editor/react, which would create a second- // EditorContext; point the dev import back at the bundle.+ // Editor.tsx takes the provider-only entry so the editor runtime stays off+ // the first screen. In dev that entry is prebundled separately from+ // @lobehub/editor/react, which the editors use, giving the app a second+ // EditorContext; point the dev import back at the one bundle.isDev &&({enforce: 'pre',name: 'lobe-dev-editor-provider',resolveId(source, importer) {- if (!source.includes('@lobehub/editor/es/react/EditorProvider')) return null;+ if (source !== '@lobehub/editor/react/EditorProvider') return null;return this.resolve('@lobehub/editor/react', importer, { skipSelf: true });},} satisfies Plugin),diff --git a/src/layout/GlobalProvider/Editor.tsx b/src/layout/GlobalProvider/Editor.tsxindex fdd67355987..4ddc2736cda 100644--- a/src/layout/GlobalProvider/Editor.tsx+++ b/src/layout/GlobalProvider/Editor.tsx@@ -1,14 +1,13 @@'use client';+// @lobehub/editor/react re-exports the whole editor runtime (lexical, yjs,+// fuse) and rolldown does not shake it down to the provider, so take the+// provider-only entry to keep that runtime off the first screen.+import { EditorProvider } from '@lobehub/editor/react/EditorProvider';import { type PropsWithChildren } from 'react';import { memo, useMemo } from 'react';import { useTranslation } from 'react-i18next';-// @lobehub/editor/react re-exports the whole editor runtime (lexical, yjs,-// fuse) and rolldown does not shake it down to the provider, so reach the-// context module by path until the package exposes a provider-only entry.-import { EditorProvider } from '../../../node_modules/@lobehub/editor/es/react/EditorProvider';-const Editor = memo<PropsWithChildren>(({ children }) => {const {i18n: { language, getResourceBundle },