@flun/node-mobile-app 2.0.1 → 2.0.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,4 +1,26 @@
1
1
  # Changelog
2
+
3
+ ## [2.0.3] - 2026-09-25 21:33
4
+
5
+ ### 修复
6
+
7
+ - **`template/metro.config.js` 排除配置更新**:原来的 `blacklistRE` 在 Metro 0.86+ 已完全移除,`metro-config/src/defaults/exclusionList.js` 的深层导入路径在 Metro 0.83 起也不再暴露,会导致新版本 RN 项目加载 Metro 配置失败。改为:
8
+ - `blacklistRE` -> `blockList`
9
+ - 导入路径改为 `metro-config/private/defaults/exclusionList`(不带 `.js` 后缀,经 `.default` 取值)
10
+ - 正则改为 `/[/\\]nodejs-assets[/\\].*/` 形式,避免字符串转义在跨平台下出错
11
+
12
+ ### 更新
13
+ - 更新 `@flun/nodejs-mobile-react-native` 依赖;
14
+
15
+ ---
16
+ ## [2.0.2] - 2026-09-23 20:25
17
+
18
+ ### 修复
19
+
20
+ - **`syncTemplateDependencies` 计数不准确**:`src/copy.js` 里 `_comment` 字段的移除被一并计入 `updated`,导致日志里打印的"已同步 N 个依赖版本"比实际多 1。拆分为 `depsUpdated`(仅统计真正变化的依赖)和 `needWrite`(是否需要写文件),`_comment` 仍会被移除,但不再计入。
21
+
22
+ ---
23
+
2
24
  ## [2.0.1] - 2026-09-23 19:53
3
25
  ### 更新
4
26
  - 升级了有bug的 `@flun/nodejs-mobile-react-native` v1.0.1版本到v1.0.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/node-mobile-app",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "将 Node.js 项目一键打包为 Android / iOS 移动应用,运行时由 @flun/nodejs-mobile-react-native 提供,无需修改你的 Node 代码;",
5
5
  "author": "flun <open@flun.top>",
6
6
  "keywords": [
@@ -62,7 +62,7 @@
62
62
  "eslint-plugin-react": "^7.37.5",
63
63
  "eslint-plugin-react-hooks": "^7.1.1",
64
64
  "eslint-plugin-react-native": "^5.0.0",
65
- "@flun/nodejs-mobile-react-native": "^1.0.3"
65
+ "@flun/nodejs-mobile-react-native": "^2.0.0"
66
66
  },
