Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

fix(notfair-cmo): make standalone build runnable

Yuting Zhongd7ace24baac4
diff --git a/notfair-cmo/next-env.d.ts b/notfair-cmo/next-env.d.ts
index c4b7818f..9edff1c7 100644
--- a/notfair-cmo/next-env.d.ts
+++ b/notfair-cmo/next-env.d.ts
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
-import "./.next/dev/types/routes.d.ts";
+import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/notfair-cmo/next.config.ts b/notfair-cmo/next.config.ts
index ab45aaca..fc6391dd 100644
--- a/notfair-cmo/next.config.ts
+++ b/notfair-cmo/next.config.ts
@@ -3,6 +3,15 @@ import type { NextConfig } from "next";
const config: NextConfig = {
output: "standalone",
serverExternalPackages: ["better-sqlite3", "keytar"],
+ // pnpm + standalone output drops transitive deps that Next.js's own
+ // compiled chunks require at runtime (e.g. @swc/helpers, @next/env).
+ // Force-include them so the published tarball boots.
+ outputFileTracingIncludes: {
+ "*": [
+ "./node_modules/@swc/helpers/**/*",
+ "./node_modules/@next/env/**/*",
+ ],
+ },
// typedRoutes intentionally disabled in V1 — our nav table builds Link hrefs
// dynamically. Re-enable once the route map settles and Link wrappers can
// be properly typed.
diff --git a/notfair-cmo/package.json b/notfair-cmo/package.json
index d92a5b96..4677890e 100644
--- a/notfair-cmo/package.json
+++ b/notfair-cmo/package.json
@@ -28,9 +28,11 @@
"dependencies": {
"@ai-sdk/anthropic": "^1.0.0",
"@ai-sdk/openai": "^1.0.0",
+ "@next/env": "16.2.6",
"@radix-ui/react-dialog": "^1.1.0",
"@radix-ui/react-dropdown-menu": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
+ "@swc/helpers": "^0.5.21",
"ai": "^4.0.0",
"better-sqlite3": "^12.10.0",
"class-variance-authority": "^0.7.0",
diff --git a/notfair-cmo/pnpm-lock.yaml b/notfair-cmo/pnpm-lock.yaml
index 2e2659f7..f7195005 100644
--- a/notfair-cmo/pnpm-lock.yaml
+++ b/notfair-cmo/pnpm-lock.yaml
@@ -14,6 +14,9 @@ importers:
'@ai-sdk/openai':
specifier: ^1.0.0
version: 1.3.24([email protected])
+ '@next/env':
+ specifier: 16.2.6
+ version: 16.2.6
'@radix-ui/react-dialog':
specifier: ^1.1.0
@@ -23,6 +26,9 @@ importers:
'@radix-ui/react-slot':
specifier: ^1.1.0
version: 1.2.4(@types/[email protected])([email protected])
+ '@swc/helpers':
+ specifier: ^0.5.21
+ version: 0.5.21
ai:
specifier: ^4.0.0
@@ -1634,6 +1640,9 @@ packages:
resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}
+ resolution: {integrity: sha512-jI/VAmtdjB/RnI8GTnokyX7Ug8c+g+ffD6QRLa6XQewtnGyukKkKSk3wLTM3b5cjt1jNh9x0jfVlagdN2gDKQg==}
+
'@tailwindcss/[email protected]':
resolution: {integrity: sha512-aFb4gUhFOgdh9AXo4IzBEOzBkkAxm9VigwDJnMIYv3lcfXCJVesNfbEaBl4BNgVRyid92AmdviqwBUBRKSeY3g==}
@@ -5597,6 +5606,10 @@ snapshots:
dependencies:
tslib: 2.8.1
+ dependencies:
+ tslib: 2.8.1
+
'@tailwindcss/[email protected]':
dependencies:
'@jridgewell/remapping': 2.3.5
diff --git a/notfair-cmo/scripts/copy-standalone-assets.mjs b/notfair-cmo/scripts/copy-standalone-assets.mjs
index c1c056f5..d464c758 100644
--- a/notfair-cmo/scripts/copy-standalone-assets.mjs
+++ b/notfair-cmo/scripts/copy-standalone-assets.mjs
@@ -36,24 +36,25 @@ for (const { src, dest } of targets) {
console.log(`Copied ${src.replace(ROOT + "/", "")} → ${dest.replace(ROOT + "/", "")}`);
}
-// Dereference symlinks in-place so npm pack ships real files. We use `cp -RL`
-// via the system shell because Node's cpSync has trouble with the pnpm-style
-// symlink layout (multiple symlinks pointing into the same .pnpm dir create
-// cpSync EISDIR errors).
+// Dereference symlinks in-place so npm pack ships real files. We pipe `tar
+// -ch | tar -x` because it follows chained pnpm symlinks correctly during
+// archive creation. Earlier approaches (`cp -RL`, `rsync -aL`) silently
+// dropped entries whose symlink chain had any dangling link, which produced
+// broken standalone bundles missing transitive deps like `@swc/helpers` and
+// `@next/env`.
const DEREF = STANDALONE + ".deref-tmp";
rmSync(DEREF, { recursive: true, force: true });
const parent = dirname(STANDALONE);
const standaloneName = basename(STANDALONE);
-// `cp -RL` exits 1 on any dangling symlink it encounters (pnpm sometimes
-// leaves a `.pnpm/node_modules/semver` symlink with no target). The copy
-// still completes successfully — the dangling entry is just dropped. We
-// verify the result via countSymlinks() below rather than relying on cp's
-// exit code.
-try {
- execSync(`cp -RL "${standaloneName}" "${basename(DEREF)}"`, { cwd: parent, stdio: "inherit" });
-} catch (err) {
- if (!existsSync(DEREF)) throw err;
-}
+const derefName = basename(DEREF);
+// tar -h dereferences symlinks during archive creation; the second tar
+// extracts. Both run inside the parent dir so relative paths stay clean.
+// 2>/dev/null on the first tar swallows the warnings about dangling pnpm
+// links that we intentionally want to skip.
+execSync(
+ `mkdir -p "${derefName}" && tar -ch -f - -C "${standaloneName}" . 2>/dev/null | tar -x -C "${derefName}"`,
+ { cwd: parent, stdio: "inherit", shell: "/bin/bash" },
+);
rmSync(STANDALONE, { recursive: true, force: true });
renameSync(DEREF, STANDALONE);
console.log(`Dereferenced symlinks under ${STANDALONE.replace(ROOT + "/", "")}`);
diff --git a/notfair-cmo/src/app/onboarding/page.tsx b/notfair-cmo/src/app/onboarding/page.tsx
index 10de8d76..226086dc 100644
--- a/notfair-cmo/src/app/onboarding/page.tsx
+++ b/notfair-cmo/src/app/onboarding/page.tsx
@@ -1,5 +1,12 @@
+import { Suspense } from "react";
import { OnboardingFlow } from "@/components/onboarding-flow";
+export const dynamic = "force-dynamic";
+
export default function OnboardingPage() {
- return <OnboardingFlow />;
+ return (
+ <Suspense fallback={null}>
+ <OnboardingFlow />
+ </Suspense>
+ );
}
diff --git a/notfair-cmo/src/components/onboarding-flow.tsx b/notfair-cmo/src/components/onboarding-flow.tsx
index 554fd6bd..9d39cfa1 100644
--- a/notfair-cmo/src/components/onboarding-flow.tsx
+++ b/notfair-cmo/src/components/onboarding-flow.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useActionState, useEffect, useRef, useState } from "react";
+import { Suspense, useActionState, useEffect, useRef, useState } from "react";
import { useRouter, useSearchParams } from "next/navigation";
import Link from "next/link";
import { AlertCircle, ChevronRight, FolderOpen, Loader2, Plug } from "lucide-react";
@@ -25,6 +25,14 @@ import {
type Step = "name" | "connect" | "account" | "setup";
export function OnboardingFlow() {
+ return (
+ <Suspense fallback={null}>
+ <OnboardingFlowInner />
+ </Suspense>
+ );
+}
+
+function OnboardingFlowInner() {
const router = useRouter();
const params = useSearchParams();
const stepParam = params.get("step");