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 { ...@@ -181,3 +181,8 @@ impl From<NapiRouteHas> for RouteHas {
pub async fn next_build(ctx: NextBuildContext) -> napi::Result<()> { pub async fn next_build(ctx: NextBuildContext) -> napi::Result<()> {
turbo_next_build(ctx.try_into()?).await.convert_err() 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) { ...@@ -296,6 +296,9 @@ async function loadWasm(importPath = '', isCustomTurbopack: boolean) {
startTrace: () => { startTrace: () => {
Log.error('Wasm binding does not support trace yet') Log.error('Wasm binding does not support trace yet')
}, },
experimentalTurbo: () => {
Log.error('Wasm binding does not support this interface')
},
entrypoints: { entrypoints: {
stream: ( stream: (
turboTasks: any, turboTasks: any,
...@@ -555,6 +558,12 @@ function loadNative(isCustomTurbopack = false) { ...@@ -555,6 +558,12 @@ function loadNative(isCustomTurbopack = false) {
) )
return ret return ret
}, },
experimentalTurbo: () => {
initHeapProfiler()
const ret = bindings.experimentalTurbo()
return ret
},
createTurboTasks: (memoryLimit?: number): unknown => createTurboTasks: (memoryLimit?: number): unknown =>
bindings.createTurboTasks(memoryLimit), bindings.createTurboTasks(memoryLimit),
entrypoints: { entrypoints: {
......
...@@ -119,6 +119,7 @@ const nextDev: CliCommand = async (argv) => { ...@@ -119,6 +119,7 @@ const nextDev: CliCommand = async (argv) => {
'--port': Number, '--port': Number,
'--hostname': String, '--hostname': String,
'--turbo': Boolean, '--turbo': Boolean,
'--experimental-turbo': Boolean,
// To align current messages with native binary. // To align current messages with native binary.
// Will need to adjust subcommand later. // Will need to adjust subcommand later.
...@@ -209,6 +210,7 @@ const nextDev: CliCommand = async (argv) => { ...@@ -209,6 +210,7 @@ const nextDev: CliCommand = async (argv) => {
// We do not set a default host value here to prevent breaking // We do not set a default host value here to prevent breaking
// some set-ups that rely on listening on other interfaces // some set-ups that rely on listening on other interfaces
const host = args['--hostname'] const host = args['--hostname']
const experimentalTurbo = args['--experimental-turbo']
const devServerOptions: StartServerOptions = { const devServerOptions: StartServerOptions = {
dir, dir,
...@@ -218,6 +220,7 @@ const nextDev: CliCommand = async (argv) => { ...@@ -218,6 +220,7 @@ const nextDev: CliCommand = async (argv) => {
hostname: host, hostname: host,
// This is required especially for app dir. // This is required especially for app dir.
useWorkers: true, useWorkers: true,
isExperimentalTurbo: experimentalTurbo,
} }
if (args['--turbo']) { if (args['--turbo']) {
...@@ -311,6 +314,11 @@ const nextDev: CliCommand = async (argv) => { ...@@ -311,6 +314,11 @@ const nextDev: CliCommand = async (argv) => {
return server return server
} else { } else {
if (experimentalTurbo) {
Log.error('Not supported yet')
process.exit(1)
}
let cleanupFns: (() => Promise<void> | void)[] = [] let cleanupFns: (() => Promise<void> | void)[] = []
const runDevServer = async () => { const runDevServer = async () => {
const oldCleanupFns = cleanupFns const oldCleanupFns = cleanupFns
......
...@@ -22,6 +22,7 @@ export interface StartServerOptions { ...@@ -22,6 +22,7 @@ export interface StartServerOptions {
useWorkers: boolean useWorkers: boolean
allowRetry?: boolean allowRetry?: boolean
isTurbopack?: boolean isTurbopack?: boolean
isExperimentalTurbo?: boolean
keepAliveTimeout?: number keepAliveTimeout?: number
onStdout?: (data: any) => void onStdout?: (data: any) => void
onStderr?: (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