67
67
  "allowScripts": {
68
68
  "node": true,
package/src/copy.js CHANGED
@@ -73,25 +73,29 @@ const BUILD_DIR_NAME = 'node-mobile-app-build',
73
73
 
74
74
  const mainDeps = mainPkg.dependencies || {};
75
75
  const missing = [];
76
- let updated = 0;
76
+ let depsUpdated = 0;
77
+ let needWrite = false;
77
78
 
78
79
  // 移除仅用于模板占位说明的 _comment 字段,避免带进最终 build 工程
79
80
  if ('_comment' in buildPkg) {
80
81
  delete buildPkg._comment;
81
- updated++;
82
+ needWrite = true;
82
83
  }
83
84
  for (const name of Object.keys(buildPkg.dependencies)) {
84
85
  const v = mainDeps[name];
85
86
  if (!v) { missing.push(name); continue; }
86
87
  if (buildPkg.dependencies[name] !== v) {
87
88
  buildPkg.dependencies[name] = v;
88
- updated++;
89
+ depsUpdated++;
90
+ needWrite = true;
89
91
  }
90
92
  }
91
93
 
92
- if (updated > 0) {
94
+ if (needWrite) {
93
95
  writeIfChanged(buildPkgPath, JSON.stringify(buildPkg, null, 2) + '\n');
94
- console.log(' ✓ 已同步 ' + updated + ' 个依赖版本到 ' + BUILD_DIR_NAME + '/package.json');
96
+ if (depsUpdated > 0) {
97
+ console.log(' ✓ 已同步 ' + depsUpdated + ' 个依赖版本到 ' + BUILD_DIR_NAME + '/package.json');
98
+ }
95
99
  }
96
100
 
97
101
  if (missing.length > 0) {
@@ -1,18 +1,18 @@
1
1
  import { getDefaultConfig, mergeConfig } from '@react-native/metro-config';
2
+ import exclusionListModule from 'metro-config/private/defaults/exclusionList';
2
3
  import { dirname, resolve } from 'path';
3
4
  import { fileURLToPath } from 'url';
4
5
 
6
+ const exclusionList = exclusionListModule.default;
5
7
  const __filename = fileURLToPath(import.meta.url), __dirname = dirname(__filename), workspaceRoot = resolve(__dirname, '..'),
6
- /**
7
- * Metro 配置
8
- * RN 工程位于 <userProject>/node-mobile-app-build/
9
- * 依赖装在 <userProject>/node_modules/(上一级)
10
- *
11
- * watchFolders 只监听必要位置,避免递归整个用户项目(性能灾难)
12
- */
13
8
  config = {
14
9
  watchFolders: [__dirname, resolve(workspaceRoot, 'node_modules')],
15
- resolver: { nodeModulesPaths: [resolve(__dirname, 'node_modules'), resolve(workspaceRoot, 'node_modules')] }
10
+ resolver: {
11
+ nodeModulesPaths: [resolve(__dirname, 'node_modules'), resolve(workspaceRoot, 'node_modules')],
12
+ blockList: exclusionList([
13
+ /[/\\]nodejs-assets[/\\].*/,
14
+ ]),
15
+ }
16
16
  };
17
17
 
18
18
  export default mergeConfig(getDefaultConfig(__dirname), config);
@@ -416,8 +416,8 @@ x86_64 在 x64 主机上**无交叉编译问题**,与 arm64 流程一致。`an
416
416
  | `number 116 is not a function` | `libnode.so` 无 full-icu | 重新用 `--with-intl=full-icu` 编译,或回退 Express 4 |
417
417
  | `\p{...}` 正则报错 | 同上 | 同上 |
418
418
  | `No "exports" main defined` | 用了 `@alloc/path-to-regexp` | 撤销 `overrides`,清 `node_modules` + `package-lock.json` 重装 |
419
- | `Cannot find module 'rn-bridge'` | Node 20+ 不再把链接绑定暴露给 `require()` | 需修改 Node.js `lib/internal/modules/cjs/loader.js`,从 `NODE_PATH` 加载 `rn-bridge` 的 JS 包装 |
420
- | `require('rn-bridge')` 返回原生绑定 | `loader.js` 补丁未生效 | 确认 `rn-bridge.cpp` 保持 `NODE_MODULE_LINKED` 注册宏 |
419
+ | `Cannot find module 'rn-bridge'` | Node 20+ 不再把链接绑定暴露给 `require()` | 需修改 Node.js `lib/internal/modules/cjs/loader.js`,从 `NODE_PATH` 按目录加载 `rn-bridge`(入口由该目录 `package.json` 的 `main` 决定) |
420
+ | 启动即崩:`pthread_mutex_lock called on a destroyed mutex` + `Fatal signal 6 (SIGABRT)`;`require('rn-bridge')` 返回的对象无 `channel` 属性 | v22 loader 补丁按 `rn-bridge/index.js` 硬编码定位,而插件入口因 `type: module` 已改名(如 `index.cjs`),匹配失败 → Node 回退到 `process._linkedBinding('rn_bridge')` 拿裸 binding | 使用按**目录** `rn-bridge` 定位的 loader 补丁(入口由该目录 `package.json` 的 `main` 字段解析) |
421
421
  | JNI 编译报 `undefined symbol: v8::Exception::Error` | 插件旧头文件(v18 时代)与 v22 `libnode.so` ABI 不匹配 | **用 `android-libnode.zip` 整目录替换**,其 `include/node/` 是 v22 官方 headers |
422
422
  | `NODE_MODULE_VERSION` 不匹配 | 原生模块未重编 | `NODE_MOBILE_FORCE_REBUILD=1` 后重跑 CLI |
423
423
  | Windows 下 `Unsupported operating system for nodejs-mobile native builds` | 插件硬编码只支持 macOS/Linux | 官方 v22 产物已含 Windows 支持(`windows-x86_64` + `host_os=win32`) |