electron-incremental-update 2.3.7 → 2.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -278,7 +278,7 @@ const plugin = electronWithUpdater({
278
278
  db: './electron/native/db.ts',
279
279
  img: './electron/native/img.ts',
280
280
  },
281
- postBuild: async ({ copyToEntryOutputDir, copyModules }) => {
281
+ postBuild: ({ copyToEntryOutputDir, copyModules }) => {
282
282
  // for better-sqlite3
283
283
  copyToEntryOutputDir({
284
284
  from: './node_modules/better-sqlite3/build/Release/better_sqlite3.node',
@@ -286,7 +286,7 @@ const plugin = electronWithUpdater({
286
286
  })
287
287
  // for @napi-rs/image
288
288
  const startStr = '@napi-rs+image-'
289
- const fileName = (await readdir('./node_modules/.pnpm')).filter(p => p.startsWith(startStr))[0]
289
+ const fileName = readdirSync('./node_modules/.pnpm').find(p => p.startsWith(startStr))!
290
290
  const archName = fileName.substring(startStr.length).split('@')[0]
291
291
  copyToEntryOutputDir({
292
292
  from: `./node_modules/.pnpm/${fileName}/node_modules/@napi-rs/image-${archName}/image.${archName}.node`,
@@ -350,6 +350,74 @@ module.exports = {
350
350
  }
351
351
  ```
352
352
 
353
+ #### Result in app.asar
354
+
355
+ Before: Redundant 🤮
356
+
357
+ ```
358
+ .
359
+ ├── dist-entry
360
+ │ ├── chunk-IVHNGRZY-BPUeB0jT.js
361
+ │ ├── db.js
362
+ │ ├── entry.js
363
+ │ └── image.js
364
+ ├── node_modules
365
+ │ ├── @napi-rs
366
+ │ ├── base64-js
367
+ │ ├── better-sqlite3
368
+ │ ├── bindings
369
+ │ ├── bl
370
+ │ ├── buffer
371
+ │ ├── chownr
372
+ │ ├── decompress-response
373
+ │ ├── deep-extend
374
+ │ ├── detect-libc
375
+ │ ├── end-of-stream
376
+ │ ├── expand-template
377
+ │ ├── file-uri-to-path
378
+ │ ├── fs-constants
379
+ │ ├── github-from-package
380
+ │ ├── ieee754
381
+ │ ├── inherits
382
+ │ ├── ini
383
+ │ ├── mimic-response
384
+ │ ├── minimist
385
+ │ ├── mkdirp-classic
386
+ │ ├── napi-build-utils
387
+ │ ├── node-abi
388
+ │ ├── once
389
+ │ ├── prebuild-install
390
+ │ ├── pump
391
+ │ ├── rc
392
+ │ ├── readable-stream
393
+ │ ├── safe-buffer
394
+ │ ├── semver
395
+ │ ├── simple-concat
396
+ │ ├── simple-get
397
+ │ ├── string_decoder
398
+ │ ├── strip-json-comments
399
+ │ ├── tar-fs
400
+ │ ├── tar-stream
401
+ │ ├── tunnel-agent
402
+ │ ├── util-deprecate
403
+ │ └── wrappy
404
+ └── package.json
405
+ ```
406
+
407
+ After: Clean 😍
408
+
409
+ ```
410
+ .
411
+ ├── dist-entry
412
+ │ ├── better_sqlite3.node
413
+ │ ├── chunk-IVHNGRZY-BPUeB0jT.js
414
+ │ ├── db.js
415
+ │ ├── entry.js
416
+ │ ├── image.js
417
+ │ └── image.win32-x64-msvc.node
418
+ └── package.json
419
+ ```
420
+
353
421
  ### Bytecode Protection
354
422
 
355
423
  Use V8 cache to protect the source code
@@ -923,7 +991,9 @@ export interface BuildEntryOption {
923
991
  /**
924
992
  * `external` option in `build.rollupOptions`,
925
993
  * default is node built-in modules or native modules.
926
- * If is in dev, also external `dependencies` in package.json
994
+ *
995
+ * If is in dev and {@link postBuild} is not setup, will also
996
+ * external `dependencies` in `package.json`
927
997
  */
928
998
  external?: NonNullable<NonNullable<InlineConfig['build']>['rollupOptions']>['external']
929
999
  /**
@@ -944,8 +1014,9 @@ export interface BuildEntryOption {
944
1014
  */
945
1015
  overrideViteOptions?: InlineConfig
946
1016
  /**
947
- * Resolve extra files on startup, such as `.node`
948
- * @remark won't trigger will reload
1017
+ * By default, all the unbundled modules will be packaged by packager like `electron-builder`.
1018
+ * If setup, all the `dependencies` in `package.json` will be bundled by default, and you need
1019
+ * to manually handle the native module files.
949
1020
  */
950
1021
  postBuild?: (args: {
951
1022
  /**
package/dist/vite.d.ts CHANGED
@@ -106,7 +106,9 @@ interface BuildEntryOption {
106
106
  /**
107
107
  * `external` option in `build.rollupOptions`,
108
108
  * default is node built-in modules or native modules.
109
- * If is in dev, also external `dependencies` in package.json
109
+ *
110
+ * If is in dev and {@link postBuild} is not setup, will also
111
+ * external `dependencies` in `package.json`
110
112
  */
111
113
  external?: NonNullable<NonNullable<InlineConfig['build']>['rollupOptions']>['external'];
112
114
  /**
@@ -127,8 +129,12 @@ interface BuildEntryOption {
127
129
  */
128
130
  overrideViteOptions?: InlineConfig;
129
131
  /**
130
- * Resolve extra files on startup, such as `.node`
131
- * @remark won't trigger will reload
132
+ * By default, all the unbundled modules will be packaged by packager like `electron-builder`.
133
+ * If setup, all the `dependencies` in `package.json` will be bundled by default, and you need
134
+ * to manually handle the native module files.
135
+ *
136
+ * If you are using `electron-buidler`, don't forget to append `'!node_modules/**'` in
137
+ * electron-build config's `files` array
132
138
  */
133
139
  postBuild?: (args: {
134
140
  /**
package/dist/vite.js CHANGED
@@ -607,7 +607,7 @@ function parseOptions(isBuild, pkg, sourcemap = false, minify = false, options =
607
607
  /.*\.(node|dll|dylib|so)$/,
608
608
  "original-fs",
609
609
  ...builtinModules,
610
- ...isBuild ? [] : Object.keys("dependencies" in pkg ? pkg.dependencies : {})
610
+ ...isBuild || postBuild ? [] : Object.keys("dependencies" in pkg ? pkg.dependencies : {})
611
611
  ],
612
612
  overrideViteOptions = {}
613
613
  } = {},
@@ -792,12 +792,12 @@ async function electronWithUpdater(options) {
792
792
  getPathFromEntryOutputDir(...paths) {
793
793
  return path5.join(entryOutputDirPath, ...paths);
794
794
  },
795
- copyToEntryOutputDir({ from, to, skipIfExist = true }) {
795
+ copyToEntryOutputDir({ from, to = path5.basename(from), skipIfExist = true }) {
796
796
  if (!fs5.existsSync(from)) {
797
797
  log.warn(`${from} not found`, { timestamp: true });
798
798
  return;
799
799
  }
800
- const target = path5.join(entryOutputDirPath, to ?? path5.basename(from));
800
+ const target = path5.join(entryOutputDirPath, to);
801
801
  copyAndSkipIfExist(from, target, skipIfExist);
802
802
  },
803
803
  copyModules({ modules, skipIfExist = true }) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-incremental-update",
3
3
  "type": "module",
4
- "version": "2.3.7",
4
+ "version": "2.3.8",
5
5
  "description": "Electron incremental update tools with Vite plugin, support bytecode protection",
6
6
  "author": "subframe7536",
7
7
  "license": "MIT",