Skip to content

Commit f593c71

Browse files
committed
v2.2.0
1 parent 64b881a commit f593c71

6 files changed

Lines changed: 37 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.2.0 (2023-06-27)
2+
3+
- 64b881a feat: add `options.forceCopyIfUnbuilt`
4+
- 7c60957 feat: add `options.ignore`
5+
16
## 2.1.0 (2023-06-25)
27

38
- 867f085 test: v2.1.0

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-native",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "Supports Node/Electron C/C++ native addons",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
@@ -20,12 +20,14 @@
2020
"build": "vite build",
2121
"types": "tsc --emitDeclarationOnly",
2222
"prepublishOnly": "npm run build && npm run test",
23+
"build:test": "vite build -c test/fixtures/vite.config.ts",
2324
"test": "vitest run"
2425
},
2526
"dependencies": {
2627
"@vercel/webpack-asset-relocator-loader": "1.7.3",
28+
"dependencies-tree": "~0.2.0",
2729
"fast-glob": "^3.3.2",
28-
"lib-esm": "^0.4.2",
30+
"lib-esm": "~0.4.2",
2931
"node-loader": "^2.0.0",
3032
"webpack": "^5.70.0"
3133
},

test/fixtures/main.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22

3-
// TODO: https://github.com/serialport/node-serialport/issues/2464
4-
// import * as serialport from 'serialport'
3+
// 🚨 https://github.com/serialport/node-serialport/issues/2464
4+
import { SerialPort } from 'serialport'
55
import * as fsevents from 'fsevents'
66
import sqlite3 from 'sqlite3'
77
import BetterSqlite3 from 'better-sqlite3'
@@ -47,3 +47,18 @@ export function initBetterSqlite3() {
4747
})
4848
})
4949
}
50+
51+
export async function initSerialport() {
52+
try {
53+
const list = await SerialPort.list()
54+
return {
55+
list,
56+
error: Array.isArray(list) ? null : new Error('serialport initialize failed'),
57+
}
58+
} catch (error) {
59+
return {
60+
list: null,
61+
error,
62+
}
63+
}
64+
}

test/fixtures/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default defineConfig({
2626
},
2727
plugins: [
2828
native({
29-
natives: (names) => names.concat('serialport'),
29+
forceCopyIfUnbuilt: true,
3030
webpack: {},
3131
}),
3232
],

test/index.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ test('vite-plugin-native', async () => {
2424
const sqlite3 = main.sqlite3
2525
const sqlite3DB = await main.initSqlite3()
2626
const better_sqlite3DB = await main.initBetterSqlite3()
27+
const serialport = await main.initSerialport()
2728

2829
const fseventsKeys1 = Object.getOwnPropertyNames(fsevents).filter(name => name !== 'default')
2930
// esm export members will be auto sort.
@@ -39,4 +40,7 @@ test('vite-plugin-native', async () => {
3940

4041
expect(better_sqlite3DB.database && typeof better_sqlite3DB.database).eq('object')
4142
expect(better_sqlite3DB.error).null
43+
44+
expect(Array.isArray(serialport.list)).true
45+
expect(serialport.error).null
4246
})

yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,11 @@ delegates@^1.0.0:
922922
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
923923
integrity sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==
924924

925+
dependencies-tree@~0.2.0:
926+
version "0.2.0"
927+
resolved "https://registry.yarnpkg.com/dependencies-tree/-/dependencies-tree-0.2.0.tgz#2f740faf194d983f08e1bf492f72b197191154e7"
928+
integrity sha512-Cxh109TbDFhDxHEdKakySnS7FGUIOWg85kftI1h8HK8pRCLvq1aYFPl59HennOFmwczd7K2LTxOwUBJOrnEz6Q==
929+
925930
detect-libc@^2.0.0:
926931
version "2.0.3"
927932
resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.3.tgz#f0cd503b40f9939b894697d19ad50895e30cf700"
@@ -1382,7 +1387,7 @@ json5@^2.1.2:
13821387
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
13831388
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==
13841389

1385-
lib-esm@^0.4.2:
1390+
lib-esm@~0.4.2:
13861391
version "0.4.2"
13871392
resolved "https://registry.yarnpkg.com/lib-esm/-/lib-esm-0.4.2.tgz#1f08ad1750b46c47d371d4f7e1a772b56db3324d"
13881393
integrity sha512-VGqaEGuryUbT7FLGxXg46nrSzkhLzyk+JQjYoYEORH5UtdIu3yf6DCOqh65FOR3bWOHHGINQH/vR5YGGIFBgJw==

0 commit comments

Comments
 (0)