Unverified Commit 73c905dc authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

feat(next-dev): add a new experimental flag (#51895)


### What?

WEB-1239. This is mainly for the code paths to not to cause regressions to existing turbopack.
parent a04a34d3
......@@ -181,3 +181,8 @@ impl From<NapiRouteHas> for RouteHas {
pub async fn next_build(ctx: NextBuildContext) -> napi::Result<()> {
turbo_next_build(ctx.try_into()?).await.convert_err()
}
#[napi]
pub async fn experimental_turbo(_unused: Buffer) -> napi::Result<()> {
unimplemented!("__experimental_turbo is not yet implemented");
}
......@@ -296,6 +296,9 @@ async function loadWasm(importPath = '', isCustomTurbopack: boolean) {
startTrace: () => {
Log.error('Wasm binding does not support trace yet')
},
experimentalTurbo: () => {
Log.error('Wasm binding does not support this interface')
},
entrypoints: {
stream: (
turboTasks: any,
......@@ -555,6 +558,12 @@ function loadNative(isCustomTurbopack = false) {
)
return ret
},
experimentalTurbo: () => {
initHeapProfiler()
const ret = bindings.experimentalTurbo()
return ret
},
createTurboTasks: (memoryLimit?: number): unknown =>
bindings.createTurboTasks(memoryLimit),
entrypoints: {
......
......@@ -119,6 +119,7 @@ const nextDev: CliCommand = async (argv) => {
'--port': Number,
'--hostname': String,
'--turbo': Boolean,
'--experimental-turbo': Boolean,
// To align current messages with native binary.
// Will need to adjust subcommand later.
......@@ -209,6 +210,7 @@ const nextDev: CliCommand = async (argv) => {
// We do not set a default host value here to prevent breaking
// some set-ups that rely on listening on other interfaces
const host = args['--hostname']
const experimentalTurbo = args['--experimental-turbo']
const devServerOptions: StartServerOptions = {
dir,
......@@ -218,6 +220,7 @@ const nextDev: CliCommand = async (argv) => {
hostname: host,
// This is required especially for app dir.
useWorkers: true,
isExperimentalTurbo: experimentalTurbo,
}
if (args['--turbo']) {
......@@ -311,6 +314,11 @@ const nextDev: CliCommand = async (argv) => {
return server
} else {
if (experimentalTurbo) {
Log.error('Not supported yet')
process.exit(1)
}
let cleanupFns: (() => Promise<void> | void)[] = []
const runDevServer = async () => {
const oldCleanupFns = cleanupFns
......
......@@ -22,6 +22,7 @@ export interface StartServerOptions {
useWorkers: boolean
allowRetry?: boolean
isTurbopack?: boolean
isExperimentalTurbo?: boolean
keepAliveTimeout?: number
onStdout?: (data: any) => void
onStderr?: (data: any) => void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment