mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
fix(vite): alias @nitrots/nitro-renderer umbrella to source index.ts
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\` -> \`<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.
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user