Skip to content

Commit c3a2c0a

Browse files
committed
add next-build-test binary / library
1 parent dfe7fc0 commit c3a2c0a

File tree

9 files changed

+771
-15
lines changed

9 files changed

+771
-15
lines changed

Cargo.lock

Lines changed: 228 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ members = [
66
"packages/next-swc/crates/napi",
77
"packages/next-swc/crates/wasm",
88
"packages/next-swc/crates/next-api",
9+
"packages/next-swc/crates/next-build-test",
910
"packages/next-swc/crates/next-build",
1011
"packages/next-swc/crates/next-core",
1112
"packages/next-swc/crates/next-custom-transforms",
@@ -22,6 +23,11 @@ debug-assertions = false
2223
[profile.dev.build-override]
2324
opt-level = 3
2425

26+
[profile.release-with-debug]
27+
inherits = "release"
28+
debug = true
29+
lto = "thin"
30+
2531
[workspace.dependencies]
2632
# Workspace crates
2733
next-api = { path = "packages/next-swc/crates/next-api" }
@@ -42,6 +48,7 @@ turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbop
4248
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240521.2" }
4349
# [TODO]: need to refactor embed_directory! macro usage in next-core
4450
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240521.2" }
51+
turbo-tasks-malloc = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240521.2" }
4552

4653
# General Deps
4754

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
[package]
2+
name = "next-build-test"
3+
version = "0.1.0"
4+
description = "TBD"
5+
license = "MPL-2.0"
6+
edition = "2021"
7+
autobenches = false
8+
9+
[lints]
10+
workspace = true
11+
12+
[dependencies]
13+
next-core = { workspace = true, features = ["rustls-tls"] }
14+
next-api = { workspace = true }
15+
serde_json = { workspace = true }
16+
anyhow = { workspace = true }
17+
tokio = { workspace = true, features = ["full"] }
18+
turbo-tasks-malloc = { workspace = true, default-features = false }
19+
turbopack-binding = { workspace = true, features = [
20+
"__turbo_tasks",
21+
"__turbo_tasks_memory",
22+
"__turbo_tasks_env",
23+
"__turbo_tasks_fs",
24+
"__turbo_tasks_memory",
25+
"__turbopack",
26+
"__turbopack_nodejs",
27+
"__turbopack_core",
28+
"__turbopack_browser",
29+
"__turbopack_ecmascript",
30+
"__turbopack_ecmascript_runtime",
31+
"__turbopack_env",
32+
"__turbopack_node",
33+
] }
34+
turbo-tasks = { workspace = true }
35+
rand = { workspace = true, features = ["small_rng"] }
36+
num_cpus = "1.16.0"
37+
tokio-stream = "0.1.15"
38+
tracing = "0.1"
39+
tracing-subscriber = "0.3"
40+
futures-util = "0.3.30"
41+
42+
[build-dependencies]
43+
turbopack-binding = { workspace = true, features = ["__turbo_tasks_build"] }
44+
45+
[dev-dependencies]
46+
iai-callgrind = "0.10.2"
47+
tempdir = "0.3.7"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# next-build-test
2+
3+
This binary lets you sidestep all of the node bundling and run a turbo build
4+
against a raw rust binary. It does _not_ do everything nextjs does, but it
5+
is an ok approximation.
6+
7+
## Getting started
8+
9+
You will need a project_options file that points to some nextjs repo that has
10+
its dependencies installed. The easiest way to do that is to run a nextjs
11+
build using a modified binary that produces one out for you or to run the
12+
`generate` command and tweak it manually. We cannot bundle one in the repo,
13+
since it needs fs-specific paths and env vars.
14+
15+
You can run the binary with the `generate` flag to build one for you.
16+
17+
```sh
18+
cargo run -- generate /path/to/project > project_options.json
19+
cargo run -- run
20+
```
21+
22+
## Flags
23+
24+
The `run` command supports 4 flags:
25+
26+
- `strategy` can be one of sequential, concurrent, or parallel. defines how
27+
work is structured
28+
- `factor` defined how many pages should be built at once. defaults to num_cpus
29+
- `limit` defines the highest number of pages to build. the pages are
30+
shuffled deterministically. defaults to 1 page
31+
- `pages` a comma separated list of routes to run. queues that precise set in
32+
the order specified
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
turbopack_binding::turbo::tasks_build::generate_register();
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"compilerOptions": {
3+
"esModuleInterop": true,
4+
"forceConsistentCasingInFileNames": true,
5+
"noFallthroughCasesInSwitch": true,
6+
"noUncheckedIndexedAccess": false,
7+
"skipLibCheck": true,
8+
"strict": true,
9+
"lib": ["lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.esnext.d.ts"],
10+
"module": 99,
11+
"target": 8,
12+
"moduleResolution": 2,
13+
"incremental": true,
14+
"noEmit": true,
15+
"resolveJsonModule": true,
16+
"isolatedModules": true,
17+
"jsx": 1,
18+
"plugins": [
19+
{
20+
"name": "typescript-plugin-css-modules",
21+
"options": {
22+
"goToDefinition": true
23+
}
24+
},
25+
{
26+
"name": "next"
27+
}
28+
],
29+
"allowJs": true,
30+
"paths": {},
31+
"tsBuildInfoFile": "/tmp/ignore",
32+
"strictNullChecks": true,
33+
"pathsBasePath": "/tmp/ignore"
34+
}
35+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
{
2+
"env": {},
3+
"webpack": {},
4+
"eslint": {
5+
"ignoreDuringBuilds": false
6+
},
7+
"typescript": {
8+
"ignoreBuildErrors": false,
9+
"tsconfigPath": "tsconfig.json"
10+
},
11+
"distDir": ".next",
12+
"cleanDistDir": true,
13+
"assetPrefix": "",
14+
"cacheMaxMemorySize": 52428800,
15+
"configOrigin": "next.config.mjs",
16+
"useFileSystemPublicRoutes": true,
17+
"generateBuildId": null,
18+
"generateEtags": true,
19+
"pageExtensions": ["jsx", "js", "tsx", "ts", "mdx", "md"],
20+
"poweredByHeader": true,
21+
"compress": true,
22+
"analyticsId": "",
23+
"images": {
24+
"deviceSizes": [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
25+
"imageSizes": [16, 32, 48, 64, 96, 128, 256, 384],
26+
"path": "/_next/image",
27+
"loader": "default",
28+
"loaderFile": "",
29+
"domains": [],
30+
"disableStaticImages": false,
31+
"minimumCacheTTL": 60,
32+
"formats": ["image/avif", "image/webp"],
33+
"dangerouslyAllowSVG": false,
34+
"contentSecurityPolicy": "script-src 'none'; frame-src 'none'; sandbox;",
35+
"contentDispositionType": "inline",
36+
"remotePatterns": [],
37+
"unoptimized": false
38+
},
39+
"devIndicators": {
40+
"buildActivity": true,
41+
"buildActivityPosition": "bottom-right"
42+
},
43+
"onDemandEntries": {
44+
"maxInactiveAge": 60000,
45+
"pagesBufferLength": 5
46+
},
47+
"amp": {
48+
"canonicalBase": ""
49+
},
50+
"basePath": "",
51+
"sassOptions": {},
52+
"trailingSlash": false,
53+
"i18n": null,
54+
"productionBrowserSourceMaps": false,
55+
"optimizeFonts": true,
56+
"excludeDefaultMomentLocales": true,
57+
"serverRuntimeConfig": {},
58+
"publicRuntimeConfig": {},
59+
"reactProductionProfiling": false,
60+
"reactStrictMode": true,
61+
"httpAgentOptions": {
62+
"keepAlive": true
63+
},
64+
"outputFileTracing": true,
65+
"staticPageGenerationTimeout": 60,
66+
"swcMinify": true,
67+
"modularizeImports": {},
68+
"experimental": {
69+
"prerenderEarlyExit": false,
70+
"serverMinification": true,
71+
"serverSourceMaps": false,
72+
"linkNoTouchStart": false,
73+
"caseSensitiveRoutes": false,
74+
"clientRouterFilter": true,
75+
"clientRouterFilterRedirects": false,
76+
"fetchCacheKeyPrefix": "",
77+
"middlewarePrefetch": "flexible",
78+
"optimisticClientCache": true,
79+
"manualClientBasePath": false,
80+
"cpus": 2,
81+
"memoryBasedWorkersCount": false,
82+
"isrFlushToDisk": true,
83+
"workerThreads": false,
84+
"optimizeCss": false,
85+
"nextScriptWorkers": false,
86+
"scrollRestoration": false,
87+
"externalDir": false,
88+
"disableOptimizedLoading": false,
89+
"gzipSize": true,
90+
"craCompat": false,
91+
"esmExternals": true,
92+
"fullySpecified": false,
93+
"outputFileTracingRoot": "/tmp/ignore",
94+
"swcTraceProfiling": false,
95+
"forceSwcTransforms": false,
96+
"largePageDataBytes": 128000,
97+
"adjustFontFallbacks": false,
98+
"adjustFontFallbacksWithSizeAdjust": false,
99+
"turbo": {
100+
"rules": {
101+
"*.mdx": {
102+
"loaders": ["turbopack-mdx-loader"],
103+
"as": "*.tsx"
104+
}
105+
},
106+
"resolveAlias": {
107+
"fs": {
108+
"browser": "./turbopack/empty.js"
109+
},
110+
"cookie": {
111+
"browser": "./turbopack/empty.js"
112+
},
113+
"http": {
114+
"browser": "./turbopack/empty.js"
115+
},
116+
"https": {
117+
"browser": "./turbopack/empty.js"
118+
},
119+
"node-fetch": {
120+
"browser": "./turbopack/empty.js"
121+
}
122+
}
123+
},
124+
"typedRoutes": false,
125+
"instrumentationHook": true,
126+
"bundlePagesExternals": false,
127+
"parallelServerCompiles": false,
128+
"parallelServerBuildTraces": false,
129+
"ppr": false,
130+
"missingSuspenseWithCSRBailout": true,
131+
"optimizeServerReact": true,
132+
"useEarlyImport": false,
133+
"serverComponentsExternalPackages": [],
134+
"useLightningcss": true,
135+
"optimizePackageImports": []
136+
},
137+
"configFile": "/tmp/ignore",
138+
"configFileName": "next.config.mjs",
139+
"transpilePackages": [],
140+
"_originalRewrites": {
141+
"beforeFiles": [],
142+
"afterFiles": [],
143+
"fallback": []
144+
},
145+
"_originalRedirects": [],
146+
"exportPathMap": {}
147+
}

0 commit comments

Comments
 (0)