Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
64430788
Commit
64430788
authored
Mar 27, 2025
by
JJ Kasper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lock swc binaries version
parent
c92233ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
495 additions
and
491 deletions
+495
-491
build_and_deploy.yml
.github/workflows/build_and_deploy.yml
+382
-382
build_reusable.yml
.github/workflows/build_reusable.yml
+1
-1
index.ts
packages/next/src/build/swc/index.ts
+2
-1
publish-native.js
scripts/publish-native.js
+110
-107
No files found.
.github/workflows/build_and_deploy.yml
View file @
64430788
This diff is collapsed.
Click to expand it.
.github/workflows/build_reusable.yml
View file @
64430788
...
@@ -177,7 +177,7 @@ jobs:
...
@@ -177,7 +177,7 @@ jobs:
-
run
:
pnpm playwright install chromium
-
run
:
pnpm playwright install chromium
if
:
${{ inputs.skipInstallBuild != 'yes' }}
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 }}"
-
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')}}
if
:
${{(inputs.skipForDocsOnly != 'yes' || steps.docs-change.outputs.DOCS_CHANGE == 'nope') && (inputs.skipForRelease != 'yes' || steps.is-release.outputs.IS_RELEASE == 'nope')}}
...
...
packages/next/src/build/swc/index.ts
View file @
64430788
...
@@ -100,7 +100,8 @@ const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =
...
@@ -100,7 +100,8 @@ const __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =
function
checkVersionMismatch
(
pkgData
:
any
)
{
function
checkVersionMismatch
(
pkgData
:
any
)
{
const
version
=
pkgData
.
version
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
(
Log
.
warn
(
`Mismatching @next/swc version, detected:
${
version
}
while Next.js is on
${
nextVersion
}
. Please ensure these match`
`Mismatching @next/swc version, detected:
${
version
}
while Next.js is on
${
nextVersion
}
. Please ensure these match`
)
)
...
...
scripts/publish-native.js
View file @
64430788
#!/usr/bin/env node
#!/usr/bin/env node
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
const
execa
=
require
(
'execa'
)
//
const execa = require('execa')
const
{
copy
}
=
require
(
'fs-extra'
)
//
const { copy } = require('fs-extra')
const
{
Sema
}
=
require
(
'async-sema'
)
//
const { Sema } = require('async-sema')
const
{
readFile
,
readdir
,
writeFile
}
=
require
(
'fs/promises'
)
const
{
readFile
,
readdir
,
writeFile
}
=
require
(
'fs/promises'
)
const
cwd
=
process
.
cwd
()
const
cwd
=
process
.
cwd
()
;(
async
function
()
{
;(
async
function
()
{
try
{
try
{
const
publishSema
=
new
Sema
(
2
)
//
const publishSema = new Sema(2)
let
version
=
JSON
.
parse
(
//
let version = JSON.parse(
await
readFile
(
path
.
join
(
cwd
,
'lerna.json'
))
//
await readFile(path.join(cwd, 'lerna.json'))
).
version
//
).version
// Copy binaries to package folders, update version, and publish
// Copy binaries to package folders, update version, and publish
let
nativePackagesDir
=
path
.
join
(
cwd
,
'packages/next-swc/crates/napi/npm'
)
let
nativePackagesDir
=
path
.
join
(
cwd
,
'packages/next-swc/crates/napi/npm'
)
...
@@ -22,122 +22,125 @@ const cwd = process.cwd()
...
@@ -22,122 +22,125 @@ const cwd = process.cwd()
(
name
)
=>
!
name
.
startsWith
(
'.'
)
(
name
)
=>
!
name
.
startsWith
(
'.'
)
)
)
await
Promise
.
all
(
//
await Promise.all(
platforms
.
map
(
async
(
platform
)
=>
{
//
platforms.map(async (platform) => {
await
publishSema
.
acquire
()
//
await publishSema.acquire()
try
{
//
try {
let
binaryName
=
`next-swc.
${
platform
}
.node`
//
let binaryName = `next-swc.${platform}.node`
await
copy
(
//
await copy(
path
.
join
(
cwd
,
'packages/next-swc/native'
,
binaryName
),
//
path.join(cwd, 'packages/next-swc/native', binaryName),
path
.
join
(
nativePackagesDir
,
platform
,
binaryName
)
//
path.join(nativePackagesDir, platform, binaryName)
)
//
)
let
pkg
=
JSON
.
parse
(
//
let pkg = JSON.parse(
await
readFile
(
//
await readFile(
path
.
join
(
nativePackagesDir
,
platform
,
'package.json'
)
//
path.join(nativePackagesDir, platform, 'package.json')
)
//
)
)
//
)
pkg
.
version
=
version
//
pkg.version = version
await
writeFile
(
//
await writeFile(
path
.
join
(
nativePackagesDir
,
platform
,
'package.json'
),
//
path.join(nativePackagesDir, platform, 'package.json'),
JSON
.
stringify
(
pkg
,
null
,
2
)
//
JSON.stringify(pkg, null, 2)
)
//
)
await
execa
(
//
await execa(
`npm`
,
//
`npm`,
[
//
[
`publish`
,
//
`publish`,
`
${
path
.
join
(
nativePackagesDir
,
platform
)}
`
,
//
`${path.join(nativePackagesDir, platform)}`,
`--access`
,
//
`--access`,
`public`
,
//
`public`,
...(
version
.
includes
(
'canary'
)
//
...(version.includes('canary')
?
[
'--tag'
,
'canary'
]
//
? ['--tag', 'canary']
:
[
'--tag'
,
'next-13'
]),
//
: ['--tag', 'next-13']),
],
//
],
{
stdio
:
'inherit'
}
//
{ stdio: 'inherit' }
)
//
)
}
catch
(
err
)
{
//
} catch (err) {
// don't block publishing other versions on single platform error
//
// don't block publishing other versions on single platform error
console
.
error
(
`Failed to publish`
,
platform
,
err
)
//
console.error(`Failed to publish`, platform, err)
if
(
//
if (
err
.
message
&&
//
err.message &&
err
.
message
.
includes
(
//
err.message.includes(
'You cannot publish over the previously published versions'
//
'You cannot publish over the previously published versions'
)
//
)
)
{
//
) {
console
.
error
(
'Ignoring already published error'
,
platform
,
err
)
//
console.error('Ignoring already published error', platform, err)
}
else
{
//
} else {
// throw err
//
// throw err
}
//
}
}
finally
{
//
} finally {
publishSema
.
release
()
//
publishSema.release()
}
//
}
})
//
})
)
//
)
// Update name/version of wasm packages and publish
// Update name/version of wasm packages and publish
const
pkgDirectory
=
'packages/next-swc/crates/wasm'
//
const pkgDirectory = 'packages/next-swc/crates/wasm'
let
wasmDir
=
path
.
join
(
cwd
,
pkgDirectory
)
//
let wasmDir = path.join(cwd, pkgDirectory)
await
Promise
.
all
(
//
await Promise.all(
[
'web'
,
'nodejs'
].
map
(
async
(
wasmTarget
)
=>
{
//
['web', 'nodejs'].map(async (wasmTarget) => {
await
publishSema
.
acquire
()
//
await publishSema.acquire()
let
wasmPkg
=
JSON
.
parse
(
//
let wasmPkg = JSON.parse(
await
readFile
(
path
.
join
(
wasmDir
,
`pkg-
${
wasmTarget
}
/package.json`
))
//
await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
)
//
)
wasmPkg
.
name
=
`@next/swc-wasm-
${
wasmTarget
}
`
//
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
wasmPkg
.
version
=
version
//
wasmPkg.version = version
wasmPkg
.
repository
=
{
//
wasmPkg.repository = {
type
:
'git'
,
//
type: 'git',
url
:
'https://github.com/vercel/next.js'
,
//
url: 'https://github.com/vercel/next.js',
directory
:
pkgDirectory
,
//
directory: pkgDirectory,
}
//
}
await
writeFile
(
//
await writeFile(
path
.
join
(
wasmDir
,
`pkg-
${
wasmTarget
}
/package.json`
),
//
path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
JSON
.
stringify
(
wasmPkg
,
null
,
2
)
//
JSON.stringify(wasmPkg, null, 2)
)
//
)
try
{
//
try {
await
execa
(
//
await execa(
`npm`
,
//
`npm`,
[
//
[
'publish'
,
//
'publish',
`
${
path
.
join
(
wasmDir
,
`pkg-
${
wasmTarget
}
`
)}
`
,
//
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access'
,
//
'--access',
'public'
,
//
'public',
...(
version
.
includes
(
'canary'
)
?
[
'--tag'
,
'canary'
]
:
[]),
//
...(version.includes('canary') ? ['--tag', 'canary'] : []),
],
//
],
{
stdio
:
'inherit'
}
//
{ stdio: 'inherit' }
)
//
)
}
catch
(
err
)
{
//
} catch (err) {
// don't block publishing other versions on single platform error
//
// don't block publishing other versions on single platform error
console
.
error
(
`Failed to publish`
,
wasmTarget
,
err
)
//
console.error(`Failed to publish`, wasmTarget, err)
if
(
//
if (
err
.
message
&&
//
err.message &&
err
.
message
.
includes
(
//
err.message.includes(
'You cannot publish over the previously published versions'
//
'You cannot publish over the previously published versions'
)
//
)
)
{
//
) {
console
.
error
(
'Ignoring already published error'
,
wasmTarget
)
//
console.error('Ignoring already published error', wasmTarget)
}
else
{
//
} else {
// throw err
//
// throw err
}
//
}
}
finally
{
//
} finally {
publishSema
.
release
()
//
publishSema.release()
}
//
}
})
//
})
)
//
)
// Update optional dependencies versions
// Update optional dependencies versions
let
nextPkg
=
JSON
.
parse
(
let
nextPkg
=
JSON
.
parse
(
await
readFile
(
path
.
join
(
cwd
,
'packages/next/package.json'
))
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
)
{
for
(
let
platform
of
platforms
)
{
let
optionalDependencies
=
nextPkg
.
optionalDependencies
||
{}
let
optionalDependencies
=
nextPkg
.
optionalDependencies
||
{}
optionalDependencies
[
'@next/swc-'
+
platform
]
=
version
optionalDependencies
[
'@next/swc-'
+
platform
]
=
'13.5.9'
nextPkg
.
optionalDependencies
=
optionalDependencies
nextPkg
.
optionalDependencies
=
optionalDependencies
}
}
await
writeFile
(
await
writeFile
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment