babel-plugin-react-native-direct-imports 1.1.0 → 1.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ # babel-plugin-react-native-direct-imports
2
+
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`cc962c5`](https://github.com/retyui/babel-plugin-react-native-direct-imports/commit/cc962c50b402247d6fce371fe1a8afc2dd429ca3) Thanks [@retyui](https://github.com/retyui)! - Publish via npm trusted publishing with provenance
package/README.md CHANGED
@@ -6,6 +6,11 @@
6
6
 
7
7
  Babel plugin that replaces `react-native` imports with direct requires of the underlying modules, so only what you use ends up in the bundle.
8
8
 
9
+ > [!WARNING]
10
+ > This plugin is in an early stage. Expect rough edges and breaking changes, and please [report issues](https://github.com/retyui/babel-plugin-react-native-direct-imports/issues) if you run into any.
11
+
12
+ ![How the plugin works](./assets/how-it-works.png)
13
+
9
14
  ```js
10
15
  import { View, AppRegistry, Systrace } from 'react-native';
11
16
 
@@ -24,6 +29,8 @@ Bundle with only `import { ReactNativeVersion } from 'react-native'`, before and
24
29
 
25
30
  ![Bundle before and after the plugin](./assets/before-after.png)
26
31
 
32
+ To measure your own bundle, use [react-native-bundle-discovery](https://github.com/retyui/react-native-bundle-discovery).
33
+
27
34
  ### Why `require()` and not `import`?
28
35
 
29
36
  React Native's modules are CommonJS. If the plugin emitted `import View from '...'`, Babel's CommonJS transform would wrap every one in `_interopRequireDefault()` / `_interopRequireWildcard()` and add those helpers to each file. A plain `require(...).default` gives the same value without the extra code.
@@ -69,13 +76,13 @@ Then reset the Metro cache once (`npx react-native start --reset-cache` or `npx
69
76
  ## Compatibility
70
77
 
71
78
  - ✅ [Uniwind](https://github.com/uni-stack/uniwind): `withUniwindConfig` also redirects deep `react-native/Libraries/...` imports of the components it styles, so `className` keeps working.
72
- - ❌ `react-native-worklets` bundle mode: `getBundleModeMetroConfig` resolves `react-native` to its own [shim](https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-worklets/bundleMode/shims/reactNativeShim.js), which sets up the worklet runtime. The deep paths skip it, so don't combine them.
79
+ - ⚠️ `react-native-worklets` bundle mode: before `0.14.0`, `getBundleModeMetroConfig` resolves `react-native` to its own [shim](https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-worklets/bundleMode/shims/reactNativeShim.js), which sets up the worklet runtime. The deep paths skip it, so don't combine them on `react-native-worklets` < `0.14.0`; upgrade to `0.14.0` or newer.
73
80
 
74
81
  ## Generating maps (development)
75
82
 
76
83
  ```bash
77
84
  yarn generate-maps # all versions
78
- yarn generate-maps 0.87.1 # specific versions
85
+ yarn generate-maps 0.88.0 # specific versions
79
86
  ```
80
87
 
81
88
  ## License
@@ -0,0 +1,390 @@
1
+ {
2
+ "ActivityIndicator": [
3
+ "Libraries/Components/ActivityIndicator/ActivityIndicator",
4
+ "default"
5
+ ],
6
+ "Button": [
7
+ "Libraries/Components/Button",
8
+ "default"
9
+ ],
10
+ "DrawerLayoutAndroid": [
11
+ "Libraries/Components/DrawerAndroid/DrawerLayoutAndroid",
12
+ "default"
13
+ ],
14
+ "EventEmitter": [
15
+ "Libraries/vendor/emitter/EventEmitter",
16
+ "default"
17
+ ],
18
+ "FlatList": [
19
+ "Libraries/Lists/FlatList",
20
+ "default"
21
+ ],
22
+ "Image": [
23
+ "Libraries/Image/Image",
24
+ "default"
25
+ ],
26
+ "ImageBackground": [
27
+ "Libraries/Image/ImageBackground",
28
+ "default"
29
+ ],
30
+ "InputAccessoryView": [
31
+ "Libraries/Components/TextInput/InputAccessoryView",
32
+ "default"
33
+ ],
34
+ "KeyboardAvoidingView": [
35
+ "Libraries/Components/Keyboard/KeyboardAvoidingView",
36
+ "default"
37
+ ],
38
+ "experimental_LayoutConformance": [
39
+ "Libraries/Components/LayoutConformance/LayoutConformance",
40
+ "default"
41
+ ],
42
+ "Modal": [
43
+ "Libraries/Modal/Modal",
44
+ "default"
45
+ ],
46
+ "unstable_NativeText": [
47
+ "Libraries/Text/TextNativeComponent",
48
+ "NativeText"
49
+ ],
50
+ "unstable_NativeView": [
51
+ "Libraries/Components/View/ViewNativeComponent",
52
+ "default"
53
+ ],
54
+ "Pressable": [
55
+ "Libraries/Components/Pressable/Pressable",
56
+ "default"
57
+ ],
58
+ "ProgressBarAndroid": [
59
+ "Libraries/Components/ProgressBarAndroid/ProgressBarAndroid",
60
+ "default"
61
+ ],
62
+ "RefreshControl": [
63
+ "Libraries/Components/RefreshControl/RefreshControl",
64
+ "default"
65
+ ],
66
+ "SafeAreaView": [
67
+ "Libraries/Components/SafeAreaView/SafeAreaView",
68
+ "default"
69
+ ],
70
+ "ScrollView": [
71
+ "Libraries/Components/ScrollView/ScrollView",
72
+ "default"
73
+ ],
74
+ "SectionList": [
75
+ "Libraries/Lists/SectionList",
76
+ "default"
77
+ ],
78
+ "StatusBar": [
79
+ "Libraries/Components/StatusBar/StatusBar",
80
+ "default"
81
+ ],
82
+ "Switch": [
83
+ "Libraries/Components/Switch/Switch",
84
+ "default"
85
+ ],
86
+ "Text": [
87
+ "Libraries/Text/Text",
88
+ "default"
89
+ ],
90
+ "unstable_TextAncestorContext": [
91
+ "Libraries/Text/TextAncestorContext",
92
+ "default"
93
+ ],
94
+ "TextInput": [
95
+ "Libraries/Components/TextInput/TextInput",
96
+ "default"
97
+ ],
98
+ "TouchableHighlight": [
99
+ "Libraries/Components/Touchable/TouchableHighlight",
100
+ "default"
101
+ ],
102
+ "TouchableNativeFeedback": [
103
+ "Libraries/Components/Touchable/TouchableNativeFeedback",
104
+ "default"
105
+ ],
106
+ "TouchableOpacity": [
107
+ "Libraries/Components/Touchable/TouchableOpacity",
108
+ "default"
109
+ ],
110
+ "TouchableWithoutFeedback": [
111
+ "Libraries/Components/Touchable/TouchableWithoutFeedback",
112
+ "default"
113
+ ],
114
+ "View": [
115
+ "Libraries/Components/View/View",
116
+ "default"
117
+ ],
118
+ "VirtualizedList": [
119
+ "Libraries/Lists/VirtualizedList",
120
+ "default"
121
+ ],
122
+ "VirtualizedSectionList": [
123
+ "Libraries/Lists/VirtualizedSectionList",
124
+ "default"
125
+ ],
126
+ "unstable_VirtualView": [
127
+ "src/private/components/virtualview/VirtualView",
128
+ "default"
129
+ ],
130
+ "unstable_VirtualArray": [
131
+ "src/private/components/virtualcollection/Virtual",
132
+ "VirtualArray"
133
+ ],
134
+ "unstable_createVirtualCollectionView": [
135
+ "src/private/components/virtualcollection/VirtualCollectionView",
136
+ "createVirtualCollectionView"
137
+ ],
138
+ "unstable_VirtualColumn": [
139
+ "src/private/components/virtualcollection/column/VirtualColumn",
140
+ "default"
141
+ ],
142
+ "unstable_VirtualColumnGenerator": [
143
+ "src/private/components/virtualcollection/column/VirtualColumnGenerator",
144
+ "default"
145
+ ],
146
+ "unstable_VirtualRow": [
147
+ "src/private/components/virtualcollection/row/VirtualRow",
148
+ "default"
149
+ ],
150
+ "unstable_getScrollParent": [
151
+ "src/private/components/virtualcollection/dom/getScrollParent",
152
+ "default"
153
+ ],
154
+ "unstable_DEFAULT_INITIAL_NUM_TO_RENDER": [
155
+ "src/private/components/virtualcollection/FlingConstants",
156
+ "DEFAULT_INITIAL_NUM_TO_RENDER"
157
+ ],
158
+ "AccessibilityInfo": [
159
+ "Libraries/Components/AccessibilityInfo/AccessibilityInfo",
160
+ "default"
161
+ ],
162
+ "ActionSheetIOS": [
163
+ "Libraries/ActionSheetIOS/ActionSheetIOS",
164
+ "default"
165
+ ],
166
+ "Alert": [
167
+ "Libraries/Alert/Alert",
168
+ "default"
169
+ ],
170
+ "Animated": [
171
+ "Libraries/Animated/Animated",
172
+ "default"
173
+ ],
174
+ "Appearance": [
175
+ "Libraries/Utilities/Appearance",
176
+ "*"
177
+ ],
178
+ "AppRegistry": [
179
+ "Libraries/ReactNative/AppRegistry",
180
+ "AppRegistry"
181
+ ],
182
+ "AppState": [
183
+ "Libraries/AppState/AppState",
184
+ "default"
185
+ ],
186
+ "AssetRegistry": [
187
+ "src/private/assets/AssetRegistry",
188
+ "AssetRegistry"
189
+ ],
190
+ "BackHandler": [
191
+ "Libraries/Utilities/BackHandler",
192
+ "default"
193
+ ],
194
+ "Clipboard": [
195
+ "Libraries/Components/Clipboard/Clipboard",
196
+ "default"
197
+ ],
198
+ "codegenNativeCommands": [
199
+ "Libraries/Utilities/codegenNativeCommands",
200
+ "default"
201
+ ],
202
+ "codegenNativeComponent": [
203
+ "Libraries/Utilities/codegenNativeComponent",
204
+ "default"
205
+ ],
206
+ "DeviceEventEmitter": [
207
+ "Libraries/EventEmitter/RCTDeviceEventEmitter",
208
+ "default"
209
+ ],
210
+ "DeviceInfo": [
211
+ "Libraries/Utilities/DeviceInfo",
212
+ "default"
213
+ ],
214
+ "DevMenu": [
215
+ "src/private/devsupport/devmenu/DevMenu",
216
+ "default"
217
+ ],
218
+ "DevSettings": [
219
+ "Libraries/Utilities/DevSettings",
220
+ "default"
221
+ ],
222
+ "Dimensions": [
223
+ "Libraries/Utilities/Dimensions",
224
+ "default"
225
+ ],
226
+ "DynamicColorIOS": [
227
+ "Libraries/StyleSheet/PlatformColorValueTypesIOS",
228
+ "DynamicColorIOS"
229
+ ],
230
+ "Easing": [
231
+ "Libraries/Animated/Easing",
232
+ "default"
233
+ ],
234
+ "findNodeHandle": [
235
+ "Libraries/ReactNative/RendererProxy",
236
+ "findNodeHandle"
237
+ ],
238
+ "I18nManager": [
239
+ "Libraries/ReactNative/I18nManager",
240
+ "default"
241
+ ],
242
+ "Keyboard": [
243
+ "Libraries/Components/Keyboard/Keyboard",
244
+ "default"
245
+ ],
246
+ "LayoutAnimation": [
247
+ "Libraries/LayoutAnimation/LayoutAnimation",
248
+ "default"
249
+ ],
250
+ "Linking": [
251
+ "Libraries/Linking/Linking",
252
+ "default"
253
+ ],
254
+ "LogBox": [
255
+ "Libraries/LogBox/LogBox",
256
+ "default"
257
+ ],
258
+ "NativeAppEventEmitter": [
259
+ "Libraries/EventEmitter/RCTNativeAppEventEmitter",
260
+ "default"
261
+ ],
262
+ "NativeComponentRegistry": [
263
+ "Libraries/NativeComponent/NativeComponentRegistry",
264
+ "*"
265
+ ],
266
+ "NativeEventEmitter": [
267
+ "Libraries/EventEmitter/NativeEventEmitter",
268
+ "default"
269
+ ],
270
+ "NativeModules": [
271
+ "Libraries/BatchedBridge/NativeModules",
272
+ "default"
273
+ ],
274
+ "Networking": [
275
+ "Libraries/Network/RCTNetworking",
276
+ "default"
277
+ ],
278
+ "PanResponder": [
279
+ "Libraries/Interaction/PanResponder",
280
+ "default"
281
+ ],
282
+ "PermissionsAndroid": [
283
+ "Libraries/PermissionsAndroid/PermissionsAndroid",
284
+ "default"
285
+ ],
286
+ "PixelRatio": [
287
+ "Libraries/Utilities/PixelRatio",
288
+ "default"
289
+ ],
290
+ "Platform": [
291
+ "Libraries/Utilities/Platform",
292
+ "default"
293
+ ],
294
+ "PlatformColor": [
295
+ "Libraries/StyleSheet/PlatformColorValueTypes",
296
+ "PlatformColor"
297
+ ],
298
+ "PushNotificationIOS": [
299
+ "Libraries/PushNotificationIOS/PushNotificationIOS",
300
+ "default"
301
+ ],
302
+ "processColor": [
303
+ "Libraries/StyleSheet/processColor",
304
+ "default"
305
+ ],
306
+ "registerCallableModule": [
307
+ "Libraries/Core/registerCallableModule",
308
+ "default"
309
+ ],
310
+ "requireNativeComponent": [
311
+ "Libraries/ReactNative/requireNativeComponent",
312
+ "default"
313
+ ],
314
+ "ReactNativeVersion": [
315
+ "Libraries/Core/ReactNativeVersion",
316
+ "default"
317
+ ],
318
+ "RootTagContext": [
319
+ "Libraries/ReactNative/RootTag",
320
+ "RootTagContext"
321
+ ],
322
+ "Settings": [
323
+ "Libraries/Settings/Settings",
324
+ "default"
325
+ ],
326
+ "Share": [
327
+ "Libraries/Share/Share",
328
+ "default"
329
+ ],
330
+ "StyleSheet": [
331
+ "Libraries/StyleSheet/StyleSheet",
332
+ "default"
333
+ ],
334
+ "Systrace": [
335
+ "Libraries/Performance/Systrace",
336
+ "*"
337
+ ],
338
+ "ToastAndroid": [
339
+ "Libraries/Components/ToastAndroid/ToastAndroid",
340
+ "default"
341
+ ],
342
+ "TurboModuleRegistry": [
343
+ "Libraries/TurboModule/TurboModuleRegistry",
344
+ "*"
345
+ ],
346
+ "UIManager": [
347
+ "Libraries/ReactNative/UIManager",
348
+ "default"
349
+ ],
350
+ "useAnimatedValue": [
351
+ "Libraries/Animated/useAnimatedValue",
352
+ "default"
353
+ ],
354
+ "useAnimatedValueXY": [
355
+ "Libraries/Animated/useAnimatedValueXY",
356
+ "default"
357
+ ],
358
+ "useAnimatedColor": [
359
+ "Libraries/Animated/useAnimatedColor",
360
+ "default"
361
+ ],
362
+ "useColorScheme": [
363
+ "Libraries/Utilities/useColorScheme",
364
+ "default"
365
+ ],
366
+ "usePressability": [
367
+ "Libraries/Pressability/usePressability",
368
+ "default"
369
+ ],
370
+ "useWindowDimensions": [
371
+ "Libraries/Utilities/useWindowDimensions",
372
+ "default"
373
+ ],
374
+ "UTFSequence": [
375
+ "Libraries/UTFSequence",
376
+ "default"
377
+ ],
378
+ "Vibration": [
379
+ "Libraries/Vibration/Vibration",
380
+ "default"
381
+ ],
382
+ "VirtualViewMode": [
383
+ "src/private/components/virtualview/VirtualView",
384
+ "VirtualViewMode"
385
+ ],
386
+ "Touchable": [
387
+ "Libraries/Components/Touchable/Touchable",
388
+ "default"
389
+ ]
390
+ }
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "babel-plugin-react-native-direct-imports",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Babel plugin that rewrites `react-native` barrel imports into direct module imports",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/retyui/babel-plugin-react-native-direct-imports.git"
8
+ },
5
9
  "main": "index.js",
6
10
  "files": [
7
11
  "index.js",
@@ -9,7 +13,10 @@
9
13
  ],
10
14
  "scripts": {
11
15
  "test": "node --test",
12
- "generate-maps": "node scripts/generate-maps.js"
16
+ "generate-maps": "node scripts/generate-maps.js",
17
+ "changeset": "changeset",
18
+ "version-packages": "changeset version && yarn install --mode=update-lockfile",
19
+ "release": "changeset publish"
13
20
  },
14
21
  "keywords": [
15
22
  "babel",
@@ -34,8 +41,13 @@
34
41
  "devDependencies": {
35
42
  "@babel/core": "^7.26.10",
36
43
  "@babel/plugin-transform-modules-commonjs": "^8.0.1",
44
+ "@changesets/changelog-github": "^1.0.1",
45
+ "@changesets/cli": "^3.0.3",
37
46
  "hermes-parser": "^0.37.0"
38
47
  },
39
48
  "license": "MIT",
40
- "packageManager": "yarn@4.18.1"
41
- }
49
+ "packageManager": "yarn@4.18.1",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }