@flun/node-mobile-app 3.1.4 → 3.1.5

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,15 +1,18 @@
1
- # 变更日志
2
- ## [3.1.4] - 2026-10-17 11:32
3
- ### 修复
4
- - **修复 `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`、建链接失败即中断;
5
-
6
- ### 变更
7
- - **Android 模板仓库增加阿里云镜像兜底**:`settings.gradle` 的 `pluginManagement.repositories` 与 `build.gradle` 的 `buildscript.repositories` 在 `google()` / `mavenCentral()` 之前插入阿里云镜像(gradle-plugin / google / public),改善国内网络拉取 `react-android`、`hermes-android` 等 AAR 时卡在官方源的问题;镜像在前、官方源在后,海外网络镜像不命中会自动回退官方源,仅多一次往返,不影响功能;不写死镜像为唯一源,镜像故障时仍可由官方源兜住;
8
-
9
- ## [3.1.3] - 2026-10-15 23:10
10
- ### 修复
11
- - **删除 `scripts` 字段的范围扩大**:原仅对被合并的包删除 `package.json` 的 `scripts`;跳过的包(如原生模块、JS 较少的包)仍保留,其安装期脚本会被 Gradle `npm rebuild` 触发,若脚本文件已被清理则报 `Cannot find module`、构建失败;现改为**对所有非原生包删除**(原生模块包保留,其 scripts 是编译必需);
12
-
13
- ## [3.1.2] - 2026-10-15 21:05
14
- ### 修复
15
- - 修复了 "src\optimize-node-modules.js" 中 prunePlatform 函数一些边界问题;
1
+ # 变更日志
2
+ ## [3.1.5] - 2026-10-18 10:04
3
+ ### 修复
4
+ - **修复原生模块编译时 `node-addon-api` 的 gyp / 头文件被误删**:`pruneDevFiles` 原保护条件为 `COMPILE_EXTS && inNativePkg`,而 `node-addon-api` 自身没有 `binding.gyp`、不在原生模块包列表内,其 `node_addon_api.gyp` 与头文件被当作开发文件删除,导致依赖它的原生模块(如 `bcrypt`)在 Gradle `npm rebuild` 时报 `../node-addon-api/node_addon_api.gyp not found`、构建中断;现新增 `isSkippedPkg`,保护条件改为 `COMPILE_EXTS && (inNativePkg || isSkippedPkg)`,仅保留 `SKIP_PKGS` 包内的编译文件(`.gyp`/`.gypi`/`.h`/`.c` 等),`.md`/`.map`/`.ts` 等仍照常清理,不扩大保留范围;
5
+
6
+ ### 变更
7
+ - **阶段 4 不再清理 `.d.ts`**:`.d.ts` 已由阶段 6 的 `TS_RE`(`/\.(ts|cts|mts)$/`)覆盖,阶段 4 重复清理属冗余;移除后 `.d.ts` 统一由阶段 6 处理,清理职责不重叠;
8
+
9
+ ## [3.1.4] - 2026-10-17 11:32
10
+ ### 修复
11
+ - **修复 `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`、建链接失败即中断;
12
+
13
+ ### 变更
14
+ - **Android 模板仓库增加阿里云镜像兜底**:`settings.gradle` 的 `pluginManagement.repositories` 与 `build.gradle` 的 `buildscript.repositories` 在 `google()` / `mavenCentral()` 之前插入阿里云镜像(gradle-plugin / google / public),改善国内网络拉取 `react-android`、`hermes-android` 等 AAR 时卡在官方源的问题;镜像在前、官方源在后,海外网络镜像不命中会自动回退官方源,仅多一次往返,不影响功能;不写死镜像为唯一源,镜像故障时仍可由官方源兜住;
15
+
16
+ ## [3.1.3] - 2026-10-15 23:10
17
+ ### 修复
18
+ - **删除 `scripts` 字段的范围扩大**:原仅对被合并的包删除 `package.json` 的 `scripts`;跳过的包(如原生模块、JS 较少的包)仍保留,其安装期脚本会被 Gradle `npm rebuild` 触发,若脚本文件已被清理则报 `Cannot find module`、构建失败;现改为**对所有非原生包删除**(原生模块包保留,其 scripts 是编译必需);
package/README.md CHANGED
@@ -124,8 +124,9 @@
124
124
  ```json
125
125
  {
126
126
  "allowScripts": {
127
- "@flun/nodejs-mobile-react-native": true,
128
- "@flun/node-mobile-app": true
127
+ "esbuild": true,
128
+ "@flun/node-mobile-app": true,
129
+ "@flun/nodejs-mobile-react-native":true
129
130
  }
130
131
  }
131
132
  ```
@@ -169,7 +170,7 @@ npx node-mobile-app build --release
169
170
  ### 常用选项
170
171
 
171
172
  | 选项 | 用途 |
172
- | --------------- | --------------------------------------------- |
173
+ | --------------- | ---------------------------------------------- |
173
174
  | `--ios` | 目标平台为 iOS(默认 Android) |
174
175
  | `--release` | 打 release 包(仅 `build`) |
175
176
  | `--device <id>` | 指定设备(`test`) |
@@ -343,10 +344,10 @@ signing: {
343
344
 
344
345
  构建时自动优化 `node_modules`(默认开启,无需配置),减少打包文件数与体积、加速启动。
345
346
 
346
- | 字段 | 类型 | 默认 | 说明 |
347
- | --------- | ---------- | ------ | ------------------------------------------------------------- |
348
- | `enabled` | `boolean` | `true` | 是否启用优化 |
349
- | `exclude` | `string[]` | `[]` | 排除优化时异常或不想优化的包(写 `package.json` 的 `name`) |
347
+ | 字段 | 类型 | 默认 | 说明 |
348
+ | --------- | ---------- | ------ | ----------------------------------------------------------- |
349
+ | `enabled` | `boolean` | `true` | 是否启用优化 |
350
+ | `exclude` | `string[]` | `[]` | 排除优化时异常或不想优化的包(写 `package.json` 的 `name`) |
350
351
 
351
352
  **六阶段流程**:
352
353
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flun/node-mobile-app",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "将 Node.js 项目一键打包为 Android / iOS 移动应用,运行时由 @flun/nodejs-mobile-react-native 提供,无需修改你的 Node 代码;",
5
5
  "author": "flun <open@flun.top>",
6
6
  "keywords": [
@@ -15,6 +15,10 @@ const require = createRequire(import.meta.url), subpath = (...parts) => './' + p
15
15
  IOS_ARCHES = ['arm64', 'x64'], INDEX_FILES = ['index.js', 'index.cjs', 'index.mjs'],
16
16
  // ==================== 通用工具 ====================
17
17
  toPosix = p => p.replace(POSIX_RE, '/'),
18
+ isSkippedPkg = rel => {
19
+ const seg = rel.split('/'), name = seg[0].startsWith('@') ? seg[0] + '/' + (seg[1] || '') : seg[0];
20
+ return SKIP_PKGS.has(name) || SKIP_PKGS.has(seg[0]);
21
+ },
18
22
  pickCond = (v, prefer) => {
19
23
  if (typeof v === 'string') return v;
20
24
  if (v && typeof v === 'object') {
@@ -500,7 +504,7 @@ const require = createRequire(import.meta.url), subpath = (...parts) => './' + p
500
504
  /(^|\/)\.editorconfig$/, /(^|\/)\.prettierignore$/, /(^|\/)\.eslintignore$/,
501
505
  /(^|\/)\.dockerignore$/, /(^|\/)\.gitignore$/, /(^|\/)\.gitattributes$/, /(^|\/)\.npmignore$/,
502
506
  /\.(md|markdown)$/i, /\.(gyp|gypi)$/i, /\.(yml|yaml)$/i, /\.(h|c)$/,
503
- /\.d\.ts$/, /\.map$/, /metafile-.*\.json$/,
507
+ /\.map$/, /metafile-.*\.json$/,
504
508
  /(^|\/)\.eslintrc(\.(json|yml|js|cjs))?$/, /(^|\/)\.babelrc(\.(json|js))?$/,
505
509
  /(^|\/)package-lock\.json$/, /(^|\/)\.package-lock\.json$/, /(^|\/)yarn\.lock$/,
506
510
  /(^|\/)package-support\.json$/,
@@ -519,7 +523,7 @@ const require = createRequire(import.meta.url), subpath = (...parts) => './' + p
519
523
  walk(full);
520
524
  } else {
521
525
  const rel = toPosix(path.relative(nmDir, full));
522
- if (PATTERNS.some(re => re.test(rel)) && !(COMPILE_EXTS.test(f.name) && inNativePkg(full)))
526
+ if (PATTERNS.some(re => re.test(rel)) && !(COMPILE_EXTS.test(f.name) && (inNativePkg(full) || isSkippedPkg(rel))))
523
527
  try { fs.unlinkSync(full), deleted++; } catch { }
524
528
  }
525
529
  }
@@ -699,4 +703,4 @@ const SELF_HASH = (() => {
699
703
  } catch { return 'unknown'; }
700
704
  })();
701
705
 
702
- export { clearVerified, markVerified, optimizeNodeModules, SELF_HASH };
706
+ export { clearVerified, markVerified, optimizeNodeModules, SELF_HASH };