Skip to content

Commit

Permalink
fix(*): wasi package load logic (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jan 3, 2024
1 parent 55321ad commit 505856c
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
with:
operating_system: freebsd
version: '13.2'
memory: 13G
memory: 8G
cpu_count: 3
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"@emnapi/core": "^0.45.0",
"@emnapi/runtime": "^0.45.0",
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@swc-node/core": "^1.10.6",
"@swc-node/register": "^1.6.8",
"@swc/core": "^1.3.101",
Expand Down
7 changes: 7 additions & 0 deletions packages/argon2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('@node-rs/argon2-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}

if (!nativeBinding) {
Expand Down
2 changes: 1 addition & 1 deletion packages/argon2/npm/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"homepage": "https://github.com/napi-rs/node-rs",
"license": "MIT",
"engines": {
"node": ">= 10"
"node": ">=14.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
6 changes: 5 additions & 1 deletion packages/argon2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"wasm32-wasi-preview1-threads"
]
},
"files": [
"index.js",
"index.d.ts"
],
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
Expand All @@ -56,7 +60,7 @@
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"argon2": "^0.31.2",
"cross-env": "^7.0.3"
}
Expand Down
7 changes: 7 additions & 0 deletions packages/bcrypt/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('@node-rs/bcrypt-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}

if (!nativeBinding) {
Expand Down
2 changes: 1 addition & 1 deletion packages/bcrypt/npm/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"homepage": "https://github.com/napi-rs/node-rs",
"license": "MIT",
"engines": {
"node": ">= 10"
"node": ">=14.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
2 changes: 1 addition & 1 deletion packages/bcrypt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"url": "https://github.com/napi-rs/node-rs/issues"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@types/bcrypt": "^5.0.2",
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
Expand Down
7 changes: 7 additions & 0 deletions packages/crc32/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('@node-rs/crc32-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}

if (!nativeBinding) {
Expand Down
2 changes: 1 addition & 1 deletion packages/crc32/npm/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/napi-rs/node-rs",
"license": "MIT",
"engines": {
"node": ">= 10"
"node": ">=14.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
2 changes: 1 addition & 1 deletion packages/crc32/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"url": "https://github.com/napi-rs/node-rs/issues"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@types/crc": "^3.8.3",
"buffer": "^6.0.3",
"crc": "^4.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/deno-lint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"typanion": "^3.14.0"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@types/webpack": "^5.28.5"
},
"funding": {
Expand Down
7 changes: 7 additions & 0 deletions packages/jieba/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('@node-rs/jieba-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}

if (!nativeBinding) {
Expand Down
2 changes: 1 addition & 1 deletion packages/jieba/npm/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"homepage": "https://github.com/napi-rs/node-rs",
"license": "MIT",
"engines": {
"node": ">= 10"
"node": ">=14.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
2 changes: 1 addition & 1 deletion packages/jieba/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"url": "https://github.com/napi-rs/node-rs/issues"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"nodejieba": "^2.6.0"
},
"funding": {
Expand Down
2 changes: 1 addition & 1 deletion packages/jsonwebtoken/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"node": ">= 10"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@types/jsonwebtoken": "^9.0.5",
"jsonwebtoken": "^9.0.2"
}
Expand Down
7 changes: 7 additions & 0 deletions packages/xxhash/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
} catch {
// ignore
}
if (!nativeBinding) {
try {
nativeBinding = require('@node-rs/xxhash-wasm32-wasi')
} catch (err) {
console.error(err)
}
}
}

if (!nativeBinding) {
Expand Down
2 changes: 1 addition & 1 deletion packages/xxhash/npm/wasm32-wasi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"homepage": "https://github.com/napi-rs/node-rs",
"license": "MIT",
"engines": {
"node": ">= 12"
"node": ">=14.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
2 changes: 1 addition & 1 deletion packages/xxhash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"url": "https://github.com/napi-rs/node-rs/issues"
},
"devDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.29",
"@napi-rs/cli": "^3.0.0-alpha.30",
"@types/xxhashjs": "^0.2.4",
"webpack": "^5.89.0",
"xxhash": "^0.3.0",
Expand Down
25 changes: 13 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ __metadata:
languageName: node
linkType: hard

"@napi-rs/cli@npm:^3.0.0-alpha.29":
version: 3.0.0-alpha.29
resolution: "@napi-rs/cli@npm:3.0.0-alpha.29"
"@napi-rs/cli@npm:^3.0.0-alpha.30":
version: 3.0.0-alpha.30
resolution: "@napi-rs/cli@npm:3.0.0-alpha.30"
dependencies:
"@napi-rs/cross-toolchain": "npm:^0.0.14"
"@octokit/rest": "npm:^20.0.2"
Expand All @@ -340,6 +340,7 @@ __metadata:
inquirer: "npm:^9.2.12"
js-yaml: "npm:^4.1.0"
lodash-es: "npm:^4.17.21"
semver: "npm:^7.5.4"
toml: "npm:^3.0.0"
typanion: "npm:^3.14.0"
peerDependencies:
Expand All @@ -356,7 +357,7 @@ __metadata:
bin:
napi: dist/cli.js
napi-raw: cli.mjs
checksum: 25ed4464d150d6a18dbbdf1ca25fd9351510f212597e9fc613dc5f74509e618935b3fa453edd3bc4c4d8c13319d5f3d5740671bca228599c1b9608d0a219ee44
checksum: e06b7273977a1bb48ae1b45c52370a2e3f34577db2161c9886ed846430aca0c1a53098f76c7d0c89c38a0d44dbc7d56c64e678f39d043fbe27d6906775b72457
languageName: node
linkType: hard

Expand Down Expand Up @@ -680,7 +681,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/argon2@workspace:packages/argon2"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
argon2: "npm:^0.31.2"
cross-env: "npm:^7.0.3"
languageName: unknown
Expand All @@ -690,7 +691,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/bcrypt@workspace:packages/bcrypt"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@types/bcrypt": "npm:^5.0.2"
bcrypt: "npm:^5.1.1"
bcryptjs: "npm:^2.4.3"
Expand All @@ -702,7 +703,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/crc32@workspace:packages/crc32"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@types/crc": "npm:^3.8.3"
buffer: "npm:^6.0.3"
crc: "npm:^4.3.2"
Expand All @@ -714,7 +715,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/deno-lint@workspace:packages/deno-lint"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@types/webpack": "npm:^5.28.5"
clipanion: "npm:^3.2.1"
typanion: "npm:^3.14.0"
Expand All @@ -735,7 +736,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/jieba@workspace:packages/jieba"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
nodejieba: "npm:^2.6.0"
languageName: unknown
linkType: soft
Expand All @@ -744,7 +745,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/jsonwebtoken@workspace:packages/jsonwebtoken"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@types/jsonwebtoken": "npm:^9.0.5"
jsonwebtoken: "npm:^9.0.2"
languageName: unknown
Expand All @@ -754,7 +755,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@node-rs/xxhash@workspace:packages/xxhash"
dependencies:
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@types/xxhashjs": "npm:^0.2.4"
webpack: "npm:^5.89.0"
xxhash: "npm:^0.3.0"
Expand Down Expand Up @@ -6841,7 +6842,7 @@ __metadata:
dependencies:
"@emnapi/core": "npm:^0.45.0"
"@emnapi/runtime": "npm:^0.45.0"
"@napi-rs/cli": "npm:^3.0.0-alpha.29"
"@napi-rs/cli": "npm:^3.0.0-alpha.30"
"@swc-node/core": "npm:^1.10.6"
"@swc-node/register": "npm:^1.6.8"
"@swc/core": "npm:^1.3.101"
Expand Down

0 comments on commit 505856c

Please sign in to comment.