Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/fern-dashboard/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/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.
89 changes: 58 additions & 31 deletions packages/fern-dashboard/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* eslint-disable turbo/no-undeclared-env-vars */

import rspack from "@next/rspack-core";
import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
import rspack from "@rspack/core";
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next";
import ForceCompleteRuntimePlugin from "next/dist/build/webpack/plugins/force-complete-runtime";
import withRspack from "next-rspack";
import webpack from "webpack";

const isRspackEnabled = process.env.NODE_ENV === "development";
// https://github.com/vercel/next.js/blob/v16.0.0/packages/next-rspack/index.js#L7C19-L17
const isRspackEnabled =
process.env.NODE_ENV === "development" && (!process.env.TURBOPACK || process.env.TURBOPACK === "auto");
const isSentryEnabled = process.env.NODE_ENV === "production";

const CSP_HEADER = `
Expand Down Expand Up @@ -35,21 +38,46 @@ let nextConfig: NextConfig = {
// this will separate the `createLowlight` from the `all` import
"lowlight"
],
useCache: true,
turbo: {
rules: {
"*.frag": {
loaders: ["raw-loader"],
as: "*.js"
},
"*.vert": {
loaders: ["raw-loader"],
as: "*.js"
},
"*.glsl": {
loaders: ["raw-loader"],
as: "*.js"
}
useCache: true
},

turbopack: {
rules: {
"*.frag": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
},
"*.vert": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
},
"*.glsl": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
}
}
},
Expand Down Expand Up @@ -84,7 +112,12 @@ let nextConfig: NextConfig = {
qualities: [75, 100]
},
webpack: (config, { isServer }) => {
const pack = isRspackEnabled ? rspack : webpack;

config.externals = config.externals || [];
config.externals.push(
// esbuild is only used on the server (mdx-bundler)
"esbuild",
"sharp",
// mongodb subdependencies are optional, and need to be externalized for rspack.
// add them + install dependencies as needed.
Expand All @@ -110,9 +143,14 @@ let nextConfig: NextConfig = {
"./node_modules/@fern-api/venus-api-sdk/dist/cjs/index.js"
);

config.plugins ??= [];
config.plugins = config.plugins || [];

if (isRspackEnabled) {
config.plugins = config.plugins.filter((plugin) => !(plugin instanceof ForceCompleteRuntimePlugin));
}

config.plugins.push(
new (isRspackEnabled ? rspack : webpack).DefinePlugin({
new pack.DefinePlugin({
"process.env.NEXT_PUBLIC_BUILD_TIMESTAMP": JSON.stringify(new Date().toISOString())
})
);
Expand All @@ -126,16 +164,10 @@ let nextConfig: NextConfig = {
}
];

// esbuild is only used on the server (mdx-bundler), so only externalize it there
if (isServer) {
config.externals = config.externals || [];
config.externals.push("esbuild");
}

// ignore all test files
// Use IgnorePlugin to ignore .test.ts and .test.tsx files
config.plugins.push(
new (isRspackEnabled ? rspack : webpack).IgnorePlugin({
new pack.IgnorePlugin({
resourceRegExp: /\.test\.tsx?$/
})
);
Expand Down Expand Up @@ -197,11 +229,6 @@ let nextConfig: NextConfig = {
tsconfigPath: "./tsconfig.app.json"
},

// linting is already handled in ci, so this is not needed
eslint: {
ignoreDuringBuilds: true
},

logging: {
fetches: {
fullUrl: true
Expand Down
14 changes: 7 additions & 7 deletions packages/fern-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"type": "module",
"scripts": {
"clean": "rm -rf ./.next",
"dashboard:build": "next build",
"dashboard:build": "next build --webpack",
"dashboard:dev": "NODE_OPTIONS=\"--max-old-space-size=16384\" next dev",
"dashboard:dev:inspect": "NODE_OPTIONS=\"--max-old-space-size=16384\" NODE_OPTIONS='--inspect' next dev",
"dashboard:dev:turbopack": "next dev --turbopack",
"dashboard:lint": "next lint",
"dashboard:rsd": "RSD=1 NODE_OPTIONS='--max-old-space-size=8192' next build",
"dashboard:rsd": "RSD=1 NODE_OPTIONS='--max-old-space-size=8192' next build --webpack",
"dashboard:rsd:client": "rsdoctor analyze --profile .next/.rsdoctor/manifest.json",
"dashboard:rsd:server": "rsdoctor analyze --profile .next/server/.rsdoctor/manifest.json",
"dashboard:start": "next start",
Expand Down Expand Up @@ -124,7 +124,7 @@
"lucide-react": "^0.460.0",
"mdx-bundler": "^10.1.1",
"motion": "^12.4.7",
"next": "catalog:",
"next": "16.0.0",
"next-themes": "^0.4.4",
"p-limit": "^7.2.0",
"posthog-js": "^1.258.2",
Expand Down Expand Up @@ -152,9 +152,9 @@
},
"devDependencies": {
"@fern-platform/configs": "workspace:*",
"@rsdoctor/cli": "^1.2.3",
"@rsdoctor/rspack-plugin": "^1.2.3",
"@rspack/core": "^1.2.3",
"@rsdoctor/cli": "^1.3.4",
"@rsdoctor/rspack-plugin": "^1.3.4",
"@next/rspack-core": "1.0.0",
"@tailwindcss/postcss": "^4.0.9",
"@tailwindcss/typography": "^0.5.16",
"@types/canvas-confetti": "^1.9.0",
Expand All @@ -171,7 +171,7 @@
"glslify-loader": "^2.0.0",
"mermaid": "catalog:",
"monaco-editor": "0.53.0",
"next-rspack": "^15.5.3",
"next-rspack": "^16.0.0",
"prisma": "5.13.0",
"raw-loader": "^4.0.2",
"sass": "^1.77.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { Button } from "@/components/ui/button";
import AcceptInviteSuccess from "./AcceptInviteSuccess";
import "./invite-page.scss";

export const revalidate = 0;

export default async function AcceptInvitePage({ params }: { params: Promise<{ token: string }> }) {
const { token } = await params;
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { unstable_noStore as noStore } from "next/cache";
import { type NextRequest, NextResponse } from "next/server";

import type { ResolvedReturnType } from "@/utils/types";
Expand All @@ -10,6 +11,7 @@ export declare namespace getMyOrganizations {
}

export async function GET(req: NextRequest) {
noStore();
const maybeSessionData = await maybeGetCurrentSession(req);
if (maybeSessionData.errorResponse != null) {
return maybeSessionData.errorResponse;
Expand Down
2 changes: 0 additions & 2 deletions packages/fern-dashboard/src/components/auth/OrgSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { getAvailableOrgsForUser } from "@/app/services/dal/fdr/getAvailableOrgs

import { OrgSwitcherClient } from "./OrgSwitcherClient";

export const revalidate = 0;

export async function OrgSwitcher({ currentOrgName }: { currentOrgName?: Auth0OrgName }) {
const session = await getCurrentSession();
if (session == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type NextRequest, NextResponse } from "next/server";
import { buildErrorPageSearchParams } from "./app/error/searchParams";
import { getAuth0Client } from "./app/services/auth0/auth0";

export async function middleware(req: NextRequest) {
export async function proxy(req: NextRequest) {
if (req.nextUrl.pathname.startsWith("/ingest")) {
return applyPosthogMiddleware(req);
}
Expand Down
44 changes: 42 additions & 2 deletions packages/fern-docs/bundle/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ const nextConfig: NextConfig = {

// speed up build
typescript: { ignoreBuildErrors: true },
eslint: { ignoreDuringBuilds: true },

skipMiddlewareUrlNormalize: true,
skipProxyUrlNormalize: true,

/**
* This is required for posthog. See https://posthog.com/docs/advanced/proxy/nextjs-middleware
Expand Down Expand Up @@ -242,6 +241,47 @@ const nextConfig: NextConfig = {
path: cdnUri != null ? `${cdnUri.href}_next/image` : undefined
},
serverExternalPackages: ["esbuild", "@typescript/vfs"],

turbopack: {
rules: {
"*.frag": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
},
"*.vert": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
},
"*.glsl": {
loaders: [
"raw-loader",
{
loader: "glslify-loader",
options: {
transform: ["glslify-import"]
}
}
],
as: "*.js"
}
}
},
webpack: (config, { isServer }) => {
// config.optimization = {
// ...config.optimization,
Expand Down
15 changes: 8 additions & 7 deletions packages/fern-docs/bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
"check-types": "tsc --noEmit",
"chromatic": "pnpx chromatic --project-token=chpt_48b3c560025e978",
"depcheck": "depcheck",
"docs:build": "NODE_OPTIONS=\"--max-old-space-size=8192\" next build",
"docs:build:local": "NODE_OPTIONS=\"--max-old-space-size=8192\" NEXT_PUBLIC_IS_LOCAL=1 next build && pnpm tsc --project tsconfig.local.json",
"docs:build:selfhosted": "NODE_OPTIONS=\"--max-old-space-size=8192\" NODE_ENV=production QSTASH_TOKEN=abc NEXT_PUBLIC_IS_SELF_HOSTED=1 next build && pnpm tsc --project tsconfig.local.json",
"docs:build:selfserved": "NODE_OPTIONS=\"--max-old-space-size=8192\" NODE_ENV=production NEXT_PUBLIC_IS_SELF_SERVED=1 next build && pnpm tsc --project tsconfig.local.json",
"docs:build": "NODE_OPTIONS=\"--max-old-space-size=8192\" next build --webpack",
"docs:build:local": "NODE_OPTIONS=\"--max-old-space-size=8192\" NEXT_PUBLIC_IS_LOCAL=1 next build --webpack && pnpm tsc --project tsconfig.local.json",
"docs:build:selfhosted": "NODE_OPTIONS=\"--max-old-space-size=8192\" NODE_ENV=production QSTASH_TOKEN=abc NEXT_PUBLIC_IS_SELF_HOSTED=1 next build --webpack && pnpm tsc --project tsconfig.local.json",
"docs:build:selfserved": "NODE_OPTIONS=\"--max-old-space-size=8192\" NODE_ENV=production NEXT_PUBLIC_IS_SELF_SERVED=1 next build --webpack && pnpm tsc --project tsconfig.local.json",
"docs:clean:local": "rm -rf .next next-env.d.ts dist .turbo",
"docs:dev": "NODE_OPTIONS=\"--max-old-space-size=16384\" NEXT_PUBLIC_IS_DOCS_DEV=true next dev",
"docs:dev": "NODE_OPTIONS=\"--max-old-space-size=16384\" NEXT_PUBLIC_IS_DOCS_DEV=true next dev --webpack",
"docs:dev:turbopack": "NODE_OPTIONS=\"--max-old-space-size=16384\" NEXT_PUBLIC_IS_DOCS_DEV=true next dev --turbopack",
"docs:dev:inspect": "NODE_OPTIONS=\"--max-old-space-size=16384\" NEXT_PUBLIC_IS_DOCS_DEV=true NODE_OPTIONS='--inspect' next dev",
"docs:hide-env": "mv .env.local .env.local.hidden",
"docs:lint": "next lint",
Expand Down Expand Up @@ -124,7 +125,7 @@
"meilisearch": "^0.51.0",
"mermaid": "catalog:",
"motion": "^12.4.7",
"next": "catalog:",
"next": "16.0.0",
"next-themes": "^0.4.4",
"posthog-js": "^1.276.0",
"pretty-bytes": "^6.1.1",
Expand Down Expand Up @@ -160,7 +161,7 @@
"@chromatic-com/storybook": "^3.2.4",
"@fern-api/docs-auth": "workspace:*",
"@fern-platform/configs": "workspace:*",
"@next/bundle-analyzer": "catalog:",
"@next/bundle-analyzer": "16.0.0",
"@storybook/addon-essentials": "^8.6.12",
"@storybook/addon-interactions": "^8.6.12",
"@storybook/addon-links": "^8.6.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { type NextRequest, NextResponse } from "next/server";
import { getFaiClient } from "@/getFaiClient";

export const maxDuration = 60;
export const revalidate = 0;

export async function POST(req: NextRequest) {
if (isLocal() || isSelfHosted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import "server-only";
import { createCachedDocsLoader } from "@fern-api/docs-loader";
import { slugjoin } from "@fern-api/fdr-sdk/navigation";
import type { Metadata } from "next/types";
import { Suspense } from "react";

import { getFernToken } from "@/app/fern-token";
import RootPage from "@/app/page";
import { generateMetadataFromPage } from "@/components/seo";
import SharedPage from "@/components/shared-page";

export default async function DynamicPage(props: { params: Promise<{ host: string; domain: string; slug: string }> }) {
export default function DynamicPage(props: { params: Promise<{ host: string; domain: string; slug: string }> }) {
return (
<Suspense fallback={null}>
<DynamicPageContent params={props.params} />
</Suspense>
);
}

async function DynamicPageContent(props: { params: Promise<{ host: string; domain: string; slug: string }> }) {
const { host, domain, slug } = await props.params;

if (slug === "index.html") {
Expand Down
Loading