babel-preset-expo 13.2.0-canary-20250428-4156f88 → 13.2.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/README.md +2 -2
- package/build/client-module-proxy-plugin.js +10 -3
- package/build/common.d.ts +5 -0
- package/build/common.js +13 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +11 -2
- package/build/server-actions-plugin.js +5 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Settings to pass to `babel-plugin-react-compiler`. Set as `false` to disable the
|
|
|
33
33
|
|
|
34
34
|
### `minifyTypeofWindow`
|
|
35
35
|
|
|
36
|
-
Set `minifyTypeofWindow:
|
|
36
|
+
Set `minifyTypeofWindow: true` to transform `typeof window` checks in your code, e.g. `if (typeof window === 'object')` -> `if (true)` in clients. This is useful when you're using libraries that mock the window object on native or in the server.
|
|
37
37
|
|
|
38
38
|
```js
|
|
39
39
|
[
|
|
@@ -47,7 +47,7 @@ Set `minifyTypeofWindow: false` to preserve the `typeof window` check in your co
|
|
|
47
47
|
];
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
Defaults to `
|
|
50
|
+
Defaults to `true` for server environments, and `false` for client environments to support legacy browser polyfills and web workers.
|
|
51
51
|
|
|
52
52
|
### `reanimated`
|
|
53
53
|
|
|
@@ -8,10 +8,12 @@ exports.reactClientReferencesPlugin = reactClientReferencesPlugin;
|
|
|
8
8
|
* Copyright © 2024 650 Industries.
|
|
9
9
|
*/
|
|
10
10
|
const core_1 = require("@babel/core");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
11
12
|
const node_url_1 = __importDefault(require("node:url"));
|
|
12
13
|
const common_1 = require("./common");
|
|
13
14
|
function reactClientReferencesPlugin(api) {
|
|
14
15
|
const isReactServer = api.caller(common_1.getIsReactServer);
|
|
16
|
+
const possibleProjectRoot = api.caller(common_1.getPossibleProjectRoot);
|
|
15
17
|
return {
|
|
16
18
|
name: 'expo-client-references',
|
|
17
19
|
visitor: {
|
|
@@ -32,7 +34,12 @@ function reactClientReferencesPlugin(api) {
|
|
|
32
34
|
// This can happen in tests or systems that use Babel standalone.
|
|
33
35
|
throw new Error('[Babel] Expected a filename to be set in the state');
|
|
34
36
|
}
|
|
35
|
-
const
|
|
37
|
+
const projectRoot = possibleProjectRoot || state.file.opts.root || '';
|
|
38
|
+
// TODO: Replace with opaque paths in production.
|
|
39
|
+
const outputKey = './' + (0, common_1.toPosixPath)((0, node_path_1.relative)(projectRoot, filePath));
|
|
40
|
+
// const outputKey = isProd
|
|
41
|
+
// ? './' + getRelativePath(projectRoot, filePath)
|
|
42
|
+
// : url.pathToFileURL(filePath).href;
|
|
36
43
|
function iterateExports(callback, type) {
|
|
37
44
|
const exportNames = new Set();
|
|
38
45
|
// Collect all of the exports
|
|
@@ -157,7 +164,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
157
164
|
// Store the proxy export names for testing purposes.
|
|
158
165
|
state.file.metadata.proxyExports = [...proxyExports];
|
|
159
166
|
// Save the server action reference in the metadata.
|
|
160
|
-
state.file.metadata.reactServerReference =
|
|
167
|
+
state.file.metadata.reactServerReference = node_url_1.default.pathToFileURL(filePath).href;
|
|
161
168
|
}
|
|
162
169
|
else if (isUseClient) {
|
|
163
170
|
if (!isReactServer) {
|
|
@@ -208,7 +215,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
208
215
|
// Store the proxy export names for testing purposes.
|
|
209
216
|
state.file.metadata.proxyExports = [...proxyExports];
|
|
210
217
|
// Save the client reference in the metadata.
|
|
211
|
-
state.file.metadata.reactClientReference =
|
|
218
|
+
state.file.metadata.reactClientReference = node_url_1.default.pathToFileURL(filePath).href;
|
|
212
219
|
}
|
|
213
220
|
},
|
|
214
221
|
},
|
package/build/common.d.ts
CHANGED
|
@@ -14,7 +14,12 @@ export declare function getIsNodeModule(caller?: any): boolean;
|
|
|
14
14
|
export declare function getBaseUrl(caller?: any): string;
|
|
15
15
|
export declare function getReactCompiler(caller?: any): boolean;
|
|
16
16
|
export declare function getIsServer(caller?: any): boolean;
|
|
17
|
+
export declare function getMetroSourceType(caller?: any): "script" | "module" | "asset" | undefined;
|
|
17
18
|
export declare function getExpoRouterAbsoluteAppRoot(caller?: any): string;
|
|
18
19
|
export declare function getInlineEnvVarsEnabled(caller?: any): boolean;
|
|
19
20
|
export declare function getAsyncRoutes(caller?: any): boolean;
|
|
20
21
|
export declare function createAddNamedImportOnce(t: typeof import('@babel/types')): (path: NodePath<t.Node>, name: string, source: string) => any;
|
|
22
|
+
/**
|
|
23
|
+
* Convert any platform-specific path to a POSIX path.
|
|
24
|
+
*/
|
|
25
|
+
export declare function toPosixPath(filePath: string): string;
|
package/build/common.js
CHANGED
|
@@ -15,10 +15,12 @@ exports.getIsNodeModule = getIsNodeModule;
|
|
|
15
15
|
exports.getBaseUrl = getBaseUrl;
|
|
16
16
|
exports.getReactCompiler = getReactCompiler;
|
|
17
17
|
exports.getIsServer = getIsServer;
|
|
18
|
+
exports.getMetroSourceType = getMetroSourceType;
|
|
18
19
|
exports.getExpoRouterAbsoluteAppRoot = getExpoRouterAbsoluteAppRoot;
|
|
19
20
|
exports.getInlineEnvVarsEnabled = getInlineEnvVarsEnabled;
|
|
20
21
|
exports.getAsyncRoutes = getAsyncRoutes;
|
|
21
22
|
exports.createAddNamedImportOnce = createAddNamedImportOnce;
|
|
23
|
+
exports.toPosixPath = toPosixPath;
|
|
22
24
|
// @ts-expect-error: missing types
|
|
23
25
|
const helper_module_imports_1 = require("@babel/helper-module-imports");
|
|
24
26
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -113,6 +115,10 @@ function getIsServer(caller) {
|
|
|
113
115
|
assertExpoBabelCaller(caller);
|
|
114
116
|
return caller?.isServer ?? false;
|
|
115
117
|
}
|
|
118
|
+
function getMetroSourceType(caller) {
|
|
119
|
+
assertExpoBabelCaller(caller);
|
|
120
|
+
return caller?.metroSourceType;
|
|
121
|
+
}
|
|
116
122
|
function getExpoRouterAbsoluteAppRoot(caller) {
|
|
117
123
|
assertExpoBabelCaller(caller);
|
|
118
124
|
const rootModuleId = caller?.routerRoot ?? './app';
|
|
@@ -164,3 +170,10 @@ function createAddNamedImportOnce(t) {
|
|
|
164
170
|
return didCreate ? identifier : t.cloneNode(identifier);
|
|
165
171
|
};
|
|
166
172
|
}
|
|
173
|
+
const REGEXP_REPLACE_SLASHES = /\\/g;
|
|
174
|
+
/**
|
|
175
|
+
* Convert any platform-specific path to a POSIX path.
|
|
176
|
+
*/
|
|
177
|
+
function toPosixPath(filePath) {
|
|
178
|
+
return filePath.replace(REGEXP_REPLACE_SLASHES, '/');
|
|
179
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ type BabelPresetExpoPlatformOptions = {
|
|
|
15
15
|
jsxImportSource?: string;
|
|
16
16
|
lazyImports?: boolean;
|
|
17
17
|
disableImportExportTransform?: boolean;
|
|
18
|
+
disableDeepImportWarnings?: boolean;
|
|
18
19
|
disableFlowStripTypesTransform?: boolean;
|
|
19
20
|
enableBabelRuntime?: boolean;
|
|
20
21
|
unstable_transformProfile?: 'default' | 'hermes-stable' | 'hermes-canary';
|
package/build/index.js
CHANGED
|
@@ -29,6 +29,7 @@ function babelPresetExpo(api, options = {}) {
|
|
|
29
29
|
const isReactServer = api.caller(common_1.getIsReactServer);
|
|
30
30
|
const isFastRefreshEnabled = api.caller(common_1.getIsFastRefreshEnabled);
|
|
31
31
|
const isReactCompilerEnabled = api.caller(common_1.getReactCompiler);
|
|
32
|
+
const metroSourceType = api.caller(common_1.getMetroSourceType);
|
|
32
33
|
const baseUrl = api.caller(common_1.getBaseUrl);
|
|
33
34
|
const supportsStaticESM = api.caller((caller) => caller?.supportsStaticESM);
|
|
34
35
|
const isServerEnv = isServer || isReactServer;
|
|
@@ -44,6 +45,11 @@ function babelPresetExpo(api, options = {}) {
|
|
|
44
45
|
// Use the simpler babel preset for web and server environments (both web and native SSR).
|
|
45
46
|
const isModernEngine = platform === 'web' || isServerEnv;
|
|
46
47
|
const platformOptions = getOptions(options, platform);
|
|
48
|
+
// If the input is a script, we're unable to add any dependencies. Since the @babel/runtime transformer
|
|
49
|
+
// adds extra dependencies (requires/imports) we need to disable it
|
|
50
|
+
if (metroSourceType === 'script') {
|
|
51
|
+
platformOptions.enableBabelRuntime = false;
|
|
52
|
+
}
|
|
47
53
|
if (platformOptions.useTransformReactJSXExperimental != null) {
|
|
48
54
|
throw new Error(`babel-preset-expo: The option 'useTransformReactJSXExperimental' has been removed in favor of { jsxRuntime: 'classic' }.`);
|
|
49
55
|
}
|
|
@@ -111,7 +117,9 @@ function babelPresetExpo(api, options = {}) {
|
|
|
111
117
|
'process.env.EXPO_SERVER': !!isServerEnv,
|
|
112
118
|
};
|
|
113
119
|
// `typeof window` is left in place for native + client environments.
|
|
114
|
-
|
|
120
|
+
// NOTE(@kitten): We're temporarily disabling this default optimization for Web targets due to Web Workers
|
|
121
|
+
// We're currently not passing metadata to indicate we're transforming for a Web Worker to disable this automatically
|
|
122
|
+
const minifyTypeofWindow = platformOptions.minifyTypeofWindow ?? isServerEnv;
|
|
115
123
|
if (minifyTypeofWindow !== false) {
|
|
116
124
|
// This nets out slightly faster in development when considering the cost of bundling server dependencies.
|
|
117
125
|
inlines['typeof window'] = isServerEnv ? 'undefined' : 'object';
|
|
@@ -199,12 +207,13 @@ function babelPresetExpo(api, options = {}) {
|
|
|
199
207
|
// Otherwise, you'll sometime get errors like the following (starting in Expo SDK 43, React Native 64, React 17):
|
|
200
208
|
//
|
|
201
209
|
// TransformError App.js: /path/to/App.js: Duplicate __self prop found. You are most likely using the deprecated transform-react-jsx-self Babel plugin.
|
|
202
|
-
// Both __source and __self are automatically set when using the automatic jsxRuntime.
|
|
210
|
+
// Both __source and __self are automatically set when using the automatic jsxRuntime. Remove transform-react-jsx-source and transform-react-jsx-self from your Babel config.
|
|
203
211
|
useTransformReactJSXExperimental: true,
|
|
204
212
|
// This will never be used regardless because `useTransformReactJSXExperimental` is set to `true`.
|
|
205
213
|
// https://github.com/facebook/react-native/blob/a4a8695cec640e5cf12be36a0c871115fbce9c87/packages/react-native-babel-preset/src/configs/main.js#L151
|
|
206
214
|
withDevTools: false,
|
|
207
215
|
disableImportExportTransform: platformOptions.disableImportExportTransform,
|
|
216
|
+
disableDeepImportWarnings: platformOptions.disableDeepImportWarnings,
|
|
208
217
|
lazyImportExportTransform: lazyImportsOption === true
|
|
209
218
|
? (importModuleSpecifier) => {
|
|
210
219
|
// Do not lazy-initialize packages that are local imports (similar to `lazy: true`
|
|
@@ -41,12 +41,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
return result;
|
|
42
42
|
};
|
|
43
43
|
})();
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
44
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
48
|
exports.reactServerActionsPlugin = reactServerActionsPlugin;
|
|
46
49
|
const core_1 = require("@babel/core");
|
|
47
50
|
const t = __importStar(require("@babel/types"));
|
|
48
51
|
const node_path_1 = require("node:path");
|
|
49
|
-
const node_url_1 =
|
|
52
|
+
const node_url_1 = __importDefault(require("node:url"));
|
|
50
53
|
const common_1 = require("./common");
|
|
51
54
|
const debug = require('debug')('expo:babel:server-actions');
|
|
52
55
|
const LAZY_WRAPPER_VALUE_KEY = 'value';
|
|
@@ -193,7 +196,7 @@ function reactServerActionsPlugin(api) {
|
|
|
193
196
|
};
|
|
194
197
|
getActionModuleId = once(() => {
|
|
195
198
|
// Create relative file path hash.
|
|
196
|
-
return (0,
|
|
199
|
+
return './' + (0, common_1.toPosixPath)((0, node_path_1.relative)(projectRoot, file.opts.filename));
|
|
197
200
|
});
|
|
198
201
|
const defineBoundArgsWrapperHelper = once(() => {
|
|
199
202
|
const id = this.file.path.scope.generateUidIdentifier('wrapBoundArgs');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "13.2.
|
|
3
|
+
"version": "13.2.1",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@babel/plugin-transform-parameters": "^7.24.7",
|
|
56
56
|
"@babel/preset-react": "^7.22.15",
|
|
57
57
|
"@babel/preset-typescript": "^7.23.0",
|
|
58
|
-
"@react-native/babel-preset": "0.79.
|
|
58
|
+
"@react-native/babel-preset": "0.79.4",
|
|
59
59
|
"babel-plugin-react-native-web": "~0.19.13",
|
|
60
60
|
"babel-plugin-transform-flow-enums": "^0.0.2",
|
|
61
61
|
"babel-plugin-syntax-hermes-parser": "^0.25.1",
|
|
@@ -76,7 +76,8 @@
|
|
|
76
76
|
"@babel/traverse": "^7.9.0",
|
|
77
77
|
"@babel/types": "^7.9.0",
|
|
78
78
|
"babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250405",
|
|
79
|
-
"expo-module-scripts": "4.1.
|
|
79
|
+
"expo-module-scripts": "^4.1.7",
|
|
80
80
|
"jest": "^29.2.1"
|
|
81
|
-
}
|
|
81
|
+
},
|
|
82
|
+
"gitHead": "cc3b641cc2e4e7686dca75e7029cf76a07b3d647"
|
|
82
83
|
}
|