@flun/node-mobile-app 3.1.2 → 3.1.3

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/CHANGELOG.md CHANGED
@@ -1,18 +1,12 @@
1
1
  # 变更日志
2
+ ## [3.1.3] - 2026-10-15 23:10
3
+ ### 修复
4
+ - **删除 `scripts` 字段的范围扩大**:原仅对被合并的包删除 `package.json` 的 `scripts`;跳过的包(如原生模块、JS 较少的包)仍保留,其安装期脚本会被 Gradle `npm rebuild` 触发,若脚本文件已被清理则报 `Cannot find module`、构建失败;现改为**对所有非原生包删除**(原生模块包保留,其 scripts 是编译必需);
5
+
2
6
  ## [3.1.2] - 2026-10-15 21:05
3
7
  ### 修复
4
8
  - 修复了 "src\optimize-node-modules.js" 中 prunePlatform 函数一些边界问题;
5
9
 
6
10
  ## [3.1.1] - 2026-10-15 20:29
7
11
  ### 更新
8
- - 同步更新了一些依赖包;
9
-
10
- ## [3.1.0] - 2026-10-15 20:15
11
- ### 修复
12
- - **优化阶段步骤顺序调整(重要)**:构建时原优化顺序是「先合并 JS、后清空资源」——合并会删除 postinstall 脚本文件,导致清空阶段读不到脚本、无法提取资源目录,报「清空 0 项」、资源目录残留;现改为**先清空资源、后合并**:
13
- - 清空资源时**跳过 js 文件**,留待合并阶段处理;
14
- - 日志如实反映:「清空 N 个文件(js 文件保留,留待合并阶段处理)」;
15
- - **`clearItem` 单文件分支漏判 js(重要)**:目录分支已有「跳过 js」判断,单文件分支遗漏,导致资源目录中的**单个 js 文件**被清空为 0 字节,合并阶段读到空文件、产物损坏;现补充 js 判断,js 一律保留给合并阶段;
16
- - **合并阶段日志标题**:由「处理 JS 资源(用到则合并,未用到则提前清除)」改为「处理保留的资源 JS(被引用则合并,否则删除)」,与新流程呼应;
17
- - **Gradle 原生编译报 postinstall 失败(重要)**:Gradle 编译原生模块时执行 `npm rebuild`,会触发各包 postinstall;而合并阶段已删除脚本文件,导致 `Cannot find module ... copy-files.js`、构建失败;现合并阶段同步**删除 `package.json` 的 `scripts` 字段**(运行时无安装期,scripts 无用),rebuild 不再触发;
18
- - **`--debug` 下 `quiet` 命令仍被静默**:`run` 的 quiet 分支未判断 debug,导致 `--debug` 时 `gradlew` / `xcodebuild` 等命令输出仍被吞;现改为「debug 时忽略 quiet,全量输出」(不影响默认模式下 test 的精简行为);
12
+ - 同步更新了一些依赖包;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/node-mobile-app",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "将 Node.js 项目一键打包为 Android / iOS 移动应用,运行时由 @flun/nodejs-mobile-react-native 提供,无需修改你的 Node 代码;",
5
5
  "author": "flun <open@flun.top>",
6
6
  "keywords": [
@@ -60,7 +60,7 @@
60
60
  "jimp": "^1.6.1",
61
61
  "prettier": "^3.9.10",
62
62
  "react": "^19.3.1",
63
- "react-native": "^0.87.1",
63
+ "react-native": "^0.88.0",
64
64
  "react-native-webview": "^14.0.1"
65
65
  },
66
66
  "allowScripts": {
@@ -190,6 +190,9 @@ const require = createRequire(import.meta.url), subpath = (...parts) => './' + p
190
190
  if (excludePkgs.has(relName)) { skipped++; continue; }
191
191
  if (SKIP_PKGS.has(relName)) { skipped++; continue; }
192
192
  if (hasNativeModule(pkgDir)) { skipped++; continue; }
193
+ // 删除安装期脚本字段:运行时无安装期,且 Gradle npm rebuild 会触发脚本导致失败
194
+ // 原生模块包已在上一步跳过(其 scripts 是编译必需,必须保留)
195
+ if (j.scripts) { delete j.scripts; fs.writeFileSync(pj, JSON.stringify(j, null, 2)); }
193
196
  if (countJS(pkgDir) <= 1) { skipped++; continue; }
194
197
  // 已优化过的包跳过
195
198
  const mainStr = String(j.main || ''), exportsStr = JSON.stringify(j.exports || '');
@@ -285,8 +288,6 @@ const require = createRequire(import.meta.url), subpath = (...parts) => './' + p
285
288
  j.main = isESM ? newExports['.'] : (newExports['.'].require || newExports['.'].default || newExports['.']);
286
289
  else delete j.main;
287
290
  if (isESM && j.main) j.module = j.main;
288
- // 删除安装期脚本字段:移动端 Gradle 会 npm rebuild,触发 postinstall;运行时无安装期,scripts 无用
289
- delete j.scripts;
290
291
  fs.writeFileSync(pj, JSON.stringify(j, null, 2));
291
292
 
292
293
  // 删除原 JS