miaoda-expo-devkit 0.1.1-beta.75 → 0.1.1-beta.77

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.
@@ -1,4 +1,4 @@
1
- import { types, PluginObj } from '@babel/core';
1
+ import { types, PluginObj, PluginPass } from '@babel/core';
2
2
 
3
3
  /**
4
4
  * babel-plugin-jsx-source
@@ -40,11 +40,16 @@ interface JsxSourcePluginOptions {
40
40
  /** 需要跳过注入的包名列表,从这些包导入的组件不会被注入 */
41
41
  excludePackages?: string[];
42
42
  }
43
+ interface PluginState extends PluginPass {
44
+ opts: JsxSourcePluginOptions;
45
+ /** 当前文件中来自被排除包的本地标识符集合,Program 阶段初始化 */
46
+ excludedComponents: Set<string>;
47
+ }
43
48
  /**
44
49
  * Babel 插件:为 JSX 元素注入 dataSet
45
50
  */
46
51
  declare function babelPluginJsxSource({ types: t, }: {
47
52
  types: typeof types;
48
- }): PluginObj;
53
+ }): PluginObj<PluginState>;
49
54
 
50
55
  export { type JsxSourcePluginOptions, babelPluginJsxSource as default };
@@ -104,24 +104,25 @@ function shouldSkipElement(t, name) {
104
104
  function babelPluginJsxSource({
105
105
  types: t
106
106
  }) {
107
- let excludedIdentifiers;
108
107
  return {
109
108
  name: "babel-plugin-jsx-source",
110
109
  visitor: {
111
110
  Program(_path, state) {
112
- excludedIdentifiers = /* @__PURE__ */ new Set();
113
111
  const excludePackages = [
114
112
  ...DEFAULT_EXCLUDE_PACKAGES,
115
- ...state.opts.excludePackages || []
113
+ ...state.opts.excludePackages ?? []
116
114
  ];
117
- const programBody = _path.node.body;
118
- for (const node of programBody) {
119
- if (t.isImportDeclaration(node) && excludePackages.some((pkg) => node.source.value === pkg || node.source.value.startsWith(pkg + "/"))) {
115
+ const excluded = /* @__PURE__ */ new Set();
116
+ for (const node of _path.node.body) {
117
+ if (t.isImportDeclaration(node) && excludePackages.some(
118
+ (pkg) => node.source.value === pkg || node.source.value.startsWith(pkg + "/")
119
+ )) {
120
120
  for (const specifier of node.specifiers) {
121
- excludedIdentifiers.add(specifier.local.name);
121
+ excluded.add(specifier.local.name);
122
122
  }
123
123
  }
124
124
  }
125
+ state.excludedComponents = excluded;
125
126
  },
126
127
  JSXOpeningElement(path, state) {
127
128
  const { opts, filename } = state;
@@ -130,8 +131,8 @@ function babelPluginJsxSource({
130
131
  if (opts.excludePaths?.some((p) => filename.includes(p))) return;
131
132
  if (shouldSkipElement(t, path.node.name)) return;
132
133
  const elementName = path.node.name;
133
- if (t.isJSXIdentifier(elementName) && excludedIdentifiers.has(elementName.name)) return;
134
- if (t.isJSXMemberExpression(elementName) && t.isJSXIdentifier(elementName.object) && excludedIdentifiers.has(elementName.object.name)) return;
134
+ if (t.isJSXIdentifier(elementName) && state.excludedComponents.has(elementName.name)) return;
135
+ if (t.isJSXMemberExpression(elementName) && t.isJSXIdentifier(elementName.object) && state.excludedComponents.has(elementName.object.name)) return;
135
136
  const loc = path.node.loc;
136
137
  if (!loc) return;
137
138
  let filePath = filename;
@@ -42,8 +42,8 @@ function presetExpoDevkit(api, options = {}) {
42
42
  presets: [
43
43
  ["babel-preset-expo", {
44
44
  jsxImportSource: "nativewind",
45
- // web 上禁止自动注入,避免下方手动注入后跑两遍
46
- ...isWeb && { worklets: false }
45
+ // 全平台禁止自动注入,由下方手动注入统一管理
46
+ worklets: false
47
47
  }],
48
48
  "nativewind/babel"
49
49
  ],
@@ -52,7 +52,9 @@ function presetExpoDevkit(api, options = {}) {
52
52
  ...lucide !== false ? [[require.resolve("./plugin-lucide-react-native"), lucide]] : [],
53
53
  // jsx-source 仅开发环境注入,生产无需调试元数据
54
54
  ...isDev ? [[require.resolve("./plugin-jsx-source"), { rootDir, excludePaths }]] : [],
55
- // web 平台手动注入 worklets plugin,跳过 native 专属数据
55
+ // native:标准注入
56
+ ...!isWeb ? [[workletsPlugin]] : [],
57
+ // web:跳过 native 专属的 __initData 字符串化,减少 transform 开销
56
58
  ...isWeb ? [[workletsPlugin, { omitNativeOnlyData: true, substituteWebPlatformChecks: true }]] : []
57
59
  ]
58
60
  };
package/dist/metro.js CHANGED
@@ -616,16 +616,14 @@ function withPersistentCache(config, options = {}) {
616
616
  return {
617
617
  ...config,
618
618
  // transform cache:JS/TS 编译结果
619
- cacheStores: [new StoreClass({ root: cacheRoot })],
620
- // FileMap cache:文件系统索引快照 + Watchman clock
621
- // transform cache 放同一目录,文件名由 Metro 按 projectRoot+config hash 自动区分
622
- fileMapCacheDirectory: cacheRoot,
623
- watcher: {
624
- ...config.watcher,
625
- // 运行时文件变化后自动将 FileMap cache 写回磁盘(debounce 5s)
626
- // 保证进程意外退出后下次启动仍能命中缓存
627
- unstable_autoSaveCache: { enabled: true }
628
- }
619
+ cacheStores: [new StoreClass({ root: cacheRoot })]
620
+ // FileMap cache 暂时禁用:pnpm install 每次重建 symlink 导致 30839 fake changes,
621
+ // 加载旧缓存反而比冷启动更慢,触发 120s 超时。
622
+ // fileMapCacheDirectory: cacheRoot,
623
+ // watcher: {
624
+ // ...config.watcher,
625
+ // unstable_autoSaveCache: { enabled: true },
626
+ // },
629
627
  };
630
628
  }
631
629
 
package/dist/metro.mjs CHANGED
@@ -567,16 +567,14 @@ function withPersistentCache(config, options = {}) {
567
567
  return {
568
568
  ...config,
569
569
  // transform cache:JS/TS 编译结果
570
- cacheStores: [new StoreClass({ root: cacheRoot })],
571
- // FileMap cache:文件系统索引快照 + Watchman clock
572
- // transform cache 放同一目录,文件名由 Metro 按 projectRoot+config hash 自动区分
573
- fileMapCacheDirectory: cacheRoot,
574
- watcher: {
575
- ...config.watcher,
576
- // 运行时文件变化后自动将 FileMap cache 写回磁盘(debounce 5s)
577
- // 保证进程意外退出后下次启动仍能命中缓存
578
- unstable_autoSaveCache: { enabled: true }
579
- }
570
+ cacheStores: [new StoreClass({ root: cacheRoot })]
571
+ // FileMap cache 暂时禁用:pnpm install 每次重建 symlink 导致 30839 fake changes,
572
+ // 加载旧缓存反而比冷启动更慢,触发 120s 超时。
573
+ // fileMapCacheDirectory: cacheRoot,
574
+ // watcher: {
575
+ // ...config.watcher,
576
+ // unstable_autoSaveCache: { enabled: true },
577
+ // },
580
578
  };
581
579
  }
582
580
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.75",
3
+ "version": "0.1.1-beta.77",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",