From 790ad2b2795174142b3281f478d0d1b28e19ce9b Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Mon, 18 May 2026 22:00:52 +0200 Subject: [PATCH] fix(vite): alias @nitrots/nitro-renderer umbrella to source index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without an explicit alias for the umbrella package @nitrots/nitro-renderer, vite's resolver follows the node_modules symlink (@nitrots/nitro-renderer -> Nitro_Render_V3) and the \`"main": "./index"\` field, which can land on a stale built \`dist/index.js\` when one exists in the renderer working tree. When that happens the bundle ships pre-snapshot-pattern stubs of SessionDataManager / IgnoredUsersManager / etc. — and the new useSessionInfo / useUserDataSnapshot code calling getUserDataSnapshot() explodes at runtime with the Firefox error TypeError: (intermediate value)() is undefined (which is Firefox's way of reporting a chain like \`GetSessionDataManager().getUserDataSnapshot()\` where the second method is undefined). The reported call site is ToolbarView line 46 because that's the first consumer of useSessionInfo that mounts. Two fixes together: 1. This commit: explicit alias \`@nitrots/nitro-renderer\` -> \`/index.ts\`. Subsequent transitive imports (export * from '@nitrots/api', '@nitrots/events', ...) still go through the existing per-package aliases, so all renderer code is guaranteed-source even when a stale dist exists. 2. Rebuild the renderer's dist (yarn build in Nitro_Render_V3) so that any other consumer that bypasses vite's alias resolution (e.g. an ad-hoc Node script) also sees the current state. Done separately. No source code change to any consumer. The client production build \`yarn build\` now produces a bundle containing getUserDataSnapshot, getIgnoredUsersSnapshot, SESSION_DATA_UPDATED, IGNORED_USERS_UPDATED and the other new symbols — verified via grep on dist/assets/*.js. --- vite.config.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vite.config.mjs b/vite.config.mjs index e4395e2..f4501bb 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -104,6 +104,16 @@ export default defineConfig({ alias: { '@': resolve(__dirname, 'src'), '~': resolve(__dirname, 'node_modules'), + // Force the umbrella to the source index.ts. Without this, + // node-module resolution (via the symlink at + // node_modules/@nitrots/nitro-renderer -> ../Nitro_Render_V3) + // can land on the stale `dist/index.js` when one exists in + // the renderer working tree — leaving the bundle with + // pre-snapshot-pattern stubs and producing runtime errors + // like "TypeError: (intermediate value)() is undefined" + // when newer code calls getUserDataSnapshot() / .subscribe() + // / NitroEventType.SESSION_DATA_UPDATED etc. + '@nitrots/nitro-renderer': resolve(rendererRoot, 'index.ts'), '@nitrots/api': resolve(rendererRoot, 'packages/api/src/index.ts'), '@nitrots/assets': resolve(rendererRoot, 'packages/assets/src/index.ts'), '@nitrots/avatar': resolve(rendererRoot, 'packages/avatar/src/index.ts'),