miaoda-expo-devkit 0.1.1-beta.72 → 0.1.1-beta.74

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.
@@ -37,6 +37,8 @@ interface JsxSourcePluginOptions {
37
37
  rootDir?: string;
38
38
  /** 需要跳过注入的路径模式列表(相对于 rootDir 的路径片段) */
39
39
  excludePaths?: string[];
40
+ /** 需要跳过注入的包名列表,从这些包导入的组件不会被注入 */
41
+ excludePackages?: string[];
40
42
  }
41
43
  /**
42
44
  * Babel 插件:为 JSX 元素注入 dataSet
@@ -23,6 +23,7 @@ __export(plugin_jsx_source_exports, {
23
23
  default: () => babelPluginJsxSource
24
24
  });
25
25
  module.exports = __toCommonJS(plugin_jsx_source_exports);
26
+ var DEFAULT_EXCLUDE_PACKAGES = ["react-native-gifted-charts"];
26
27
  var DATASET_PROP_NAME = "dataSet";
27
28
  var MD_ID_KEY = "mdId";
28
29
  var MD_CONTENT_KEY = "componentContent";
@@ -103,15 +104,34 @@ function shouldSkipElement(t, name) {
103
104
  function babelPluginJsxSource({
104
105
  types: t
105
106
  }) {
107
+ let excludedIdentifiers;
106
108
  return {
107
109
  name: "babel-plugin-jsx-source",
108
110
  visitor: {
111
+ Program(_path, state) {
112
+ excludedIdentifiers = /* @__PURE__ */ new Set();
113
+ const excludePackages = [
114
+ ...DEFAULT_EXCLUDE_PACKAGES,
115
+ ...state.opts.excludePackages || []
116
+ ];
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 + "/"))) {
120
+ for (const specifier of node.specifiers) {
121
+ excludedIdentifiers.add(specifier.local.name);
122
+ }
123
+ }
124
+ }
125
+ },
109
126
  JSXOpeningElement(path, state) {
110
127
  const { opts, filename } = state;
111
128
  if (!filename) return;
112
129
  if (filename.includes("node_modules")) return;
113
130
  if (opts.excludePaths?.some((p) => filename.includes(p))) return;
114
131
  if (shouldSkipElement(t, path.node.name)) return;
132
+ 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;
115
135
  const loc = path.node.loc;
116
136
  if (!loc) return;
117
137
  let filePath = filename;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-expo-devkit",
3
- "version": "0.1.1-beta.72",
3
+ "version": "0.1.1-beta.74",
4
4
  "description": "Expo 应用开发工具集:Sentry DSN 替换 stub、错误/网络捕获、Metro 符号化",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",