Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @next scope for native packages #28046

Merged
merged 1 commit into from Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we initialize these packages on npm already with 0.0.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No ,0.0.0 is more of a placeholder as the versions get overwritten in the publish-native.js script. The updated versions are not being committed at the moment because it seemed kind of weird to commit it after the tag, but let me know if you have other ideas.

"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.

This file was deleted.

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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the outside await is not necessary here since filter() is not async

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, not sure what happened there

(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