@flun/node-mobile-app 4.0.0 → 4.0.2

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,4 +1,21 @@
1
1
  # 变更日志
2
+ ## [4.0.2] - 2026-10-20 15:56
3
+
4
+ ### 修复
5
+ - **CLI 或插件版本变化时跳过依赖重装,产物沿用旧优化规则**:`[3/11]` 检测到 CLI 版本、插件版本、ABI、libnode、模板文件变化时,原逻辑只清 Gradle 构建目录与插件 CMake 缓存,不清 `nodejs-assets` 与 `.deps-snapshot.json`;`[5/11]` 读到的仍是旧快照,判定"依赖与环境未变化",跳过安装与优化;结果是新版本代码配旧规则产物,原生模块的编译源文件、中间产物、异平台 prebuilds 可能残留;现拆分为 `clearGradleCaches` 与 `clearDepsCaches`,前者清 Gradle 与插件构建目录,后者清 `nodejs-assets` 与依赖快照;版本类变化同时清两者,触发重装、重编、重优化;
6
+ - **`[3/11]` 提示与实际清理范围不符**:原提示"清理全部缓存"实际只清 Gradle 构建目录;`depsChanged` / `appInfoChanged` 分支提示"清理 nodejs-assets 缓存 + app/build",但 `nodejs-assets` 从未被清理;现提示按实际清理目标拼接--版本类变化为"清理 Gradle 缓存、CMake 缓存与依赖缓存",依赖变化为"清理依赖缓存、Gradle 缓存",仅应用信息变化为"清理 Gradle 缓存";
7
+
8
+ ## [4.0.1] - 2026-10-20 14:48
9
+
10
+ ### 紧急修复
11
+ - **4.0.0 在全新安装时原生模块产物错误,应用无法正常加载**:4.0.0 发布时依赖 `@flun/nodejs-mobile-react-native` 的版本被锁定为 2.0.8,而 2.0.8 缺少配合编译前移的 Gradle 改动;结果 `DeleteIncorrectPrebuilds` 删除前移阶段已编译的 `.node`、`DetectCorrectPrebuilds` 用 prebuild 覆盖已编译结果、`BuildNpmModules` 重复编译,APK 内原生模块缺失或不匹配,应用启动后加载失败;现依赖 `@flun/nodejs-mobile-react-native@^2.1.0`,该版本在标记文件存在时保留 `build/Release/*.node`、跳过 prebuild 替换、跳过重复编译;
12
+
13
+ ### 升级注意事项
14
+ - **已装 4.0.0 必须升级**:4.0.0 的锁文件已固定 `nodejs-mobile-react-native@2.0.8`,直接使用会构建失败或运行异常;请安装 4.0.1,或手动执行 `npm update @flun/nodejs-mobile-react-native` 升至 2.1.0;
15
+
16
+ ### 更新
17
+ - 同步更新了一些依赖包
18
+
2
19
  ## [4.0.0] - 2026-10-20 12:09
3
20
 
4
21
  ### 升级注意事项
@@ -33,14 +50,3 @@
33
50
 
34
51
  ### 变更
35
52
  - **阶段 4 不再清理 `.d.ts`**:`.d.ts` 已由阶段 6 的 `TS_RE`(`/\.(ts|cts|mts)$/`)覆盖,阶段 4 重复清理属冗余;移除后 `.d.ts` 统一由阶段 6 处理,清理职责不重叠;
36
-
37
- ## [3.1.4] - 2026-10-17 11:32
38
- ### 修复
39
- - **修复 `react-native bundle` 报 `Cannot resolve @react-native/metro-config`**:个别场景下用户根 `node_modules` 中缺失该包(如历史安装残留,依赖布局异常),RN CLI 从其自身位置向上解析不到,导致 `test` / `build` 的 bundle 阶段中断;现由 `copyTemplate` 调用新增的 `linkNestedDeps`:遍历主包 `node_modules` 顶层全部条目(含 `@scope/` 子项,不列举包名),对从用户根解析不到的条目,在用户根 `node_modules` 下建 Junction(Windows)/ symlink(macOS/Linux)指向主包物理路径;用户根已能解析的条目跳过,不改 `package.json` / `package-lock.json`,建链接失败即中断;
40
-
41
- ### 变更
42
- - **Android 模板仓库增加阿里云镜像兜底**:`settings.gradle` 的 `pluginManagement.repositories` 与 `build.gradle` 的 `buildscript.repositories` 在 `google()` / `mavenCentral()` 之前插入阿里云镜像(gradle-plugin / google / public),改善国内网络拉取 `react-android`,`hermes-android` 等 AAR 时卡在官方源的问题;镜像在前,官方源在后,海外网络镜像不命中会自动回退官方源,仅多一次往返,不影响功能;不写死镜像为唯一源,镜像故障时仍可由官方源兜住;
43
-
44
- ## [3.1.3] - 2026-10-15 23:10
45
- ### 修复
46
- - **删除 `scripts` 字段的范围扩大**:原仅对被合并的包删除 `package.json` 的 `scripts`;跳过的包(如原生模块,JS 较少的包)仍保留,其安装期脚本会被 Gradle `npm rebuild` 触发,若脚本文件已被清理则报 `Cannot find module`,构建失败;现改为**对所有非原生包删除**(原生模块包保留,其 scripts 是编译必需);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/node-mobile-app",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "将 Node.js 项目一键打包为 Android / iOS 移动应用,运行时由 @flun/nodejs-mobile-react-native 提供,无需修改你的 Node 代码;",
5
5
  "author": "flun <open@flun.top>",
