Commit 64430788 authored by JJ Kasper's avatar JJ Kasper

lock swc binaries version

parent c92233ba
This diff is collapsed.
......@@ -177,7 +177,7 @@ jobs:
- run: pnpm playwright install chromium
if: ${{ inputs.skipInstallBuild != 'yes' }}
- run: pnpm turbo run get-test-timings -- --build ${{ github.sha }}
- run: pnpm dlx turbo@${TURBO_VERSION} run get-test-timings -- --build ${{ github.sha }}
- run: /bin/bash -c "${{ inputs.afterBuild }}"
if: ${{(inputs.skipForDocsOnly != 'yes' || steps.docs-change.outputs.DOCS_CHANGE == 'nope') && (inputs.skipForRelease != 'yes' || steps.is-release.outputs.IS_RELEASE == 'nope')}}
......
......@@ -100,7 +100,8 @@ const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =
function checkVersionMismatch(pkgData: any) {
const version = pkgData.version
if (version && version !== nextVersion) {
// swc version is locked to 13.5.9 so don't warn for that case
if (version && version !== nextVersion && version !== '13.5.9') {
Log.warn(
`Mismatching @next/swc version, detected: ${version} while Next.js is on ${nextVersion}. Please ensure these match`
)
......
#!/usr/bin/env node
const path = require('path')
const execa = require('execa')
const { copy } = require('fs-extra')
const { Sema } = require('async-sema')
// const execa = require('execa')
// const { copy } = require('fs-extra')
// const { Sema } = require('async-sema')
const { readFile, readdir, writeFile } = require('fs/promises')
const cwd = process.cwd()
;(async function () {
try {
const publishSema = new Sema(2)
// const publishSema = new Sema(2)
let version = JSON.parse(
await readFile(path.join(cwd, 'lerna.json'))
).version
// let version = JSON.parse(
// await readFile(path.join(cwd, 'lerna.json'))
// ).version
// Copy binaries to package folders, update version, and publish
let nativePackagesDir = path.join(cwd, 'packages/next-swc/crates/napi/npm')
......@@ -22,122 +22,125 @@ const cwd = process.cwd()
(name) => !name.startsWith('.')
)
await Promise.all(
platforms.map(async (platform) => {
await publishSema.acquire()
// await Promise.all(
// platforms.map(async (platform) => {
// await publishSema.acquire()
try {
let binaryName = `next-swc.${platform}.node`
await copy(
path.join(cwd, 'packages/next-swc/native', binaryName),
path.join(nativePackagesDir, platform, binaryName)
)
let pkg = JSON.parse(
await readFile(
path.join(nativePackagesDir, platform, 'package.json')
)
)
pkg.version = version
await writeFile(
path.join(nativePackagesDir, platform, 'package.json'),
JSON.stringify(pkg, null, 2)
)
await execa(
`npm`,
[
`publish`,
`${path.join(nativePackagesDir, platform)}`,
`--access`,
`public`,
...(version.includes('canary')
? ['--tag', 'canary']
: ['--tag', 'next-13']),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, platform, err)
// try {
// let binaryName = `next-swc.${platform}.node`
// await copy(
// path.join(cwd, 'packages/next-swc/native', binaryName),
// path.join(nativePackagesDir, platform, binaryName)
// )
// let pkg = JSON.parse(
// await readFile(
// path.join(nativePackagesDir, platform, 'package.json')
// )
// )
// pkg.version = version
// await writeFile(
// path.join(nativePackagesDir, platform, 'package.json'),
// JSON.stringify(pkg, null, 2)
// )
// await execa(
// `npm`,
// [
// `publish`,
// `${path.join(nativePackagesDir, platform)}`,
// `--access`,
// `public`,
// ...(version.includes('canary')
// ? ['--tag', 'canary']
// : ['--tag', 'next-13']),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, platform, err)
if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', platform, err)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)
// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', platform, err)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )
// Update name/version of wasm packages and publish
const pkgDirectory = 'packages/next-swc/crates/wasm'
let wasmDir = path.join(cwd, pkgDirectory)
// const pkgDirectory = 'packages/next-swc/crates/wasm'
// let wasmDir = path.join(cwd, pkgDirectory)
await Promise.all(
['web', 'nodejs'].map(async (wasmTarget) => {
await publishSema.acquire()
// await Promise.all(
// ['web', 'nodejs'].map(async (wasmTarget) => {
// await publishSema.acquire()
let wasmPkg = JSON.parse(
await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
)
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
wasmPkg.version = version
wasmPkg.repository = {
type: 'git',
url: 'https://github.com/vercel/next.js',
directory: pkgDirectory,
}
// let wasmPkg = JSON.parse(
// await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
// )
// wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
// wasmPkg.version = version
// wasmPkg.repository = {
// type: 'git',
// url: 'https://github.com/vercel/next.js',
// directory: pkgDirectory,
// }
await writeFile(
path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
JSON.stringify(wasmPkg, null, 2)
)
// await writeFile(
// path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
// JSON.stringify(wasmPkg, null, 2)
// )
try {
await execa(
`npm`,
[
'publish',
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access',
'public',
...(version.includes('canary') ? ['--tag', 'canary'] : []),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, wasmTarget, err)
// try {
// await execa(
// `npm`,
// [
// 'publish',
// `${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
// '--access',
// 'public',
// ...(version.includes('canary') ? ['--tag', 'canary'] : []),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, wasmTarget, err)
if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', wasmTarget)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)
// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', wasmTarget)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )
// Update optional dependencies versions
let nextPkg = JSON.parse(
await readFile(path.join(cwd, 'packages/next/package.json'))
)
// we lock the version to last built swc binaries for
// last successfully built binaries
// https://github.com/vercel/next.js/pull/77477#issuecomment-2752725970
for (let platform of platforms) {
let optionalDependencies = nextPkg.optionalDependencies || {}
optionalDependencies['@next/swc-' + platform] = version
optionalDependencies['@next/swc-' + platform] = '13.5.9'
nextPkg.optionalDependencies = optionalDependencies
}
await writeFile(
......
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