fext(next-swc): extend internal env flag to all native bindings (#65748)

### What

`__INTERNAL_CUSTOM_TURBOPACK_BINDINGS` behaves inconsistent across
exposed bindings interface. PR adjusts to apply it to all of the
interface, to allow to use this env to override any swc binaries. This
is not a public interface, no concern of breaking changes.
This commit is contained in:
OJ Kwon 2024-05-14 11:18:33 -07:00 committed by GitHub
parent caf261288e
commit 85873492e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,9 +97,9 @@ const triples = (() => {
})()
// Allow to specify an absolute path to the custom turbopack binary to load.
// If one of env variables is set, `loadNative` will try to use any turbo-* interfaces from specified
// binary instead. This will not affect existing swc's transform, or other interfaces. This is thin,
// naive interface - `loadBindings` will not validate neither path nor the binary.
// If one of env variables is set, `loadNative` will try to use specified
// binary instead. This is thin, naive interface
// - `loadBindings` will not validate neither path nor the binary.
//
// Note these are internal flag: there's no stability, feature guarantee.
const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =
@ -1352,7 +1352,7 @@ function loadNative(importPath?: string) {
const customBindings = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS
? require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
: null
let bindings: any
let bindings: any = customBindings
let attempts: any[] = []
const NEXT_TEST_NATIVE_DIR = process.env.NEXT_TEST_NATIVE_DIR