-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add next-build-test binary / library
- Loading branch information
Showing
9 changed files
with
771 additions
and
15 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[package] | ||
name = "next-build-test" | ||
version = "0.1.0" | ||
description = "TBD" | ||
license = "MPL-2.0" | ||
edition = "2021" | ||
autobenches = false | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
next-core = { workspace = true, features = ["rustls-tls"] } | ||
next-api = { workspace = true } | ||
serde_json = { workspace = true } | ||
anyhow = { workspace = true } | ||
tokio = { workspace = true, features = ["full"] } | ||
turbo-tasks-malloc = { workspace = true, default-features = false } | ||
turbopack-binding = { workspace = true, features = [ | ||
"__turbo_tasks", | ||
"__turbo_tasks_memory", | ||
"__turbo_tasks_env", | ||
"__turbo_tasks_fs", | ||
"__turbo_tasks_memory", | ||
"__turbopack", | ||
"__turbopack_nodejs", | ||
"__turbopack_core", | ||
"__turbopack_browser", | ||
"__turbopack_ecmascript", | ||
"__turbopack_ecmascript_runtime", | ||
"__turbopack_env", | ||
"__turbopack_node", | ||
] } | ||
turbo-tasks = { workspace = true } | ||
rand = { workspace = true, features = ["small_rng"] } | ||
num_cpus = "1.16.0" | ||
tokio-stream = "0.1.15" | ||
tracing = "0.1" | ||
tracing-subscriber = "0.3" | ||
futures-util = "0.3.30" | ||
|
||
[build-dependencies] | ||
turbopack-binding = { workspace = true, features = ["__turbo_tasks_build"] } | ||
|
||
[dev-dependencies] | ||
iai-callgrind = "0.10.2" | ||
tempdir = "0.3.7" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# next-build-test | ||
|
||
This binary lets you sidestep all of the node bundling and run a turbo build | ||
against a raw rust binary. It does _not_ do everything nextjs does, but it | ||
is an ok approximation. | ||
|
||
## Getting started | ||
|
||
You will need a project_options file that points to some nextjs repo that has | ||
its dependencies installed. The easiest way to do that is to run a nextjs | ||
build using a modified binary that produces one out for you or to run the | ||
`generate` command and tweak it manually. We cannot bundle one in the repo, | ||
since it needs fs-specific paths and env vars. | ||
|
||
You can run the binary with the `generate` flag to build one for you. | ||
|
||
```sh | ||
cargo run -- generate /path/to/project > project_options.json | ||
cargo run -- run | ||
``` | ||
|
||
## Flags | ||
|
||
The `run` command supports 4 flags: | ||
|
||
- `strategy` can be one of sequential, concurrent, or parallel. defines how | ||
work is structured | ||
- `factor` defined how many pages should be built at once. defaults to num_cpus | ||
- `limit` defines the highest number of pages to build. the pages are | ||
shuffled deterministically. defaults to 1 page | ||
- `pages` a comma separated list of routes to run. queues that precise set in | ||
the order specified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
turbopack_binding::turbo::tasks_build::generate_register(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedIndexedAccess": false, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"lib": ["lib.dom.d.ts", "lib.dom.iterable.d.ts", "lib.esnext.d.ts"], | ||
"module": 99, | ||
"target": 8, | ||
"moduleResolution": 2, | ||
"incremental": true, | ||
"noEmit": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": 1, | ||
"plugins": [ | ||
{ | ||
"name": "typescript-plugin-css-modules", | ||
"options": { | ||
"goToDefinition": true | ||
} | ||
}, | ||
{ | ||
"name": "next" | ||
} | ||
], | ||
"allowJs": true, | ||
"paths": {}, | ||
"tsBuildInfoFile": "/tmp/ignore", | ||
"strictNullChecks": true, | ||
"pathsBasePath": "/tmp/ignore" | ||
} | ||
} |
147 changes: 147 additions & 0 deletions
147
packages/next-swc/crates/next-build-test/nextConfig.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"env": {}, | ||
"webpack": {}, | ||
"eslint": { | ||
"ignoreDuringBuilds": false | ||
}, | ||
"typescript": { | ||
"ignoreBuildErrors": false, | ||
"tsconfigPath": "tsconfig.json" | ||
}, | ||
"distDir": ".next", | ||
"cleanDistDir": true, | ||
"assetPrefix": "", | ||
"cacheMaxMemorySize": 52428800, | ||
"configOrigin": "next.config.mjs", | ||
"useFileSystemPublicRoutes": true, | ||
"generateBuildId": null, | ||
"generateEtags": true, | ||
"pageExtensions": ["jsx", "js", "tsx", "ts", "mdx", "md"], | ||
"poweredByHeader": true, | ||
"compress": true, | ||
"analyticsId": "", | ||
"images": { | ||
"deviceSizes": [640, 750, 828, 1080, 1200, 1920, 2048, 3840], | ||
"imageSizes": [16, 32, 48, 64, 96, 128, 256, 384], | ||
"path": "/_next/image", | ||
"loader": "default", | ||
"loaderFile": "", | ||
"domains": [], | ||
"disableStaticImages": false, | ||
"minimumCacheTTL": 60, | ||
"formats": ["image/avif", "image/webp"], | ||
"dangerouslyAllowSVG": false, | ||
"contentSecurityPolicy": "script-src 'none'; frame-src 'none'; sandbox;", | ||
"contentDispositionType": "inline", | ||
"remotePatterns": [], | ||
"unoptimized": false | ||
}, | ||
"devIndicators": { | ||
"buildActivity": true, | ||
"buildActivityPosition": "bottom-right" | ||
}, | ||
"onDemandEntries": { | ||
"maxInactiveAge": 60000, | ||
"pagesBufferLength": 5 | ||
}, | ||
"amp": { | ||
"canonicalBase": "" | ||
}, | ||
"basePath": "", | ||
"sassOptions": {}, | ||
"trailingSlash": false, | ||
"i18n": null, | ||
"productionBrowserSourceMaps": false, | ||
"optimizeFonts": true, | ||
"excludeDefaultMomentLocales": true, | ||
"serverRuntimeConfig": {}, | ||
"publicRuntimeConfig": {}, | ||
"reactProductionProfiling": false, | ||
"reactStrictMode": true, | ||
"httpAgentOptions": { | ||
"keepAlive": true | ||
}, | ||
"outputFileTracing": true, | ||
"staticPageGenerationTimeout": 60, | ||
"swcMinify": true, | ||
"modularizeImports": {}, | ||
"experimental": { | ||
"prerenderEarlyExit": false, | ||
"serverMinification": true, | ||
"serverSourceMaps": false, | ||
"linkNoTouchStart": false, | ||
"caseSensitiveRoutes": false, | ||
"clientRouterFilter": true, | ||
"clientRouterFilterRedirects": false, | ||
"fetchCacheKeyPrefix": "", | ||
"middlewarePrefetch": "flexible", | ||
"optimisticClientCache": true, | ||
"manualClientBasePath": false, | ||
"cpus": 2, | ||
"memoryBasedWorkersCount": false, | ||
"isrFlushToDisk": true, | ||
"workerThreads": false, | ||
"optimizeCss": false, | ||
"nextScriptWorkers": false, | ||
"scrollRestoration": false, | ||
"externalDir": false, | ||
"disableOptimizedLoading": false, | ||
"gzipSize": true, | ||
"craCompat": false, | ||
"esmExternals": true, | ||
"fullySpecified": false, | ||
"outputFileTracingRoot": "/tmp/ignore", | ||
"swcTraceProfiling": false, | ||
"forceSwcTransforms": false, | ||
"largePageDataBytes": 128000, | ||
"adjustFontFallbacks": false, | ||
"adjustFontFallbacksWithSizeAdjust": false, | ||
"turbo": { | ||
"rules": { | ||
"*.mdx": { | ||
"loaders": ["turbopack-mdx-loader"], | ||
"as": "*.tsx" | ||
} | ||
}, | ||
"resolveAlias": { | ||
"fs": { | ||
"browser": "./turbopack/empty.js" | ||
}, | ||
"cookie": { | ||
"browser": "./turbopack/empty.js" | ||
}, | ||
"http": { | ||
"browser": "./turbopack/empty.js" | ||
}, | ||
"https": { | ||
"browser": "./turbopack/empty.js" | ||
}, | ||
"node-fetch": { | ||
"browser": "./turbopack/empty.js" | ||
} | ||
} | ||
}, | ||
"typedRoutes": false, | ||
"instrumentationHook": true, | ||
"bundlePagesExternals": false, | ||
"parallelServerCompiles": false, | ||
"parallelServerBuildTraces": false, | ||
"ppr": false, | ||
"missingSuspenseWithCSRBailout": true, | ||
"optimizeServerReact": true, | ||
"useEarlyImport": false, | ||
"serverComponentsExternalPackages": [], | ||
"useLightningcss": true, | ||
"optimizePackageImports": [] | ||
}, | ||
"configFile": "/tmp/ignore", | ||
"configFileName": "next.config.mjs", | ||
"transpilePackages": [], | ||
"_originalRewrites": { | ||
"beforeFiles": [], | ||
"afterFiles": [], | ||
"fallback": [] | ||
}, | ||
"_originalRedirects": [], | ||
"exportPathMap": {} | ||
} |
Oops, something went wrong.