Skip to content

Commit

Permalink
chore: upgrade dependencies (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Jul 13, 2024
1 parent 6c520b8 commit 0bfabb2
Show file tree
Hide file tree
Showing 10 changed files with 736 additions and 2,790 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ env:
DEBUG: napi:*
APP_NAME: package-template
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_INCREMENTAL: '1'
permissions:
contents: write
id-token: write
Expand Down Expand Up @@ -35,9 +36,7 @@ jobs:
build: yarn build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: windows-latest
build: |
yarn build --target i686-pc-windows-msvc
yarn test
build: yarn build --target i686-pc-windows-msvc
target: i686-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
Expand Down Expand Up @@ -106,24 +105,13 @@ jobs:
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
with:
version: 0.12.0
version: 0.13.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
shell: bash
- name: Setup node x86
if: matrix.settings.target == 'i686-pc-windows-msvc'
run: yarn config set supportedArchitectures.cpu "ia32"
shell: bash
- name: Install dependencies
run: yarn install
- name: Setup node x86
uses: actions/setup-node@v4
if: matrix.settings.target == 'i686-pc-windows-msvc'
with:
node-version: 20
cache: yarn
architecture: x86
- name: Build in docker
uses: addnab/docker-run-action@v3
if: ${{ matrix.settings.docker }}
Expand Down
3 changes: 3 additions & 0 deletions __test__/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
11 changes: 11 additions & 0 deletions __test__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"outDir": "lib",
"rootDir": "."
},
"include": ["*.ts"],
"exclude": ["lib"]
}
29 changes: 11 additions & 18 deletions benchmark/bench.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
import b from 'benny'
import { Bench } from 'tinybench'

import { plus100 } from '../index'
import { plus100 } from '../index.js'

function add(a: number) {
return a + 100
}

async function run() {
await b.suite(
'Add 100',
const b = new Bench()

b.add('Native a + 100', () => {
plus100(10)
}),
b.add('Native a + 100', () => {
plus100(10)
})

b.add('JavaScript a + 100', () => {
add(10)
}),
b.add('JavaScript a + 100', () => {
add(10)
})

b.cycle(),
b.complete(),
)
}
await b.run()

run().catch((e) => {
console.error(e)
})
console.table(b.table())
3 changes: 3 additions & 0 deletions benchmark/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
10 changes: 10 additions & 0 deletions benchmark/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "NodeNext",
"module": "NodeNext",
"outDir": "lib"
},
"include": ["."],
"exclude": ["lib"]
}
56 changes: 53 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,62 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm-gnueabihf.node'))
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm-musleabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./package-template.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@napi-rs/package-template-linux-arm-musleabihf')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm-gnueabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./package-template.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@napi-rs/package-template-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'package-template.linux-riscv64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./package-template.linux-riscv64-musl.node')
} else {
nativeBinding = require('@napi-rs/package-template-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'package-template.linux-riscv64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./package-template.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@napi-rs/package-template-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(join(__dirname, 'package-template.linux-s390x-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./package-template.linux-arm-gnueabihf.node')
nativeBinding = require('./package-template.linux-s390x-gnu.node')
} else {
nativeBinding = require('@napi-rs/package-template-linux-arm-gnueabihf')
nativeBinding = require('@napi-rs/package-template-linux-s390x-gnu')
}
} catch (e) {
loadError = e
Expand Down
52 changes: 24 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,36 @@
},
"scripts": {
"artifacts": "napi artifacts",
"bench": "node -r @swc-node/register benchmark/bench.ts",
"build": "napi build --platform --release --pipe \"prettier -w\"",
"build:debug": "napi build --platform --pipe \"prettier -w\"",
"bench": "node --import @swc-node/register/esm-register benchmark/bench.ts",
"build": "napi build --platform --release",
"build:debug": "napi build --platform",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier . -w",
"format:toml": "taplo format",
"format:rs": "cargo fmt",
"lint": "eslint . -c ./.eslintrc.yml",
"lint": "oxlint .",
"prepublishOnly": "napi prepublish -t npm",
"test": "ava",
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "^2.16.4",
"@swc-node/register": "^1.6.8",
"@swc/core": "^1.3.95",
"@napi-rs/cli": "^2.18.4",
"@swc-node/register": "^1.10.6",
"@swc/core": "^1.6.13",
"@taplo/cli": "^0.7.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"ava": "^6.0.0",
"benny": "^3.7.1",
"ava": "^6.1.3",
"chalk": "^5.3.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^9.0.0",
"lint-staged": "^15.0.2",
"npm-run-all2": "^6.0.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"husky": "^9.0.11",
"lint-staged": "^15.2.7",
"npm-run-all2": "^6.2.2",
"oxlint": "^0.6.0",
"prettier": "^3.3.3",
"tinybench": "^2.8.0",
"typescript": "^5.5.3"
},
"lint-staged": {
"*.@(js|ts|tsx)": [
"eslint -c .eslintrc.yml --fix"
"oxlint --fix"
],
"*.@(js|ts|tsx|yml|yaml|md|json)": [
"prettier --write"
Expand All @@ -88,17 +83,18 @@
]
},
"ava": {
"require": [
"@swc-node/register"
],
"extensions": [
"ts"
],
"extensions": {
"ts": "module"
},
"timeout": "2m",
"workerThreads": false,
"environmentVariables": {
"TS_NODE_PROJECT": "./tsconfig.json"
}
},
"nodeArguments": [
"--import",
"@swc-node/register/esm-register"
]
},
"prettier": {
"printWidth": 120,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2018",
"target": "ESNext",
"strict": true,
"moduleResolution": "node",
"module": "CommonJS",
Expand All @@ -10,5 +10,5 @@
"allowSyntheticDefaultImports": true
},
"include": ["."],
"exclude": ["node_modules"]
"exclude": ["node_modules", "bench", "__test__"]
}
Loading

0 comments on commit 0bfabb2

Please sign in to comment.