build(node): Include fallback binding as a dependency (#5322)

This commit is contained in:
OJ Kwon 2022-07-27 20:10:08 -07:00 committed by GitHub
parent 61c23924fc
commit 0782d25074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 1 deletions

View File

@ -623,6 +623,11 @@ jobs:
run: ls -R ./scripts/npm
shell: bash
- name: Set fallback dependencies
shell: bash
run: |
node ./scripts/update_fallback_dependencies.js
- name: Publish
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc

View File

@ -8,8 +8,9 @@ do
CLI_BINARY_PATH=${filename%%.*}
if [ -f "$CLI_BINARY_PATH" ]; then
chmod +x $CLI_BINARY_PATH
mv $CLI_BINARY_PATH ./scripts/npm/$BINDING_ABI
else
elif [ -f "$CLI_BINARY_PATH.exe" ]; then
mv $CLI_BINARY_PATH.exe ./scripts/npm/$BINDING_ABI
fi
done

View File

@ -0,0 +1,28 @@
// For some native targets, we'll make `@swc/wasm` as dependency to ensure it can gracefully fallback
// While we migrate native builds into `@swc/wasm`.
const path = require("path");
const fs = require("fs");
const targets = [
"freebsd-x64",
"win32-ia32-msvc",
"linux-arm-gnueabihf",
"android-arm64",
"win32-arm64-msvc",
"android-arm-eabi",
];
(async () => {
for (const target of targets) {
const pkgPath = path.resolve(__dirname, "npm", target, "package.json");
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
const { version } = pkg;
pkg.dependencies = {
"@swc/wasm": version,
};
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
}
})().catch((err) => {
console.error("Failed to update dependencies", err);
});