mirror of
https://github.com/swc-project/swc.git
synced 2024-09-11 16:55:27 +03:00
build(node): Include fallback binding as a dependency (#5322)
This commit is contained in:
parent
61c23924fc
commit
0782d25074
5
.github/workflows/publish-node.yml
vendored
5
.github/workflows/publish-node.yml
vendored
@ -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
|
||||
|
@ -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
|
28
scripts/update_fallback_dependencies.js
Normal file
28
scripts/update_fallback_dependencies.js
Normal 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);
|
||||
});
|
Loading…
Reference in New Issue
Block a user