Skip to content
Closed
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
82 changes: 82 additions & 0 deletions apps/cloud/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,95 @@
* This repository utilizes multiple licenses across different directories. To
* see this files license find the nearest LICENSE file up the source tree.
*/
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import type { NextConfig } from "next";

const __dirname = dirname(fileURLToPath(import.meta.url));

const nextConfig: NextConfig = {
transpilePackages: ["@triplex/lib"],
// esbuild ships platform-specific binary packages whose folders contain a
// README.md that Turbopack tries to parse as a module. Keep it out of the
// bundle and let Node resolve it at runtime.
serverExternalPackages: ["esbuild"],

Check failure on line 18 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'serverExternalPackages' should be before 'transpilePackages'
// The /api/triplex-bundle + /api/pkg/[...name] routes read prebuilt files
// from `packages/<n>/{dist,themes,package.json}` at runtime via fs.readdir.
// Next's auto-tracing can't see those reads, so we point it at the
// monorepo root and include the workspace pkgs explicitly. Without this,
// Vercel ships an empty `packages/` tree and the prod-bundle endpoint
// returns the unrewritten src-pointing package.json.
outputFileTracingRoot: join(__dirname, "../.."),

Check failure on line 25 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'outputFileTracingRoot' should be before 'serverExternalPackages'
outputFileTracingIncludes: {

Check failure on line 26 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'outputFileTracingIncludes' should be before 'outputFileTracingRoot'
"/api/triplex-bundle": [
"../../packages/renderer/dist/**",
"../../packages/renderer/themes/**",
"../../packages/renderer/package.json",
"../../packages/bridge/dist/**",
"../../packages/bridge/package.json",
"../../packages/lib/dist/**",
"../../packages/lib/themes/**",
"../../packages/lib/package.json",
],
"/api/pkg/[...name]": [

Check failure on line 37 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. '/api/pkg/[...name]' should be before '/api/triplex-bundle'
"../../packages/renderer/**",
"../../packages/bridge/**",
"../../packages/lib/**",
"../../packages/@triplex/**",
],
},
typescript: {
ignoreBuildErrors: true,
},
// The Web Worker (`wss-worker.ts`) pulls in @triplex/lib/path which
// imports node:path. path-browserify also works in the server runtime,
// so a single global alias is fine. node:fs / node:os only get used by
// server code paths — leaving them on the real module so API routes
// (e.g. /api/pkg-watch's fs.watch) keep their behaviour.
turbopack: {

Check failure on line 52 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'turbopack' should be before 'typescript'
resolveAlias: {
"node:path": "path-browserify",
},
},
// The Web Worker (`wss-worker.ts`) pulls in @triplex/server + @triplex/lib
// which use `node:path`, `node:fs`, and `node:os`. Webpack's prod build
// doesn't know how to resolve `node:` URIs in browser bundles. Provide
// browser-safe shims so the prod build succeeds; the worker only ever
// calls `path`'s pure-string helpers — `fs` and `os` are imported but the
// calls are guarded out of the browser code paths.
webpack(config, { isServer, webpack }) {
if (!isServer) {
// Webpack 5 rejects `node:*` URIs before they reach `resolve.alias`,
// so we have to intercept them via NormalModuleReplacementPlugin and
// rewrite the request to either a browser shim or an empty module.
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/^node:path$/,
(resource: { request: string }) => {
resource.request = "path-browserify";
},
),
new webpack.NormalModuleReplacementPlugin(
/^node:(fs|os)$/,
(resource: { request: string }) => {
resource.request = require.resolve("./src/lib/empty-node-module");
},
),
);
}
return config;
},
async headers() {

Check failure on line 85 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'headers' should be before 'webpack'
return [
{
source: "/:path*",
headers: [

Check failure on line 89 in apps/cloud/next.config.ts

View workflow job for this annotation

GitHub Actions / lint

Expected object keys to be in ascending order. 'headers' should be before 'source'
{ key: "Cross-Origin-Embedder-Policy", value: "require-corp" },
{ key: "Cross-Origin-Opener-Policy", value: "same-origin" },
],
},
];
},
};

export default nextConfig;
7 changes: 6 additions & 1 deletion apps/cloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@
"private": true,
"license": "SEE LICENSE IN LICENSE",
"scripts": {
"build": "next build",
"build": "pnpm --filter @triplex/renderer --filter @triplex/bridge --filter @triplex/lib build && next build",
"dev": "next dev --turbopack",
"start": "next start",
"typedef": "tsc"
},
"dependencies": {
"@ai-sdk/google": "^1.2.14",
"@triplex/lib": "0.69.20",
"@triplex/server": "workspace:*",
"@webcontainer/api": "^1.6.4",
"ai": "^4.3.12",
"next": "15.3.8",
"path-browserify": "^1.0.1",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"ts-morph": "^25.0.1",
"valibot": "^0.25.0"
},
"devDependencies": {
"@types/kill-port": "^2.0.3",
"@types/node": "^22.15.17",
"@types/react": "^19.1.6",
"@types/react-dom": "^19.1.5",
"esbuild": "^0.24.2",
"kill-port": "^2.0.1",
"tree-kill": "^1.2.2",
"typescript": "^5.8.3"
Expand Down
Loading
Loading