mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### Why? In preparation for moving all turbopack crates Also makes them easier to work with in general. Closes PACK-3164
33 lines
851 B
JavaScript
33 lines
851 B
JavaScript
import path from 'path'
|
|
import fs from 'fs'
|
|
;(async function () {
|
|
try {
|
|
let wasmDir = path.join(process.cwd(), 'crates/wasm')
|
|
let wasmTarget = 'nodejs'
|
|
|
|
// CI restores artifact at pkg-${wasmTarget}
|
|
// This only runs locally
|
|
let folderName = fs.existsSync(path.join(wasmDir, 'pkg'))
|
|
? 'pkg'
|
|
: `pkg-${wasmTarget}`
|
|
|
|
let wasmPkg = JSON.parse(
|
|
fs.readFileSync(path.join(wasmDir, `${folderName}/package.json`))
|
|
)
|
|
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
|
|
|
|
fs.writeFileSync(
|
|
path.join(wasmDir, `${folderName}/package.json`),
|
|
JSON.stringify(wasmPkg, null, 2)
|
|
)
|
|
|
|
fs.cpSync(
|
|
path.join(wasmDir, folderName),
|
|
path.join(process.cwd(), `node_modules/@next/swc-wasm-${wasmTarget}`),
|
|
{ force: true, recursive: true }
|
|
)
|
|
} catch (e) {
|
|
console.error(e)
|
|
}
|
|
})()
|