Skip to content

Commit

Permalink
Use @next scope for native packages (#28046)
Browse files Browse the repository at this point in the history
  • Loading branch information
padmaia committed Aug 12, 2021
1 parent 25df53d commit ff5e444
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/swc/index.js
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/darwin-arm64/README.md
@@ -0,0 +1,3 @@
# `@next/swc-darwin-arm64`

This is the **aarch64-apple-darwin** binary for `@next/swc`
@@ -1,5 +1,5 @@
{
"name": "next-swc-darwin-arm64",
"name": "@next/swc-darwin-arm64",
"version": "0.0.0",
"os": [
"darwin"
Expand Down
3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/darwin-x64/README.md
@@ -0,0 +1,3 @@
# `@next/swc-darwin-x64`

This is the **x86_64-apple-darwin** binary for `@next/swc`
@@ -1,5 +1,5 @@
{
"name": "next-swc-darwin-x64",
"name": "@next/swc-darwin-x64",
"version": "0.0.0",
"os": [
"darwin"
Expand Down
3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/linux-x64-gnu/README.md
@@ -0,0 +1,3 @@
# `@next/swc-linux-x64-gnu`

This is the **x86_64-unknown-linux-gnu** binary for `@next/swc`
@@ -1,5 +1,5 @@
{
"name": "next-swc-linux-x64-gnu",
"name": "@next/swc-linux-x64-gnu",
"version": "0.0.0",
"os": [
"linux"
Expand Down
3 changes: 0 additions & 3 deletions packages/next/build/swc/npm/next-swc-darwin-arm64/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/next/build/swc/npm/next-swc-darwin-x64/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/next/build/swc/npm/next-swc-linux-x64-gnu/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/next/build/swc/npm/next-swc-win32-x64-msvc/README.md

This file was deleted.

3 changes: 3 additions & 0 deletions packages/next/build/swc/npm/win32-x64-msvc/README.md
@@ -0,0 +1,3 @@
# `@next/swc-win32-x64-msvc`

This is the **x86_64-pc-windows-msvc** binary for `@next/swc`
@@ -1,5 +1,5 @@
{
"name": "next-swc-win32-x64-msvc",
"name": "@next/swc-win32-x64-msvc",
"version": "0.0.0",
"os": [
"win32"
Expand Down
27 changes: 12 additions & 15 deletions scripts/publish-native.js
Expand Up @@ -15,36 +15,33 @@ 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' : ''
}`
)
// lerna publish in next step will fail if git status is not clean
execSync(
`git update-index --skip-worktree ${path.join(
nativePackagesDir,
nativePackage,
platform,
'package.json'
)}`
)
Expand All @@ -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(
Expand Down

0 comments on commit ff5e444

Please sign in to comment.