Unverified Commit ff5e4442 authored by Maia Teegarden's avatar Maia Teegarden Committed by GitHub

Use @next scope for native packages (#28046)

parent 25df53d1
...@@ -12,7 +12,7 @@ const path = require('path') ...@@ -12,7 +12,7 @@ const path = require('path')
const bindings = loadBinding( const bindings = loadBinding(
path.join(__dirname, '../../../native'), path.join(__dirname, '../../../native'),
'next-swc', 'next-swc',
'next-swc' '@next/swc'
) )
async function transform(src, options) { async function transform(src, options) {
......
# `@next/swc-darwin-arm64`
This is the **aarch64-apple-darwin** binary for `@next/swc`
{ {
"name": "next-swc-darwin-arm64", "name": "@next/swc-darwin-arm64",
"version": "0.0.0", "version": "0.0.0",
"os": [ "os": [
"darwin" "darwin"
......
# `@next/swc-darwin-x64`
This is the **x86_64-apple-darwin** binary for `@next/swc`
{ {
"name": "next-swc-darwin-x64", "name": "@next/swc-darwin-x64",
"version": "0.0.0", "version": "0.0.0",
"os": [ "os": [
"darwin" "darwin"
......
# `@next/swc-linux-x64-gnu`
This is the **x86_64-unknown-linux-gnu** binary for `@next/swc`
{ {
"name": "next-swc-linux-x64-gnu", "name": "@next/swc-linux-x64-gnu",
"version": "0.0.0", "version": "0.0.0",
"os": [ "os": [
"linux" "linux"
......
# `next-swc-darwin-arm64`
This is the **aarch64-apple-darwin** binary for `next-swc`
# `next-swc-darwin-x64`
This is the **x86_64-apple-darwin** binary for `next-swc`
# `next-swc-linux-x64-gnu`
This is the **x86_64-unknown-linux-gnu** binary for `next-swc`
# `next-swc-win32-x64-msvc`
This is the **x86_64-pc-windows-msvc** binary for `next-swc`
# `@next/swc-win32-x64-msvc`
This is the **x86_64-pc-windows-msvc** binary for `@next/swc`
{ {
"name": "next-swc-win32-x64-msvc", "name": "@next/swc-win32-x64-msvc",
"version": "0.0.0", "version": "0.0.0",
"os": [ "os": [
"win32" "win32"
......
...@@ -15,28 +15,25 @@ const cwd = process.cwd() ...@@ -15,28 +15,25 @@ const cwd = process.cwd()
// 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/build/swc/npm') let nativePackagesDir = path.join(cwd, 'packages/next/build/swc/npm')
let nativePackages = await readdir(nativePackagesDir) let platforms = await (await readdir(nativePackagesDir)).filter(
for (let nativePackage of nativePackages) { (name) => name !== '.gitignore'
if (nativePackage === '.gitignore') { )
continue for (let platform of platforms) {
} let binaryName = `next-swc.${platform}.node`
let binaryName = `next-swc.${nativePackage.substr(9)}.node`
await copy( await copy(
path.join(cwd, 'packages/next/build/swc/dist', binaryName), path.join(cwd, 'packages/next/build/swc/dist', binaryName),
path.join(nativePackagesDir, nativePackage, 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, nativePackage, 'package.json')
)
) )
pkg.version = version pkg.version = version
await writeFile( await writeFile(
path.join(nativePackagesDir, nativePackage, 'package.json'), path.join(nativePackagesDir, platform, 'package.json'),
JSON.stringify(pkg, null, 2) JSON.stringify(pkg, null, 2)
) )
execSync( execSync(
`npm publish ${path.join(nativePackagesDir, nativePackage)}${ `npm publish ${path.join(nativePackagesDir, platform)}${
gitref.includes('canary') ? ' --tag canary' : '' gitref.includes('canary') ? ' --tag canary' : ''
}` }`
) )
...@@ -44,7 +41,7 @@ const cwd = process.cwd() ...@@ -44,7 +41,7 @@ const cwd = process.cwd()
execSync( execSync(
`git update-index --skip-worktree ${path.join( `git update-index --skip-worktree ${path.join(
nativePackagesDir, nativePackagesDir,
nativePackage, platform,
'package.json' 'package.json'
)}` )}`
) )
...@@ -54,9 +51,9 @@ const cwd = process.cwd() ...@@ -54,9 +51,9 @@ const cwd = process.cwd()
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'))
) )
for (let name of nativePackages) { for (let platform of platforms) {
let optionalDependencies = nextPkg.optionalDependencies || {} let optionalDependencies = nextPkg.optionalDependencies || {}
optionalDependencies[name] = version optionalDependencies['@next/swc-' + platform] = version
nextPkg.optionalDependencies = optionalDependencies nextPkg.optionalDependencies = optionalDependencies
} }
await writeFile( 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