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')
const bindings = loadBinding(
path.join(__dirname, '../../../native'),
'next-swc',
'next-swc'
'@next/swc'
)
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",
"os": [
"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",
"os": [
"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",
"os": [
"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",
"os": [
"win32"
......
......@@ -15,28 +15,25 @@ const cwd = process.cwd()
// Copy binaries to package folders, update version, and publish
let nativePackagesDir = path.join(cwd, 'packages/next/build/swc/npm')
let nativePackages = await readdir(nativePackagesDir)
for (let nativePackage of nativePackages) {
if (nativePackage === '.gitignore') {
continue
}
let binaryName = `next-swc.${nativePackage.substr(9)}.node`
let platforms = await (await readdir(nativePackagesDir)).filter(
(name) => name !== '.gitignore'
)
for (let platform of platforms) {
let binaryName = `next-swc.${platform}.node`
await copy(
path.join(cwd, 'packages/next/build/swc/dist', binaryName),
path.join(nativePackagesDir, nativePackage, binaryName)
path.join(nativePackagesDir, platform, binaryName)
)
let pkg = JSON.parse(
await readFile(
path.join(nativePackagesDir, nativePackage, 'package.json')
)
await readFile(path.join(nativePackagesDir, platform, 'package.json'))
)
pkg.version = version
await writeFile(
path.join(nativePackagesDir, nativePackage, 'package.json'),
path.join(nativePackagesDir, platform, 'package.json'),
JSON.stringify(pkg, null, 2)
)
execSync(
`npm publish ${path.join(nativePackagesDir, nativePackage)}${
`npm publish ${path.join(nativePackagesDir, platform)}${
gitref.includes('canary') ? ' --tag canary' : ''
}`
)
......@@ -44,7 +41,7 @@ const cwd = process.cwd()
execSync(
`git update-index --skip-worktree ${path.join(
nativePackagesDir,
nativePackage,
platform,
'package.json'
)}`
)
......@@ -54,9 +51,9 @@ const cwd = process.cwd()
let nextPkg = JSON.parse(
await readFile(path.join(cwd, 'packages/next/package.json'))
)
for (let name of nativePackages) {
for (let platform of platforms) {
let optionalDependencies = nextPkg.optionalDependencies || {}
optionalDependencies[name] = version
optionalDependencies['@next/swc-' + platform] = version
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