babel-preset-expo 0.0.1-canary-20231205-250b31f → 0.0.1-canary-20240109-93608d8
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/README.md +18 -13
- package/build/index.js +4 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# babel-preset-expo
|
|
2
2
|
|
|
3
|
-
This preset extends the default React Native preset (
|
|
3
|
+
This preset extends the default React Native preset (`@react-native/babel-preset`) and adds support for decorators, tree-shaking web packages, and loading font icons with optional native dependencies if they're installed.
|
|
4
4
|
|
|
5
|
-
You can use this preset in any React Native project as a drop-in replacement for
|
|
5
|
+
You can use this preset in any React Native project as a drop-in replacement for `@react-native/babel-preset`. If your project isn't using native font loading or web support then this preset will only add support for decorators with `@babel/plugin-proposal-decorators` - this is mostly used for supporting legacy community libraries.
|
|
6
6
|
|
|
7
7
|
If you start your **web** project with `@expo/webpack-config` or `npx expo start` and your project doesn't contain a `babel.config.js` or a `.babelrc` then it will default to using `babel-preset-expo` for loading.
|
|
8
8
|
|
|
@@ -92,14 +92,10 @@ This can improve the initial load time of your app because evaluating dependenci
|
|
|
92
92
|
|
|
93
93
|
The value of `lazyImports` has a few possible effects:
|
|
94
94
|
|
|
95
|
-
- `null` - [
|
|
96
|
-
|
|
95
|
+
- `null` - [@react-native/babel-preset](https://github.com/facebook/react-native/tree/main/packages/react-native-babel-preset) will handle it. (Learn more about it here: https://github.com/facebook/metro/commit/23e3503dde5f914f3e642ef214f508d0a699851d)
|
|
97
96
|
- `false` - No lazy initialization of any imported module.
|
|
98
|
-
|
|
99
97
|
- `true` - Lazy-init all imported modules except local imports (e.g., `./foo`), certain Expo packages that have side effects, and the two cases mentioned [here](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy).
|
|
100
|
-
|
|
101
98
|
- `Array<string>` - [babel-plugin-transform-modules-commonjs](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy) will handle it.
|
|
102
|
-
|
|
103
99
|
- `(string) => boolean` - [babel-plugin-transform-modules-commonjs](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy) will handle it.
|
|
104
100
|
|
|
105
101
|
If you choose to do this, you can also access the list of Expo packages that have side effects by using `const lazyImportsBlacklist = require('babel-preset-expo/lazy-imports-blacklist');` which returns a `Set`.
|
|
@@ -117,11 +113,20 @@ The value of `lazyImports` has a few possible effects:
|
|
|
117
113
|
|
|
118
114
|
### `disableImportExportTransform`
|
|
119
115
|
|
|
120
|
-
|
|
116
|
+
Pass `true` to disable the transform that converts import/export to `module.exports`. Avoid setting this property directly. If you're using Metro, set `experimentalImportSupport: true` instead to ensure the entire pipeline is configured correctly.
|
|
121
117
|
|
|
122
|
-
|
|
118
|
+
```js
|
|
119
|
+
// metro.config.js
|
|
120
|
+
|
|
121
|
+
config.transformer.getTransformOptions = async () => ({
|
|
122
|
+
transform: {
|
|
123
|
+
// Setting this to `true` will automatically toggle `disableImportExportTransform` in `babel-preset-expo`.
|
|
124
|
+
experimentalImportSupport: true,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
```
|
|
123
128
|
|
|
124
|
-
|
|
129
|
+
If `undefined` (default), this will be set automatically via `caller.supportsStaticESM` which is set by the bundler.
|
|
125
130
|
|
|
126
131
|
```js
|
|
127
132
|
[
|
|
@@ -134,15 +139,15 @@ Enabling this option will allow your project to run with older JavaScript syntax
|
|
|
134
139
|
|
|
135
140
|
### `unstable_transformProfile`
|
|
136
141
|
|
|
137
|
-
Changes the engine preset in
|
|
142
|
+
Changes the engine preset in `@react-native/babel-preset` based on the JavaScript engine that is being targeted. In Expo SDK 50 and greater, this is automatically set based on the [`jsEngine`](https://docs.expo.dev/versions/latest/config/app/#jsengine) option in your `app.json`.
|
|
138
143
|
|
|
139
144
|
### `enableBabelRuntime`
|
|
140
145
|
|
|
141
|
-
Passed to
|
|
146
|
+
Passed to `@react-native/babel-preset`.
|
|
142
147
|
|
|
143
148
|
### `disableFlowStripTypesTransform`
|
|
144
149
|
|
|
145
|
-
Passed to
|
|
150
|
+
Passed to `@react-native/babel-preset`.
|
|
146
151
|
|
|
147
152
|
## Platform-specific options
|
|
148
153
|
|
package/build/index.js
CHANGED
|
@@ -20,6 +20,7 @@ function babelPresetExpo(api, options = {}) {
|
|
|
20
20
|
const isDev = api.caller(common_1.getIsDev);
|
|
21
21
|
const isFastRefreshEnabled = api.caller(common_1.getIsFastRefreshEnabled);
|
|
22
22
|
const baseUrl = api.caller(common_1.getBaseUrl);
|
|
23
|
+
const supportsStaticESM = api.caller((caller) => caller?.supportsStaticESM);
|
|
23
24
|
// Unlike `isDev`, this will be `true` when the bundler is explicitly set to `production`,
|
|
24
25
|
// i.e. `false` when testing, development, or used with a bundler that doesn't specify the correct inputs.
|
|
25
26
|
const isProduction = api.caller(common_1.getIsProd);
|
|
@@ -34,10 +35,10 @@ function babelPresetExpo(api, options = {}) {
|
|
|
34
35
|
if (platform === 'web') {
|
|
35
36
|
// Only disable import/export transform when Webpack is used because
|
|
36
37
|
// Metro does not support tree-shaking.
|
|
37
|
-
platformOptions.disableImportExportTransform = isWebpack;
|
|
38
|
+
platformOptions.disableImportExportTransform = supportsStaticESM ?? isWebpack;
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
platformOptions.disableImportExportTransform = false;
|
|
41
|
+
platformOptions.disableImportExportTransform = supportsStaticESM ?? false;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
if (platformOptions.unstable_transformProfile == null) {
|
|
@@ -52,7 +53,7 @@ function babelPresetExpo(api, options = {}) {
|
|
|
52
53
|
// getters and setters in spread objects. We need to add this plugin ourself without that option.
|
|
53
54
|
// @see https://github.com/expo/expo/pull/11960#issuecomment-887796455
|
|
54
55
|
extraPlugins.push([
|
|
55
|
-
require.resolve('@babel/plugin-
|
|
56
|
+
require.resolve('@babel/plugin-transform-object-rest-spread'),
|
|
56
57
|
{ loose: false },
|
|
57
58
|
]);
|
|
58
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "0.0.1-canary-
|
|
3
|
+
"version": "0.0.1-canary-20240109-93608d8",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/plugin-proposal-decorators": "^7.12.9",
|
|
45
|
-
"@babel/plugin-
|
|
45
|
+
"@babel/plugin-transform-object-rest-spread": "^7.12.13",
|
|
46
46
|
"@babel/plugin-transform-export-namespace-from": "^7.22.11",
|
|
47
47
|
"@babel/preset-env": "^7.20.0",
|
|
48
48
|
"@babel/preset-react": "^7.22.15",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@babel/core": "^7.20.0",
|
|
56
|
-
"expo-module-scripts": "0.0.1-canary-
|
|
56
|
+
"expo-module-scripts": "0.0.1-canary-20240109-93608d8",
|
|
57
57
|
"jest": "^29.2.1"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "93608d8dcb0268312e0c8ed22036ebfa6efe9830"
|
|
60
60
|
}
|