Unverified Commit 2cea3f70 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

feat(next-swc): support env var for --experimental-turbo (#52841)



### What?

Minor update to next-swc to support `__INTERNAL_CUSTOM_TURBOPACK_BINDINGS` for the --experimental-turbo entrypoint as same as current --turbo.
parent 5bf2bbb3
......@@ -832,6 +832,9 @@ function loadNative(isCustomTurbopack = false, importPath?: string) {
return nativeBindings
}
const customBindings = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS
? require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
: null
let bindings: any
let attempts: any[] = []
......@@ -1027,13 +1030,13 @@ function loadNative(isCustomTurbopack = false, importPath?: string) {
},
nextBuild: (options: unknown) => {
initHeapProfiler()
const ret = bindings.nextBuild(options)
const ret = (customBindings ?? bindings).nextBuild(options)
return ret
},
startTrace: (options = {}, turboTasks: unknown) => {
initHeapProfiler()
const ret = bindings.runTurboTracing(
const ret = (customBindings ?? bindings).runTurboTracing(
toBuffer({ exact: true, ...options }),
turboTasks
)
......@@ -1049,7 +1052,7 @@ function loadNative(isCustomTurbopack = false, importPath?: string) {
pageExtensions: string[],
fn: (entrypoints: any) => void
) => {
return bindings.streamEntrypoints(
return (customBindings ?? bindings).streamEntrypoints(
turboTasks,
rootDir,
applicationDir,
......@@ -1063,7 +1066,7 @@ function loadNative(isCustomTurbopack = false, importPath?: string) {
applicationDir: string,
pageExtensions: string[]
) => {
return bindings.getEntrypoints(
return (customBindings ?? bindings).getEntrypoints(
turboTasks,
rootDir,
applicationDir,
......@@ -1071,7 +1074,7 @@ function loadNative(isCustomTurbopack = false, importPath?: string) {
)
},
},
createProject: bindingToApi(bindings, false),
createProject: bindingToApi(customBindings ?? bindings, false),
},
mdx: {
compile: (src: string, options: any) =>
......
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