Unverified Commit c36d3427 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[ci] Crash if next-swc could not be loaded when `NEXT_TEST_NATIVE_DIR` is specified (#90387)

parent 08ae81fa
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
"version": "16.0.2-canary.16", "version": "16.0.2-canary.16",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "cross-env NEXT_TEST_NATIVE_DIR=no next build --no-mangling", "build": "cross-env NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL=true NEXT_TEST_NATIVE_DIR=no next build --no-mangling",
"dev": "cross-env NEXT_TEST_NATIVE_DIR=no next dev", "dev": "cross-env NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL=true NEXT_TEST_NATIVE_DIR=no next dev",
"lint": "eslint .", "lint": "eslint .",
"start": "cross-env NEXT_TEST_NATIVE_DIR=no next start" "start": "cross-env NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL=true NEXT_TEST_NATIVE_DIR=no next start"
}, },
"dependencies": { "dependencies": {
"@radix-ui/react-dialog": "1.1.4", "@radix-ui/react-dialog": "1.1.4",
......
...@@ -1463,7 +1463,8 @@ function loadNative(importPath?: string) { ...@@ -1463,7 +1463,8 @@ function loadNative(importPath?: string) {
? require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS) ? require(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)
: null : null
let bindings: RawBindings = customBindings let bindings: RawBindings = customBindings
let attempts: any[] = [] // callers expect that if loadNative throws, it's an array of strings.
let attempts: string[] = []
const NEXT_TEST_NATIVE_DIR = process.env.NEXT_TEST_NATIVE_DIR const NEXT_TEST_NATIVE_DIR = process.env.NEXT_TEST_NATIVE_DIR
for (const triple of triples) { for (const triple of triples) {
...@@ -1477,8 +1478,12 @@ function loadNative(importPath?: string) { ...@@ -1477,8 +1478,12 @@ function loadNative(importPath?: string) {
'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR' 'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'
) )
break break
} catch (e) {} } catch (e: any) {
} else { attempts.push(
`Failed to load triple ${triple.platformArchABI}: ${e.message ?? e}`
)
}
} else if (process.env.NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL !== 'true') {
try { try {
bindings = require( bindings = require(
`@next/swc/native/next-swc.${triple.platformArchABI}.node` `@next/swc/native/next-swc.${triple.platformArchABI}.node`
...@@ -1490,6 +1495,10 @@ function loadNative(importPath?: string) { ...@@ -1490,6 +1495,10 @@ function loadNative(importPath?: string) {
} }
if (!bindings) { if (!bindings) {
if (NEXT_TEST_NATIVE_DIR) {
throw attempts
}
for (const triple of triples) { for (const triple of triples) {
let pkg = importPath let pkg = importPath
? path.join( ? path.join(
......
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