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

Fix monorepo `@next/swc` binary postinstall (#92813)

parent b6cf70eb
...@@ -29,6 +29,8 @@ ignoredBuiltDependencies: ...@@ -29,6 +29,8 @@ ignoredBuiltDependencies:
- ssh2 - ssh2
- unrs-resolver - unrs-resolver
- wasm-pack - wasm-pack
# Keep security related settings in sync with pnpm-workspace.yaml written to
# temporary fixture dirs in file://./scripts/install-native.mjs
blockExoticSubdeps: true blockExoticSubdeps: true
minimumReleaseAge: 2880 # 48 hrs minimumReleaseAge: 2880 # 48 hrs
minimumReleaseAgeExclude: minimumReleaseAgeExclude:
......
...@@ -3,6 +3,7 @@ import path from 'path' ...@@ -3,6 +3,7 @@ import path from 'path'
import execa from 'execa' import execa from 'execa'
import fs from 'fs' import fs from 'fs'
import fsp from 'fs/promises' import fsp from 'fs/promises'
import { outdent } from 'outdent'
;(async function () { ;(async function () {
if (process.env.NEXT_SKIP_NATIVE_POSTINSTALL) { if (process.env.NEXT_SKIP_NATIVE_POSTINSTALL) {
console.log( console.log(
...@@ -58,20 +59,43 @@ import fsp from 'fs/promises' ...@@ -58,20 +59,43 @@ import fsp from 'fs/promises'
packageManager, packageManager,
} }
fs.writeFileSync(path.join(tmpdir, 'package.json'), JSON.stringify(pkgJson)) fs.writeFileSync(path.join(tmpdir, 'package.json'), JSON.stringify(pkgJson))
fs.writeFileSync(path.join(tmpdir, '.npmrc'), 'node-linker=hoisted') fs.writeFileSync(
path.join(tmpdir, 'pnpm-workspace.yaml'),
'' +
outdent`
nodeLinker: hoisted
` +
'\n' +
// Propagate security related settings from file://./../../pnpm-workspace.yaml
outdent`
blockExoticSubdeps: true
minimumReleaseAge: 2880 # 48 hrs
minimumReleaseAgeExclude:
- '@next/*'
- '@turbo/*'
- '@vercel/*'
- '@workflow/*'
- babel-plugin-react-compiler
- next
- react
- react-dom
- react-is
- react-server-dom-*
- scheduler
- turbo
`
)
const args = [ const args = [
'add', 'add',
`next@${nextVersion}`, `next@${nextVersion}`,
'--lockfile=false', '--lockfile=false',
'--ignore-workspace',
'--ignore-scripts', '--ignore-scripts',
] ]
if (preferOffline) { if (preferOffline) {
args.push('--prefer-offline') args.push('--prefer-offline')
} }
let { stdout } = await execa('pnpm', args, { cwd: tmpdir }) await execa('pnpm', args, { cwd: tmpdir })
console.log(stdout)
let pkgs = fs.readdirSync(path.join(tmpdir, 'node_modules/@next')) let pkgs = fs.readdirSync(path.join(tmpdir, 'node_modules/@next'))
fs.mkdirSync(path.join(cwd, 'node_modules/@next'), { recursive: true }) fs.mkdirSync(path.join(cwd, 'node_modules/@next'), { recursive: true })
...@@ -91,7 +115,6 @@ import fsp from 'fs/promises' ...@@ -91,7 +115,6 @@ import fsp from 'fs/promises'
fs.rmSync(tmpdir, { recursive: true, force: true }) fs.rmSync(tmpdir, { recursive: true, force: true })
console.log('Installed the following binary packages:', pkgs) console.log('Installed the following binary packages:', pkgs)
} catch (e) { } catch (e) {
console.error(e) throw new Error('Failed to install @next/swc binary packages', { cause: e })
console.error('Failed to load @next/swc binary packages')
} }
})() })()
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