6
6
  "keywords": [
@@ -41,9 +41,9 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@babel/core": "^8.0.7",
44
- "@eslint-react/eslint-plugin": "^5.27.2",
44
+ "@eslint-react/eslint-plugin": "^5.28.2",
45
45
  "@eslint/js": "^10.0.1",
46
- "@flun/nodejs-mobile-react-native": "^2.0.8",
46
+ "@flun/nodejs-mobile-react-native": "^2.1.0",
47
47
  "@react-native/babel-preset": "^0.88.0",
48
48
  "@react-native/metro-config": "^0.88.0",
49
49
  "@react-native-community/cli": "^20.2.0",
@@ -54,7 +54,7 @@
54
54
  "@typescript-eslint/parser": "^8.72.0",
55
55
  "chalk": "^6.0.1",
56
56
  "esbuild": "^0.28.2",
57
- "eslint": "^10.12.0",
57
+ "eslint": "^10.13.0",
58
58
  "eslint-config-prettier": "^10.1.8",
59
59
  "eslint-plugin-eslint-comments": "^3.2.0",
60
60
  "eslint-plugin-react-hooks": "^7.1.1",
@@ -17,11 +17,15 @@ const FINGERPRINT_FILE = '.build-fingerprint.json',
17
17
  return h.digest('hex');
18
18
  },
19
19
  writeFp = (file, fp) => fs.writeFileSync(file, JSON.stringify(fp, null, 2), 'utf-8'),
20
- clearCommonCaches = (buildDir, userProjectDir) => {
20
+ clearGradleCaches = (buildDir, userProjectDir) => {
21
21
  removeDir(path.join(buildDir, 'android', 'build'));
22
22
  removeDir(path.join(buildDir, 'android', 'app', 'build'));
23
23
  removeDir(path.join(userProjectDir, 'node_modules', '@flun', 'nodejs-mobile-react-native', 'android', 'build'));
24
24
  },
25
+ clearDepsCaches = buildDir => {
26
+ removeDir(path.join(buildDir, 'nodejs-assets'));
27
+ removeDir(path.join(buildDir, '.deps-snapshot.json'));
28
+ },
25
29
  hashTemplate = templateDir => {
26
30
  const h = crypto.createHash('sha256'),
27
31
  walk = d => {
@@ -104,16 +108,18 @@ const FINGERPRINT_FILE = '.build-fingerprint.json',
104
108
  if (templateChanged) reasons.push('模板文件');
105
109
  if (depsChanged) reasons.push('用户依赖');
106
110
  if (appInfoChanged) reasons.push('应用信息');
107
- console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理全部缓存'));
108
- clearCommonCaches(buildDir, userProjectDir);
111
+ console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 Gradle 缓存、CMake 缓存与依赖缓存'));
112
+ clearGradleCaches(buildDir, userProjectDir);
109
113
  removeDir(path.join(userProjectDir, 'node_modules', '@flun', 'nodejs-mobile-react-native', 'android', '.cxx'));
114
+ clearDepsCaches(buildDir);
110
115
  }
111
116
  else if (depsChanged || appInfoChanged) {
112
- const reasons = [];
113
- if (depsChanged) reasons.push('用户依赖');
114
- if (appInfoChanged) reasons.push('应用信息');
115
- console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 nodejs-assets 缓存 + app/build'));
116
- clearCommonCaches(buildDir, userProjectDir);
117
+ const reasons = [], targets = [];
118
+ if (depsChanged) reasons.push('用户依赖'), targets.push('依赖缓存', 'Gradle 缓存');
119
+ if (appInfoChanged) reasons.push('应用信息'), targets.push('Gradle 缓存');
120
+ console.log(chalk.yellow(' ⚠️ 检测到变化(' + reasons.join('、') + '),清理 ' + targets.join('、')));
121
+ clearGradleCaches(buildDir, userProjectDir);
122
+ if (depsChanged) clearDepsCaches(buildDir);
117
123
  }
118
124
  else console.log(chalk.gray(' ✓ 缓存有效,跳过清理'));
119
125