akanjs 3.0.0-alpha.13 → 3.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/akanApp.ts +7 -1
- package/server/webRouter.ts +9 -1
package/package.json
CHANGED
package/server/akanApp.ts
CHANGED
|
@@ -190,10 +190,16 @@ export class AkanApp {
|
|
|
190
190
|
return Math.max(min, parsed);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* The command that started this gateway outranks an inherited `NODE_ENV`: the command is a statement about
|
|
195
|
+
* this run, while the env var can arrive from a shell export, a CI image, or the workspace `.env` Bun loads
|
|
196
|
+
* on its own. Handing a dev child `NODE_ENV=production` makes it serve from the production route cache and
|
|
197
|
+
* throw on every route, since only `akan build` writes the routes manifest that cache expects.
|
|
198
|
+
*/
|
|
193
199
|
static #defaultChildNodeEnv() {
|
|
194
|
-
if (process.env.NODE_ENV) return process.env.NODE_ENV;
|
|
195
200
|
if (process.env.AKAN_COMMAND_TYPE === "start") return "development";
|
|
196
201
|
if (process.env.AKAN_COMMAND_TYPE === "build") return "production";
|
|
202
|
+
if (process.env.NODE_ENV) return process.env.NODE_ENV;
|
|
197
203
|
return Bun.main.endsWith(".js") ? "production" : "development";
|
|
198
204
|
}
|
|
199
205
|
|
package/server/webRouter.ts
CHANGED
|
@@ -287,7 +287,13 @@ export class WebRouter {
|
|
|
287
287
|
#subRoutes: Record<string, string[]>;
|
|
288
288
|
#rsc: RscWorker;
|
|
289
289
|
#hub: HmrWsHub | null = null;
|
|
290
|
-
|
|
290
|
+
/**
|
|
291
|
+
* `akan start` is the dev server whatever the environment claims. Its artifact directory carries no routes
|
|
292
|
+
* manifest — only `akan build` writes one — so the production branch cannot build a route on demand and
|
|
293
|
+
* throws on every request instead. `NODE_ENV` arrives by accident often enough (a workspace `.env` Bun loads
|
|
294
|
+
* on its own, a CI image default) that the command which started this process has to outrank it.
|
|
295
|
+
*/
|
|
296
|
+
#prodMode = process.env.NODE_ENV === "production" && process.env.AKAN_COMMAND_TYPE !== "start";
|
|
291
297
|
#builderRpc: BuilderRpc | null;
|
|
292
298
|
#routeCache: RouteClientCache;
|
|
293
299
|
#devHmr: DevHmrController | null = null;
|
|
@@ -316,6 +322,8 @@ export class WebRouter {
|
|
|
316
322
|
#seedIndex: RouteSeedIndex;
|
|
317
323
|
constructor({ artifact, cssBytesByUrl, rsc, seedIndex, upgradeHmrWs }: WebRouterOptions) {
|
|
318
324
|
this.#logger.verbose(`[SSR] loaded ${Object.keys(cssBytesByUrl).length} CSS assets`);
|
|
325
|
+
if (process.env.NODE_ENV === "production" && !this.#prodMode)
|
|
326
|
+
this.#logger.warn("[SSR] NODE_ENV=production ignored under `akan start`; serving in dev mode");
|
|
319
327
|
this.#artifact = artifact;
|
|
320
328
|
const { subRoutes, ignoredBasePaths } = resolveSubRouteHosts({
|
|
321
329
|
subRoutes: artifact.subRoutes,
|