babel-preset-expo 11.0.9 → 11.0.10
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 +0 -18
- package/build/common.d.ts +13 -14
- package/build/common.js +1 -19
- package/build/expo-router-plugin.js +1 -1
- package/build/index.d.ts +0 -47
- package/build/index.js +0 -26
- package/package.json +3 -5
- package/react-compiler-runtime.js +0 -21
package/README.md
CHANGED
|
@@ -42,24 +42,6 @@ If the `bundler` is not defined, it will default to checking if a `babel-loader`
|
|
|
42
42
|
|
|
43
43
|
## Options
|
|
44
44
|
|
|
45
|
-
### `react-compiler`
|
|
46
|
-
|
|
47
|
-
Settings to pass to `babel-plugin-react-compiler`. Set as `false` to disable the plugin. As of SDK 51, you must also enable `experiments.reactCompiler: true` in the `app.json`.
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
[
|
|
51
|
-
'babel-preset-expo',
|
|
52
|
-
{
|
|
53
|
-
'react-compiler': {
|
|
54
|
-
sources: (filename) => {
|
|
55
|
-
// Match file names to include in the React Compiler.
|
|
56
|
-
return filename.includes('src/path/to/dir');
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
```
|
|
62
|
-
|
|
63
45
|
### `minifyTypeofWindow`
|
|
64
46
|
|
|
65
47
|
Set `minifyTypeofWindow: false` to preserve the `typeof window` check in your code, e.g. `if (typeof window === 'undefined')` -> `if (true)` in servers. This is useful when you're using libraries that mock the window object on native or in the server.
|
package/build/common.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export declare function hasModule(name: string): boolean;
|
|
2
2
|
/** Determine which bundler is being used. */
|
|
3
|
-
export declare function getBundler(caller
|
|
4
|
-
export declare function getPlatform(caller
|
|
5
|
-
export declare function getPossibleProjectRoot(caller
|
|
3
|
+
export declare function getBundler(caller: any): any;
|
|
4
|
+
export declare function getPlatform(caller: any): any;
|
|
5
|
+
export declare function getPossibleProjectRoot(caller: any): any;
|
|
6
6
|
/** If bundling for a react-server target. */
|
|
7
|
-
export declare function getIsReactServer(caller
|
|
8
|
-
export declare function getIsDev(caller
|
|
9
|
-
export declare function getIsFastRefreshEnabled(caller
|
|
10
|
-
export declare function getIsProd(caller
|
|
11
|
-
export declare function getIsNodeModule(caller
|
|
12
|
-
export declare function getBaseUrl(caller
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function getAsyncRoutes(caller?: any): boolean;
|
|
7
|
+
export declare function getIsReactServer(caller: any): boolean;
|
|
8
|
+
export declare function getIsDev(caller: any): any;
|
|
9
|
+
export declare function getIsFastRefreshEnabled(caller: any): any;
|
|
10
|
+
export declare function getIsProd(caller: any): boolean;
|
|
11
|
+
export declare function getIsNodeModule(caller: any): boolean;
|
|
12
|
+
export declare function getBaseUrl(caller: any): string;
|
|
13
|
+
export declare function getIsServer(caller: any): any;
|
|
14
|
+
export declare function getExpoRouterAbsoluteAppRoot(caller: any): string;
|
|
15
|
+
export declare function getInlineEnvVarsEnabled(caller: any): boolean;
|
|
16
|
+
export declare function getAsyncRoutes(caller: any): boolean;
|
package/build/common.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAsyncRoutes = exports.getInlineEnvVarsEnabled = exports.getExpoRouterAbsoluteAppRoot = exports.getIsServer = exports.
|
|
6
|
+
exports.getAsyncRoutes = exports.getInlineEnvVarsEnabled = exports.getExpoRouterAbsoluteAppRoot = exports.getIsServer = exports.getBaseUrl = exports.getIsNodeModule = exports.getIsProd = exports.getIsFastRefreshEnabled = exports.getIsDev = exports.getIsReactServer = exports.getPossibleProjectRoot = exports.getPlatform = exports.getBundler = exports.hasModule = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
function hasModule(name) {
|
|
9
9
|
try {
|
|
@@ -19,7 +19,6 @@ function hasModule(name) {
|
|
|
19
19
|
exports.hasModule = hasModule;
|
|
20
20
|
/** Determine which bundler is being used. */
|
|
21
21
|
function getBundler(caller) {
|
|
22
|
-
assertExpoBabelCaller(caller);
|
|
23
22
|
if (!caller)
|
|
24
23
|
return null;
|
|
25
24
|
if (caller.bundler)
|
|
@@ -36,7 +35,6 @@ function getBundler(caller) {
|
|
|
36
35
|
}
|
|
37
36
|
exports.getBundler = getBundler;
|
|
38
37
|
function getPlatform(caller) {
|
|
39
|
-
assertExpoBabelCaller(caller);
|
|
40
38
|
if (!caller)
|
|
41
39
|
return null;
|
|
42
40
|
if (caller.platform)
|
|
@@ -50,7 +48,6 @@ function getPlatform(caller) {
|
|
|
50
48
|
}
|
|
51
49
|
exports.getPlatform = getPlatform;
|
|
52
50
|
function getPossibleProjectRoot(caller) {
|
|
53
|
-
assertExpoBabelCaller(caller);
|
|
54
51
|
if (!caller)
|
|
55
52
|
return null;
|
|
56
53
|
if (caller.projectRoot)
|
|
@@ -61,13 +58,10 @@ function getPossibleProjectRoot(caller) {
|
|
|
61
58
|
exports.getPossibleProjectRoot = getPossibleProjectRoot;
|
|
62
59
|
/** If bundling for a react-server target. */
|
|
63
60
|
function getIsReactServer(caller) {
|
|
64
|
-
assertExpoBabelCaller(caller);
|
|
65
61
|
return caller?.isReactServer ?? false;
|
|
66
62
|
}
|
|
67
63
|
exports.getIsReactServer = getIsReactServer;
|
|
68
|
-
function assertExpoBabelCaller(caller) { }
|
|
69
64
|
function getIsDev(caller) {
|
|
70
|
-
assertExpoBabelCaller(caller);
|
|
71
65
|
if (caller?.isDev != null)
|
|
72
66
|
return caller.isDev;
|
|
73
67
|
// https://babeljs.io/docs/options#envname
|
|
@@ -75,14 +69,12 @@ function getIsDev(caller) {
|
|
|
75
69
|
}
|
|
76
70
|
exports.getIsDev = getIsDev;
|
|
77
71
|
function getIsFastRefreshEnabled(caller) {
|
|
78
|
-
assertExpoBabelCaller(caller);
|
|
79
72
|
if (!caller)
|
|
80
73
|
return false;
|
|
81
74
|
return caller.isHMREnabled && !caller.isServer && !caller.isNodeModule && getIsDev(caller);
|
|
82
75
|
}
|
|
83
76
|
exports.getIsFastRefreshEnabled = getIsFastRefreshEnabled;
|
|
84
77
|
function getIsProd(caller) {
|
|
85
|
-
assertExpoBabelCaller(caller);
|
|
86
78
|
if (caller?.isDev != null)
|
|
87
79
|
return caller.isDev === false;
|
|
88
80
|
// https://babeljs.io/docs/options#envname
|
|
@@ -94,22 +86,14 @@ function getIsNodeModule(caller) {
|
|
|
94
86
|
}
|
|
95
87
|
exports.getIsNodeModule = getIsNodeModule;
|
|
96
88
|
function getBaseUrl(caller) {
|
|
97
|
-
assertExpoBabelCaller(caller);
|
|
98
89
|
return caller?.baseUrl ?? '';
|
|
99
90
|
}
|
|
100
91
|
exports.getBaseUrl = getBaseUrl;
|
|
101
|
-
function getReactCompiler(caller) {
|
|
102
|
-
assertExpoBabelCaller(caller);
|
|
103
|
-
return caller?.supportsReactCompiler ?? false;
|
|
104
|
-
}
|
|
105
|
-
exports.getReactCompiler = getReactCompiler;
|
|
106
92
|
function getIsServer(caller) {
|
|
107
|
-
assertExpoBabelCaller(caller);
|
|
108
93
|
return caller?.isServer ?? false;
|
|
109
94
|
}
|
|
110
95
|
exports.getIsServer = getIsServer;
|
|
111
96
|
function getExpoRouterAbsoluteAppRoot(caller) {
|
|
112
|
-
assertExpoBabelCaller(caller);
|
|
113
97
|
const rootModuleId = caller?.routerRoot ?? './app';
|
|
114
98
|
if (path_1.default.isAbsolute(rootModuleId)) {
|
|
115
99
|
return rootModuleId;
|
|
@@ -119,7 +103,6 @@ function getExpoRouterAbsoluteAppRoot(caller) {
|
|
|
119
103
|
}
|
|
120
104
|
exports.getExpoRouterAbsoluteAppRoot = getExpoRouterAbsoluteAppRoot;
|
|
121
105
|
function getInlineEnvVarsEnabled(caller) {
|
|
122
|
-
assertExpoBabelCaller(caller);
|
|
123
106
|
const isWebpack = getBundler(caller) === 'webpack';
|
|
124
107
|
const isDev = getIsDev(caller);
|
|
125
108
|
const isServer = getIsServer(caller);
|
|
@@ -131,7 +114,6 @@ function getInlineEnvVarsEnabled(caller) {
|
|
|
131
114
|
}
|
|
132
115
|
exports.getInlineEnvVarsEnabled = getInlineEnvVarsEnabled;
|
|
133
116
|
function getAsyncRoutes(caller) {
|
|
134
|
-
assertExpoBabelCaller(caller);
|
|
135
117
|
const isServer = getIsServer(caller);
|
|
136
118
|
if (isServer) {
|
|
137
119
|
return false;
|
|
@@ -69,7 +69,7 @@ function expoRouterBabelPlugin(api) {
|
|
|
69
69
|
path.replaceWith(t.stringLiteral(routerAbsoluteRoot));
|
|
70
70
|
}
|
|
71
71
|
else if (key.value.startsWith('EXPO_ROUTER_APP_ROOT')) {
|
|
72
|
-
path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(
|
|
72
|
+
path.replaceWith(t.stringLiteral(getExpoRouterAppRoot(possibleProjectRoot, routerAbsoluteRoot)));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
package/build/index.d.ts
CHANGED
|
@@ -13,53 +13,6 @@ type BabelPresetExpoPlatformOptions = {
|
|
|
13
13
|
disableFlowStripTypesTransform?: boolean;
|
|
14
14
|
enableBabelRuntime?: boolean;
|
|
15
15
|
unstable_transformProfile?: 'default' | 'hermes-stable' | 'hermes-canary';
|
|
16
|
-
/** Settings to pass to `babel-plugin-react-compiler`. Set as `false` to disable the plugin. */
|
|
17
|
-
'react-compiler'?: false | {
|
|
18
|
-
enableUseMemoCachePolyfill?: boolean;
|
|
19
|
-
compilationMode?: 'infer' | 'strict';
|
|
20
|
-
panicThreshold?: 'none' | 'all_errors' | 'critical_errors';
|
|
21
|
-
logger?: any;
|
|
22
|
-
environment?: {
|
|
23
|
-
customHooks?: unknown;
|
|
24
|
-
enableResetCacheOnSourceFileChanges?: boolean;
|
|
25
|
-
enablePreserveExistingMemoizationGuarantees?: boolean;
|
|
26
|
-
/** @default true */
|
|
27
|
-
validatePreserveExistingMemoizationGuarantees?: boolean;
|
|
28
|
-
enableForest?: boolean;
|
|
29
|
-
enableUseTypeAnnotations?: boolean;
|
|
30
|
-
/** @default true */
|
|
31
|
-
enableReactiveScopesInHIR?: boolean;
|
|
32
|
-
/** @default true */
|
|
33
|
-
validateHooksUsage?: boolean;
|
|
34
|
-
validateRefAccessDuringRender?: boolean;
|
|
35
|
-
/** @default true */
|
|
36
|
-
validateNoSetStateInRender?: boolean;
|
|
37
|
-
validateMemoizedEffectDependencies?: boolean;
|
|
38
|
-
validateNoCapitalizedCalls?: string[] | null;
|
|
39
|
-
/** @default true */
|
|
40
|
-
enableAssumeHooksFollowRulesOfReact?: boolean;
|
|
41
|
-
/** @default true */
|
|
42
|
-
enableTransitivelyFreezeFunctionExpressions: boolean;
|
|
43
|
-
enableEmitFreeze?: unknown;
|
|
44
|
-
enableEmitHookGuards?: unknown;
|
|
45
|
-
enableEmitInstrumentForget?: unknown;
|
|
46
|
-
assertValidMutableRanges?: boolean;
|
|
47
|
-
enableChangeVariableCodegen?: boolean;
|
|
48
|
-
enableMemoizationComments?: boolean;
|
|
49
|
-
throwUnknownException__testonly?: boolean;
|
|
50
|
-
enableTreatFunctionDepsAsConditional?: boolean;
|
|
51
|
-
/** Automatically enabled when reanimated plugin is added. */
|
|
52
|
-
enableCustomTypeDefinitionForReanimated?: boolean;
|
|
53
|
-
/** @default `null` */
|
|
54
|
-
hookPattern?: string | null;
|
|
55
|
-
};
|
|
56
|
-
gating?: unknown;
|
|
57
|
-
noEmit?: boolean;
|
|
58
|
-
runtimeModule?: string | null;
|
|
59
|
-
eslintSuppressionRules?: unknown | null;
|
|
60
|
-
flowSuppressions?: boolean;
|
|
61
|
-
ignoreUseNoForget?: boolean;
|
|
62
|
-
};
|
|
63
16
|
/** Enable `typeof window` runtime checks. The default behavior is to minify `typeof window` on web clients to `"object"` and `"undefined"` on servers. */
|
|
64
17
|
minifyTypeofWindow?: boolean;
|
|
65
18
|
};
|
package/build/index.js
CHANGED
|
@@ -21,11 +21,9 @@ function babelPresetExpo(api, options = {}) {
|
|
|
21
21
|
let platform = api.caller((caller) => caller?.platform);
|
|
22
22
|
const engine = api.caller((caller) => caller?.engine) ?? 'default';
|
|
23
23
|
const isDev = api.caller(common_1.getIsDev);
|
|
24
|
-
const isNodeModule = api.caller(common_1.getIsNodeModule);
|
|
25
24
|
const isServer = api.caller(common_1.getIsServer);
|
|
26
25
|
const isReactServer = api.caller(common_1.getIsReactServer);
|
|
27
26
|
const isFastRefreshEnabled = api.caller(common_1.getIsFastRefreshEnabled);
|
|
28
|
-
const isReactCompilerEnabled = api.caller(common_1.getReactCompiler);
|
|
29
27
|
const baseUrl = api.caller(common_1.getBaseUrl);
|
|
30
28
|
const supportsStaticESM = api.caller((caller) => caller?.supportsStaticESM);
|
|
31
29
|
const isServerEnv = isServer || isReactServer;
|
|
@@ -59,30 +57,6 @@ function babelPresetExpo(api, options = {}) {
|
|
|
59
57
|
// `@react-native/babel-preset` will handle it.
|
|
60
58
|
const lazyImportsOption = platformOptions?.lazyImports;
|
|
61
59
|
const extraPlugins = [];
|
|
62
|
-
// Add compiler as soon as possible to prevent other plugins from modifying the code.
|
|
63
|
-
if (isReactCompilerEnabled &&
|
|
64
|
-
// Don't run compiler on node modules, it can only safely be run on the user's code.
|
|
65
|
-
!isNodeModule &&
|
|
66
|
-
// Only run for client code. It's unclear if compiler has any benefits for React Server Components.
|
|
67
|
-
// NOTE: We might want to allow running it to prevent hydration errors.
|
|
68
|
-
!isServerEnv &&
|
|
69
|
-
// Give users the ability to opt-out of the feature, per-platform.
|
|
70
|
-
platformOptions['react-compiler'] !== false) {
|
|
71
|
-
extraPlugins.push([
|
|
72
|
-
require('babel-plugin-react-compiler'),
|
|
73
|
-
{
|
|
74
|
-
runtimeModule: 'babel-preset-expo/react-compiler-runtime.js',
|
|
75
|
-
// enableUseMemoCachePolyfill: true,
|
|
76
|
-
// compilationMode: 'infer',
|
|
77
|
-
environment: {
|
|
78
|
-
enableResetCacheOnSourceFileChanges: !isProduction,
|
|
79
|
-
...(platformOptions['react-compiler']?.environment ?? {}),
|
|
80
|
-
},
|
|
81
|
-
panicThreshold: isDev ? undefined : 'NONE',
|
|
82
|
-
...platformOptions['react-compiler'],
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
60
|
if (engine !== 'hermes') {
|
|
87
61
|
// `@react-native/babel-preset` configures this plugin with `{ loose: true }`, which breaks all
|
|
88
62
|
// getters and setters in spread objects. We need to add this plugin ourself without that option.
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.10",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"build",
|
|
8
|
-
"lazy-imports-blacklist.js"
|
|
9
|
-
"react-compiler-runtime.js"
|
|
8
|
+
"lazy-imports-blacklist.js"
|
|
10
9
|
],
|
|
11
10
|
"scripts": {
|
|
12
11
|
"build": "expo-module build",
|
|
@@ -49,7 +48,6 @@
|
|
|
49
48
|
"@babel/preset-typescript": "^7.23.0",
|
|
50
49
|
"@babel/preset-react": "^7.22.15",
|
|
51
50
|
"@react-native/babel-preset": "0.74.84",
|
|
52
|
-
"babel-plugin-react-compiler": "^0.0.0-experimental-592953e-20240517",
|
|
53
51
|
"babel-plugin-react-native-web": "~0.19.10",
|
|
54
52
|
"react-refresh": "^0.14.2"
|
|
55
53
|
},
|
|
@@ -58,5 +56,5 @@
|
|
|
58
56
|
"expo-module-scripts": "^3.3.0",
|
|
59
57
|
"jest": "^29.2.1"
|
|
60
58
|
},
|
|
61
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6f609a05a2d4dac7fd281bcc502575440c5af7c9"
|
|
62
60
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// lib/react-compiler-runtime.js
|
|
2
|
-
const $empty = Symbol.for('react.memo_cache_sentinel');
|
|
3
|
-
const React = require('react');
|
|
4
|
-
/**
|
|
5
|
-
* DANGER: this hook is NEVER meant to be called directly!
|
|
6
|
-
*
|
|
7
|
-
* Note that this is a temporary userspace implementation of this function
|
|
8
|
-
* from React 19. It is not as efficient and may invalidate more frequently
|
|
9
|
-
* than the official API. Please upgrade to React 19 as soon as you can.
|
|
10
|
-
**/
|
|
11
|
-
export function c(size) {
|
|
12
|
-
return React.useState(() => {
|
|
13
|
-
const $ = new Array(size);
|
|
14
|
-
for (let ii = 0; ii < size; ii++) {
|
|
15
|
-
$[ii] = $empty;
|
|
16
|
-
}
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
$[$empty] = true;
|
|
19
|
-
return $;
|
|
20
|
-
})[0];
|
|
21
|
-
}
|