-
Notifications
You must be signed in to change notification settings - Fork 2
feat: ENABLE_MINI feature flag + conditional build (#409) #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,6 +69,9 @@ | |
| "zod": "^4.3.6", | ||
| "zod-openapi": "^5.4.6" | ||
| }, | ||
| "optionalDependencies": { | ||
| "pubnub": "^10.2.9" | ||
| }, | ||
|
Comment on lines
+72
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update CI is already red on 🤖 Prompt for AI Agents |
||
| "devDependencies": { | ||
| "@babel/preset-typescript": "^7.28.5", | ||
| "@eslint/css": "^1.0.0", | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,13 @@ import { waterLevelRouter } from './waterLevel' | |
| import { runOnceRouter } from './runOnce' | ||
| import { scheduleGroupsRouter } from './scheduleGroups' | ||
|
|
||
| // Mini router — conditional dynamic import, only loaded when ENABLE_MINI=true. | ||
| // When disabled: no Mini code is bundled (webpack resolve alias → false), | ||
| // no PubNub SDK loaded, no Mini routes registered. | ||
| const miniRouter = process.env.ENABLE_MINI === 'true' | ||
| ? (await import('./mini')).miniRouter | ||
| : null | ||
|
Comment on lines
+16
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Find build config files
git ls-files | grep -E '(next\.config|webpack|tsconfig|\.env)' | head -20Repository: sleepypod/core Length of output: 106 🏁 Script executed: # Search for ENABLE_MINI references in the codebase
rg 'ENABLE_MINI' --type ts --type js --type json -nRepository: sleepypod/core Length of output: 249 🏁 Script executed: # Check the structure of src/server/routers/
ls -la src/server/routers/ 2>/dev/null || echo "Directory not found"Repository: sleepypod/core Length of output: 1152 🏁 Script executed: # Look for the mini module
fd -type f -path '*mini*' | grep -E '\.(ts|js|tsx|jsx)$' | head -20Repository: sleepypod/core Length of output: 228 🏁 Script executed: # Check next.config.mjs for any aliases or configuration
cat next.config.mjs 2>/dev/null | head -100Repository: sleepypod/core Length of output: 1454 🏁 Script executed: # Read the mini.ts file to see what it contains
cat -n src/server/routers/mini.tsRepository: sleepypod/core Length of output: 509 🏁 Script executed: # Check if there are any other references to the mini router or ENABLE_MINI in app.ts
cat -n src/server/routers/app.tsRepository: sleepypod/core Length of output: 2248 🏁 Script executed: # Search for any build-time webpack plugin or setup for env variable handling
rg 'DefinePlugin|process.env' next.config.mjs webpack.configRepository: sleepypod/core Length of output: 199 🏁 Script executed: # Check if mini.ts has any dependencies on pubnub
rg -A 5 -B 5 'pubnub|pubsub' src/server/routers/mini.ts src/server/trpc.ts 2>/dev/null || echo "No pubnub refs found in mini or trpc"Repository: sleepypod/core Length of output: 94 🏁 Script executed: # Search for any build-time env defines or extra webpack config
rg 'DefinePlugin|ENABLE_MINI' . --type js --type mjs -A 3 -B 3 2>/dev/null | head -50Repository: sleepypod/core Length of output: 40 🏁 Script executed: # Check if there's any documentation about the build exclusion objective
cat README.md 2>/dev/null | grep -i -A 5 -B 5 'mini\|enable_mini\|bundle' | head -40Repository: sleepypod/core Length of output: 827 The static import statement creates a dependency edge without explicit build-time exclusion. The code conditionally imports
The inline comment claiming "webpack resolve alias → false" is misleading since the alias only applies to pubnub, not to the mini module itself. 🤖 Prompt for AI Agents |
||
|
|
||
| export const appRouter = router({ | ||
| healthcheck: publicProcedure | ||
| .meta({ openapi: { method: 'GET', path: '/healthcheck', protect: false, tags: ['Health'] } }) | ||
|
|
@@ -35,6 +42,7 @@ export const appRouter = router({ | |
| waterLevel: waterLevelRouter, | ||
| runOnce: runOnceRouter, | ||
| scheduleGroups: scheduleGroupsRouter, | ||
| ...(miniRouter ? { mini: miniRouter } : {}), | ||
| }) | ||
|
|
||
| export type AppRouter = typeof appRouter | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { z } from 'zod' | ||
| import { publicProcedure, router } from '@/src/server/trpc' | ||
|
|
||
| export const miniRouter = router({ | ||
| status: publicProcedure | ||
| .meta({ openapi: { method: 'GET', path: '/mini/status', protect: false, tags: ['Mini'] } }) | ||
| .input(z.object({})) | ||
| .output(z.object({ | ||
| enabled: z.boolean(), | ||
| })) | ||
| .query(() => ({ enabled: true })), | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /** | ||
| * Snoo client — Auth (OAuth PKCE) and data API. | ||
| * Stub: implementation comes in the TS Snoo client step. | ||
| */ | ||
|
|
||
| export class SnooClient { | ||
| // OAuth PKCE auth flow to Happiest Baby | ||
| async authenticate(): Promise<void> { | ||
| throw new Error('Not implemented — awaiting TS Snoo client step') | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export { SnooClient } from './client' | ||
| export { MiniPubNubManager } from './pubnub' | ||
| export type { MiniSession, MiniStatus, MiniSettings, MiniLevel, MiniCommand } from './types' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /** | ||
| * PubNub subscription manager for real-time Snoo state and commands. | ||
| * Stub: implementation comes in the TS Snoo client step. | ||
| */ | ||
|
|
||
| export class MiniPubNubManager { | ||
| async connect(): Promise<void> { | ||
| throw new Error('Not implemented — awaiting TS Snoo client step') | ||
| } | ||
|
|
||
| async disconnect(): Promise<void> { | ||
| // no-op until implemented | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /** | ||
| * TypeScript types matching the Snoo data model. | ||
| * Populated in the TS Snoo client implementation step. | ||
| */ | ||
|
|
||
| export interface MiniSession { | ||
| sessionId: string | ||
| startTime: string | ||
| endTime?: string | ||
| levels: MiniLevel[] | ||
| } | ||
|
|
||
| export interface MiniStatus { | ||
| isOnline: boolean | ||
| babyName?: string | ||
| firmwareVersion?: string | ||
| lastSSID?: string | ||
| } | ||
|
|
||
| export interface MiniSettings { | ||
| responsiveness: 'low' | 'normal' | 'high' | ||
| volume: number | ||
| weaning: boolean | ||
| motionLimiter: boolean | ||
| } | ||
|
|
||
| export type MiniLevel = 'baseline' | 'level1' | 'level2' | 'level3' | 'level4' | ||
|
|
||
| export type MiniCommand = 'start' | 'stop' | 'level_up' | 'level_down' | 'toggle' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Next.js 16.1.6, doesnext devuse Turbopack by default, and should a package alias configured inwebpack.resolve.aliasalso be duplicated inturbopack.resolveAliasto keep module resolution behavior consistent?💡 Result:
In Next.js 16.1.6, next dev uses Turbopack by default. Yes, a package alias configured in webpack.resolve.alias should be duplicated in turbopack.resolveAlias to keep module resolution behavior consistent, as Turbopack does not automatically use webpack aliases and has its own resolveAlias configuration in next.config.js under the top-level turbopack key (moved from experimental in Next.js 16). Multiple GitHub discussions and issues confirm users need to explicitly configure resolveAlias for Turbopack to match webpack behavior, especially for custom aliases, symlinks, or fallbacks.
Citations:
Add the
pubnub: falsealias toturbopack.resolveAliasas well.The
pubnub: falsealias is set in the webpack config but missing fromturbopack.resolveAlias. Since Next.js 16.1.6 uses Turbopack by default, the Mini-off behavior won't work consistently—Turbopack doesn't inherit webpack aliases and requires the alias to be explicitly configured in its ownresolveAliasblock to match webpack behavior.🤖 Prompt for AI Agents