Skip to content

Commit 9c93972

Browse files
sokraclaude
andauthored
Fix preview tarball script to include @next/swc-linux-x64-gnu (#91099)
### What? Adds `@next/swc-linux-x64-gnu` to the preview tarball patching script (`scripts/patch-preview-tarball.mjs`): 1. Adds the package to the `PACKAGES_TO_PATCH` list so its tarball URL is fetched. 2. Adds the package as an explicit dependency in the patched `package.json`, in addition to the overrides/resolutions. ### Why? The `@next/swc-linux-x64-gnu` native binary package is an optional dependency of `next` and may not be installed automatically depending on the platform/package manager. When testing preview tarballs (e.g., in CI or on Linux environments), the SWC binary needs to be explicitly present for Next.js to function correctly. Without this change, preview tarball testing on Linux x64 could fail because the native binary isn't resolved from the preview build. Adding it as a direct dependency (not just an override/resolution) ensures the package manager actually installs it, since optional dependencies from overridden tarballs may not be auto-resolved. ### How? - Added `'@next/swc-linux-x64-gnu'` to the `PACKAGES_TO_PATCH` array so the script fetches its tarball URL. - After writing overrides/resolutions, the script now also adds `@next/swc-linux-x64-gnu` as an explicit entry in `pkg.dependencies` pointing to the tarball URL. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5a22623 commit 9c93972

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/patch-preview-tarball.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const PACKAGES_TO_PATCH = [
1010
'@next/mdx',
1111
'@next/env',
1212
'@next/bundle-analyzer',
13+
'@next/swc-linux-x64-gnu',
1314
]
1415

1516
// --- Argument parsing ---
@@ -186,6 +187,12 @@ async function patchPackageJson(projectPath, tarballUrls) {
186187
pkg.resolutions[name] = url
187188
}
188189

190+
// Add @next/swc-linux-x64-gnu to dependencies
191+
pkg.dependencies = pkg.dependencies || {}
192+
pkg.dependencies['@next/swc-linux-x64-gnu'] = tarballUrls.get(
193+
'@next/swc-linux-x64-gnu'
194+
)
195+
189196
await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n')
190197

191198
console.log(`Patched ${packageJsonPath}`)

0 commit comments

Comments
 (0)