Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/next-swc/crates/napi/src/turbopack.rs
Expand Up @@ -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");
}
9 changes: 9 additions & 0 deletions packages/next/src/build/swc/index.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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: {
Expand Down
8 changes: 8 additions & 0 deletions packages/next/src/cli/next-dev.ts
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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']) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/lib/start-server.ts
Expand Up @@ -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
Expand Down