babel-preset-expo 13.1.6 → 13.1.8
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 +1 -1
- package/build/client-module-proxy-plugin.js +10 -3
- package/build/common.d.ts +4 -0
- package/build/common.js +8 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +2 -1
- package/build/server-actions-plugin.js +5 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ Changes the engine preset in `@react-native/babel-preset` based on the JavaScrip
|
|
|
150
150
|
|
|
151
151
|
### `unstable_transformImportMeta`
|
|
152
152
|
|
|
153
|
-
Enable that transform that converts `import.meta` to `globalThis.__ExpoImportMetaRegistry`, defaults to `false
|
|
153
|
+
Enable that transform that converts `import.meta` to `globalThis.__ExpoImportMetaRegistry`, defaults to `false` in client bundles and `true` for server bundles.
|
|
154
154
|
|
|
155
155
|
> **Note:** Use this option at your own risk. If the JavaScript engine supports `import.meta` natively, this transformation may interfere with the native implementation.
|
|
156
156
|
|
|
@@ -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
|
@@ -18,3 +18,7 @@ export declare function getExpoRouterAbsoluteAppRoot(caller?: any): string;
|
|
|
18
18
|
export declare function getInlineEnvVarsEnabled(caller?: any): boolean;
|
|
19
19
|
export declare function getAsyncRoutes(caller?: any): boolean;
|
|
20
20
|
export declare function createAddNamedImportOnce(t: typeof import('@babel/types')): (path: NodePath<t.Node>, name: string, source: string) => any;
|
|
21
|
+
/**
|
|
22
|
+
* Convert any platform-specific path to a POSIX path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toPosixPath(filePath: string): string;
|
package/build/common.js
CHANGED
|
@@ -19,6 +19,7 @@ exports.getExpoRouterAbsoluteAppRoot = getExpoRouterAbsoluteAppRoot;
|
|
|
19
19
|
exports.getInlineEnvVarsEnabled = getInlineEnvVarsEnabled;
|
|
20
20
|
exports.getAsyncRoutes = getAsyncRoutes;
|
|
21
21
|
exports.createAddNamedImportOnce = createAddNamedImportOnce;
|
|
22
|
+
exports.toPosixPath = toPosixPath;
|
|
22
23
|
// @ts-expect-error: missing types
|
|
23
24
|
const helper_module_imports_1 = require("@babel/helper-module-imports");
|
|
24
25
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -164,3 +165,10 @@ function createAddNamedImportOnce(t) {
|
|
|
164
165
|
return didCreate ? identifier : t.cloneNode(identifier);
|
|
165
166
|
};
|
|
166
167
|
}
|
|
168
|
+
const REGEXP_REPLACE_SLASHES = /\\/g;
|
|
169
|
+
/**
|
|
170
|
+
* Convert any platform-specific path to a POSIX path.
|
|
171
|
+
*/
|
|
172
|
+
function toPosixPath(filePath) {
|
|
173
|
+
return filePath.replace(REGEXP_REPLACE_SLASHES, '/');
|
|
174
|
+
}
|
package/build/index.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ type BabelPresetExpoPlatformOptions = {
|
|
|
72
72
|
*
|
|
73
73
|
* > **Note:** Use this option at your own risk. If the JavaScript engine supports `import.meta` natively, this transformation may interfere with the native implementation.
|
|
74
74
|
*
|
|
75
|
-
* @default `false`
|
|
75
|
+
* @default `false` on client and `true` on server.
|
|
76
76
|
*/
|
|
77
77
|
unstable_transformImportMeta?: boolean;
|
|
78
78
|
};
|
package/build/index.js
CHANGED
|
@@ -181,7 +181,8 @@ function babelPresetExpo(api, options = {}) {
|
|
|
181
181
|
if (platformOptions.disableImportExportTransform) {
|
|
182
182
|
extraPlugins.push([require('./detect-dynamic-exports').detectDynamicExports]);
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
const polyfillImportMeta = platformOptions.unstable_transformImportMeta ?? isServerEnv;
|
|
185
|
+
extraPlugins.push((0, import_meta_transform_plugin_1.expoImportMetaTransformPluginFactory)(polyfillImportMeta === true));
|
|
185
186
|
return {
|
|
186
187
|
presets: [
|
|
187
188
|
(() => {
|
|
@@ -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.1.
|
|
3
|
+
"version": "13.1.8",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -76,8 +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.5",
|
|
80
80
|
"jest": "^29.2.1"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "a639a661a5329e58f916cf69b8f1a7718bbdd26e"
|
|
83
83
|
}
|