babel-preset-expo 13.3.0-canary-20250722-599a28f → 14.0.0
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/build/babel-plugin-transform-export-namespace-from.d.ts +2 -2
- package/build/babel-plugin-transform-export-namespace-from.js +6 -7
- package/build/client-module-proxy-plugin.d.ts +2 -2
- package/build/client-module-proxy-plugin.js +6 -9
- package/build/common.d.ts +2 -3
- package/build/define-plugin.d.ts +3 -5
- package/build/define-plugin.js +18 -53
- package/build/detect-dynamic-exports.d.ts +2 -4
- package/build/environment-restricted-imports.d.ts +2 -4
- package/build/expo-inline-manifest-plugin.d.ts +2 -9
- package/build/expo-inline-manifest-plugin.js +42 -13
- package/build/expo-router-plugin.d.ts +2 -9
- package/build/expo-router-plugin.js +1 -5
- package/build/import-meta-transform-plugin.d.ts +2 -4
- package/build/index.d.ts +1 -1
- package/build/index.js +12 -1
- package/build/inline-env-vars.d.ts +2 -4
- package/build/inline-env-vars.js +6 -7
- package/build/minify-platform-select-plugin.d.ts +2 -4
- package/build/minify-platform-select-plugin.js +40 -41
- package/build/restricted-react-api-plugin.d.ts +2 -4
- package/build/server-actions-plugin.d.ts +2 -4
- package/build/server-actions-plugin.js +21 -60
- package/build/use-dom-directive-plugin.d.ts +2 -4
- package/build/use-dom-directive-plugin.js +2 -6
- package/package.json +21 -19
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { PluginObj } from '@babel/core';
|
|
9
|
-
declare const _default: () => PluginObj;
|
|
8
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
9
|
+
declare const _default: ({ types: t }: ConfigAPI & typeof import("@babel/core")) => PluginObj;
|
|
10
10
|
export default _default;
|
|
@@ -7,10 +7,9 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const core_1 = require("@babel/core");
|
|
11
10
|
// Original: https://github.com/babel/babel/blob/e5c8dc7330cb2f66c37637677609df90b31ff0de/packages/babel-plugin-transform-export-namespace-from/src/index.ts
|
|
12
11
|
// NOTE: Original plugin asserts that Babel version 7 or newer is used. This was removed for simplicity.
|
|
13
|
-
exports.default = () => ({
|
|
12
|
+
exports.default = ({ types: t }) => ({
|
|
14
13
|
name: 'transform-export-namespace-from',
|
|
15
14
|
manipulateOptions: process.env.BABEL_8_BREAKING
|
|
16
15
|
? undefined
|
|
@@ -19,21 +18,21 @@ exports.default = () => ({
|
|
|
19
18
|
ExportNamedDeclaration(path) {
|
|
20
19
|
const { node, scope } = path;
|
|
21
20
|
const { specifiers } = node;
|
|
22
|
-
const index =
|
|
23
|
-
if (!
|
|
21
|
+
const index = t.isExportDefaultSpecifier(specifiers[0]) ? 1 : 0;
|
|
22
|
+
if (!t.isExportNamespaceSpecifier(specifiers[index]))
|
|
24
23
|
return;
|
|
25
24
|
const nodes = [];
|
|
26
25
|
if (index === 1) {
|
|
27
|
-
nodes.push(
|
|
26
|
+
nodes.push(t.exportNamedDeclaration(null, [specifiers.shift()], node.source));
|
|
28
27
|
}
|
|
29
28
|
const specifier = specifiers.shift();
|
|
30
29
|
const { exported } = specifier;
|
|
31
30
|
const uid = scope.generateUidIdentifier(
|
|
32
31
|
// @ts-expect-error Identifier ?? StringLiteral
|
|
33
32
|
exported.name ?? exported.value);
|
|
34
|
-
nodes.push(withLocation(
|
|
33
|
+
nodes.push(withLocation(t.importDeclaration([t.importNamespaceSpecifier(uid)],
|
|
35
34
|
// @ts-expect-error
|
|
36
|
-
|
|
35
|
+
t.cloneNode(node.source)), node.loc), withLocation(t.exportNamedDeclaration(null, [t.exportSpecifier(t.cloneNode(uid), exported)]), node.loc));
|
|
37
36
|
if (node.specifiers.length >= 1) {
|
|
38
37
|
nodes.push(node);
|
|
39
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigAPI } from '@babel/core';
|
|
5
|
-
export declare function reactClientReferencesPlugin(api: ConfigAPI):
|
|
4
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
5
|
+
export declare function reactClientReferencesPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -4,14 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.reactClientReferencesPlugin = reactClientReferencesPlugin;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright © 2024 650 Industries.
|
|
9
|
-
*/
|
|
10
|
-
const core_1 = require("@babel/core");
|
|
11
7
|
const node_path_1 = require("node:path");
|
|
12
8
|
const node_url_1 = __importDefault(require("node:url"));
|
|
13
9
|
const common_1 = require("./common");
|
|
14
10
|
function reactClientReferencesPlugin(api) {
|
|
11
|
+
const { template, types } = api;
|
|
15
12
|
const isReactServer = api.caller(common_1.getIsReactServer);
|
|
16
13
|
const possibleProjectRoot = api.caller(common_1.getPossibleProjectRoot);
|
|
17
14
|
return {
|
|
@@ -81,7 +78,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
81
78
|
}
|
|
82
79
|
else {
|
|
83
80
|
exportPath.node.specifiers.forEach((specifier) => {
|
|
84
|
-
if (
|
|
81
|
+
if (types.isIdentifier(specifier.exported)) {
|
|
85
82
|
const exportName = specifier.exported.name;
|
|
86
83
|
exportNames.add(exportName);
|
|
87
84
|
callback(exportName, exportPath);
|
|
@@ -115,7 +112,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
115
112
|
// Assert that assignment to `module.exports` or `exports` is not allowed.
|
|
116
113
|
path.traverse({
|
|
117
114
|
AssignmentExpression(path) {
|
|
118
|
-
if (
|
|
115
|
+
if (types.isMemberExpression(path.node.left) &&
|
|
119
116
|
'name' in path.node.left.object &&
|
|
120
117
|
(path.node.left.object.name === 'module' ||
|
|
121
118
|
path.node.left.object.name === 'exports')) {
|
|
@@ -124,7 +121,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
124
121
|
},
|
|
125
122
|
// Also check Object.assign
|
|
126
123
|
CallExpression(path) {
|
|
127
|
-
if (
|
|
124
|
+
if (types.isMemberExpression(path.node.callee) &&
|
|
128
125
|
'name' in path.node.callee.property &&
|
|
129
126
|
'name' in path.node.callee.object &&
|
|
130
127
|
path.node.callee.property.name === 'assign' &&
|
|
@@ -159,7 +156,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
159
156
|
// Clear the body
|
|
160
157
|
path.node.body = [];
|
|
161
158
|
path.node.directives = [];
|
|
162
|
-
path.pushContainer('body',
|
|
159
|
+
path.pushContainer('body', template.ast(proxyModule.join('\n')));
|
|
163
160
|
assertExpoMetadata(state.file.metadata);
|
|
164
161
|
// Store the proxy export names for testing purposes.
|
|
165
162
|
state.file.metadata.proxyExports = [...proxyExports];
|
|
@@ -210,7 +207,7 @@ function reactClientReferencesPlugin(api) {
|
|
|
210
207
|
// Clear the body
|
|
211
208
|
path.node.body = [];
|
|
212
209
|
path.node.directives = [];
|
|
213
|
-
path.pushContainer('body',
|
|
210
|
+
path.pushContainer('body', template.ast(proxyModule.join('\n')));
|
|
214
211
|
assertExpoMetadata(state.file.metadata);
|
|
215
212
|
// Store the proxy export names for testing purposes.
|
|
216
213
|
state.file.metadata.proxyExports = [...proxyExports];
|
package/build/common.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as t from '@babel/types';
|
|
1
|
+
import type { NodePath, types as t } from '@babel/core';
|
|
3
2
|
export declare function hasModule(name: string): boolean;
|
|
4
3
|
/** Determine which bundler is being used. */
|
|
5
4
|
export declare function getBundler(caller?: any): "metro" | "webpack" | null;
|
|
@@ -18,7 +17,7 @@ export declare function getMetroSourceType(caller?: any): "script" | "module" |
|
|
|
18
17
|
export declare function getExpoRouterAbsoluteAppRoot(caller?: any): string;
|
|
19
18
|
export declare function getInlineEnvVarsEnabled(caller?: any): boolean;
|
|
20
19
|
export declare function getAsyncRoutes(caller?: any): boolean;
|
|
21
|
-
export declare function createAddNamedImportOnce(t: typeof import('@babel/
|
|
20
|
+
export declare function createAddNamedImportOnce(t: typeof import('@babel/core').types): (path: NodePath<t.Node>, name: string, source: string) => any;
|
|
22
21
|
/**
|
|
23
22
|
* Convert any platform-specific path to a POSIX path.
|
|
24
23
|
*/
|
package/build/define-plugin.d.ts
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import
|
|
9
|
-
declare
|
|
10
|
-
|
|
11
|
-
}) => babel.PluginObj;
|
|
12
|
-
export default plugin;
|
|
8
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
9
|
+
declare function definePlugin({ types: t }: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
10
|
+
export default definePlugin;
|
package/build/define-plugin.js
CHANGED
|
@@ -6,55 +6,7 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
-
}) : function(o, v) {
|
|
23
|
-
o["default"] = v;
|
|
24
|
-
});
|
|
25
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
-
var ownKeys = function(o) {
|
|
27
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
-
var ar = [];
|
|
29
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
return ownKeys(o);
|
|
33
|
-
};
|
|
34
|
-
return function (mod) {
|
|
35
|
-
if (mod && mod.__esModule) return mod;
|
|
36
|
-
var result = {};
|
|
37
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
-
__setModuleDefault(result, mod);
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
})();
|
|
42
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
const t = __importStar(require("@babel/types"));
|
|
44
|
-
/**
|
|
45
|
-
* Replace a node with a given value. If the replacement results in a BinaryExpression, it will be
|
|
46
|
-
* evaluated. For example, if the result of the replacement is `var x = "production" === "production"`
|
|
47
|
-
* The evaluation will make a second replacement resulting in `var x = true`
|
|
48
|
-
*/
|
|
49
|
-
function replaceAndEvaluateNode(nodePath, replacement) {
|
|
50
|
-
nodePath.replaceWith(t.valueToNode(replacement));
|
|
51
|
-
if (nodePath.parentPath && nodePath.parentPath.isBinaryExpression()) {
|
|
52
|
-
const result = nodePath.parentPath.evaluate();
|
|
53
|
-
if (result.confident) {
|
|
54
|
-
nodePath.parentPath.replaceWith(t.valueToNode(result.value));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
10
|
/**
|
|
59
11
|
* Checks if the given identifier is an ES module import
|
|
60
12
|
* @param {babelNode} identifierNodePath The node to check
|
|
@@ -77,9 +29,23 @@ const unaryExpressionComparator = (nodePath, value) => {
|
|
|
77
29
|
}
|
|
78
30
|
return false;
|
|
79
31
|
};
|
|
80
|
-
const isLeftHandSideOfAssignmentExpression = (node, parent) => t.isAssignmentExpression(parent) && parent.left === node;
|
|
81
32
|
const TYPEOF_PREFIX = 'typeof ';
|
|
82
|
-
|
|
33
|
+
function definePlugin({ types: t }) {
|
|
34
|
+
/**
|
|
35
|
+
* Replace a node with a given value. If the replacement results in a BinaryExpression, it will be
|
|
36
|
+
* evaluated. For example, if the result of the replacement is `var x = "production" === "production"`
|
|
37
|
+
* The evaluation will make a second replacement resulting in `var x = true`
|
|
38
|
+
*/
|
|
39
|
+
function replaceAndEvaluateNode(nodePath, replacement) {
|
|
40
|
+
nodePath.replaceWith(t.valueToNode(replacement));
|
|
41
|
+
if (nodePath.parentPath && nodePath.parentPath.isBinaryExpression()) {
|
|
42
|
+
const result = nodePath.parentPath.evaluate();
|
|
43
|
+
if (result.confident) {
|
|
44
|
+
nodePath.parentPath.replaceWith(t.valueToNode(result.value));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const isLeftHandSideOfAssignmentExpression = (node, parent) => t.isAssignmentExpression(parent) && parent.left === node;
|
|
83
49
|
const processNode = (replacements, nodePath, comparator) => {
|
|
84
50
|
const replacementKey = Object.keys(replacements).find((value) => comparator(nodePath, value));
|
|
85
51
|
if (typeof replacementKey === 'string' &&
|
|
@@ -103,7 +69,6 @@ const plugin = (_) => {
|
|
|
103
69
|
processNode(replacements, nodePath, memberExpressionComparator);
|
|
104
70
|
},
|
|
105
71
|
// const x = { version: VERSION };
|
|
106
|
-
// @ts-expect-error: Virtual type `ReferencedIdentifier` is not on types.
|
|
107
72
|
ReferencedIdentifier(nodePath, state) {
|
|
108
73
|
const binding = nodePath.scope?.getBinding(nodePath.node.name);
|
|
109
74
|
if (binding ||
|
|
@@ -142,10 +107,10 @@ const plugin = (_) => {
|
|
|
142
107
|
},
|
|
143
108
|
},
|
|
144
109
|
};
|
|
145
|
-
}
|
|
110
|
+
}
|
|
146
111
|
function assertOptions(opts) {
|
|
147
112
|
if (opts == null || typeof opts !== 'object') {
|
|
148
113
|
throw new Error('define plugin expects an object as options');
|
|
149
114
|
}
|
|
150
115
|
}
|
|
151
|
-
exports.default =
|
|
116
|
+
exports.default = definePlugin;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
export declare function detectDynamicExports(api: ConfigAPI &
|
|
6
|
-
types: typeof types;
|
|
7
|
-
}): babel.PluginObj;
|
|
4
|
+
import type { PluginObj, ConfigAPI } from '@babel/core';
|
|
5
|
+
export declare function detectDynamicExports(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigAPI,
|
|
4
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
5
5
|
/** Prevent importing certain known imports in given environments. This is for sanity to ensure a module never accidentally gets imported unexpectedly. */
|
|
6
|
-
export declare function environmentRestrictedImportsPlugin(api: ConfigAPI &
|
|
7
|
-
types: typeof types;
|
|
8
|
-
}): babel.PluginObj;
|
|
6
|
+
export declare function environmentRestrictedImportsPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import { ConfigAPI } from '@babel/core';
|
|
2
|
-
export declare function expoInlineManifestPlugin(api: ConfigAPI &
|
|
3
|
-
types: any;
|
|
4
|
-
}): {
|
|
5
|
-
name: string;
|
|
6
|
-
visitor: {
|
|
7
|
-
MemberExpression(path: any, state: any): void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
1
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
2
|
+
export declare function expoInlineManifestPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expoInlineManifestPlugin = expoInlineManifestPlugin;
|
|
4
|
-
const config_1 = require("expo/config");
|
|
5
4
|
const common_1 = require("./common");
|
|
6
5
|
const debug = require('debug')('expo:babel:inline-manifest');
|
|
7
6
|
// Convert expo value to PWA value
|
|
@@ -29,18 +28,19 @@ const RESTRICTED_MANIFEST_FIELDS = [
|
|
|
29
28
|
'assetBundlePatterns',
|
|
30
29
|
];
|
|
31
30
|
function getExpoConstantsManifest(projectRoot) {
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
const config = getConfigMemo(projectRoot);
|
|
32
|
+
if (!config)
|
|
33
|
+
return null;
|
|
34
|
+
const manifest = applyWebDefaults(config);
|
|
34
35
|
for (const field of RESTRICTED_MANIFEST_FIELDS) {
|
|
35
36
|
delete manifest[field];
|
|
36
37
|
}
|
|
37
38
|
return manifest;
|
|
38
39
|
}
|
|
39
|
-
function applyWebDefaults(
|
|
40
|
+
function applyWebDefaults({ config, appName, webName }) {
|
|
41
|
+
const appJSON = config.exp;
|
|
40
42
|
// For RN CLI support
|
|
41
43
|
const { web: webManifest = {}, splash = {}, ios = {}, android = {} } = appJSON;
|
|
42
|
-
// rn-cli apps use a displayName value as well.
|
|
43
|
-
const { appName, webName } = (0, config_1.getNameFromConfig)(appJSON);
|
|
44
44
|
const languageISOCode = webManifest.lang;
|
|
45
45
|
const primaryColor = appJSON.primaryColor;
|
|
46
46
|
const description = appJSON.description;
|
|
@@ -97,18 +97,45 @@ function getExpoAppManifest(projectRoot) {
|
|
|
97
97
|
return process.env.APP_MANIFEST;
|
|
98
98
|
}
|
|
99
99
|
const exp = getExpoConstantsManifest(projectRoot);
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
if (exp) {
|
|
101
|
+
debug('public manifest', exp);
|
|
102
|
+
return JSON.stringify(exp);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
debug('public manifest is null. `expo/config` is not available');
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
102
108
|
}
|
|
103
|
-
let
|
|
109
|
+
let configMemo;
|
|
104
110
|
function getConfigMemo(projectRoot) {
|
|
105
|
-
if (
|
|
106
|
-
|
|
111
|
+
if (configMemo === undefined) {
|
|
112
|
+
let expoConfig;
|
|
113
|
+
try {
|
|
114
|
+
// This is an optional dependency. In practice, it will resolve in all Expo projects/apps
|
|
115
|
+
// since `expo` is a direct dependency in those. If `babel-preset-expo` is used independently
|
|
116
|
+
// this will fail and we won't return a config
|
|
117
|
+
expoConfig = require('expo/config');
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if ('code' in error && error.code === 'MODULE_NOT_FOUND') {
|
|
121
|
+
return (configMemo = null);
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
const { getConfig, getNameFromConfig } = expoConfig;
|
|
126
|
+
const config = getConfig(projectRoot, {
|
|
107
127
|
isPublicConfig: true,
|
|
108
128
|
skipSDKVersionRequirement: true,
|
|
109
129
|
});
|
|
130
|
+
// rn-cli apps use a displayName value as well.
|
|
131
|
+
const { appName, webName } = getNameFromConfig(config.exp);
|
|
132
|
+
configMemo = {
|
|
133
|
+
config,
|
|
134
|
+
appName,
|
|
135
|
+
webName,
|
|
136
|
+
};
|
|
110
137
|
}
|
|
111
|
-
return
|
|
138
|
+
return configMemo;
|
|
112
139
|
}
|
|
113
140
|
// Convert `process.env.APP_MANIFEST` to a modified web-specific variation of the app.json public manifest.
|
|
114
141
|
function expoInlineManifestPlugin(api) {
|
|
@@ -142,7 +169,9 @@ function expoInlineManifestPlugin(api) {
|
|
|
142
169
|
}) &&
|
|
143
170
|
!parent.parentPath.isAssignmentExpression()) {
|
|
144
171
|
const manifest = getExpoAppManifest(projectRoot);
|
|
145
|
-
|
|
172
|
+
if (manifest !== null) {
|
|
173
|
+
parent.replaceWith(t.stringLiteral(manifest));
|
|
174
|
+
}
|
|
146
175
|
}
|
|
147
176
|
},
|
|
148
177
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigAPI,
|
|
4
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
5
5
|
/**
|
|
6
6
|
* Inlines environment variables to configure the process:
|
|
7
7
|
*
|
|
@@ -10,11 +10,4 @@ import { ConfigAPI, types } from '@babel/core';
|
|
|
10
10
|
* EXPO_ROUTER_APP_ROOT
|
|
11
11
|
* EXPO_ROUTER_IMPORT_MODE
|
|
12
12
|
*/
|
|
13
|
-
export declare function expoRouterBabelPlugin(api: ConfigAPI &
|
|
14
|
-
types: typeof types;
|
|
15
|
-
}): {
|
|
16
|
-
name: string;
|
|
17
|
-
visitor: {
|
|
18
|
-
MemberExpression(path: any, state: any): void;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
13
|
+
export declare function expoRouterBabelPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -4,10 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.expoRouterBabelPlugin = expoRouterBabelPlugin;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright © 2024 650 Industries.
|
|
9
|
-
*/
|
|
10
|
-
const core_1 = require("@babel/core");
|
|
11
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
12
8
|
const resolve_from_1 = __importDefault(require("resolve-from"));
|
|
13
9
|
const common_1 = require("./common");
|
|
@@ -33,7 +29,7 @@ function expoRouterBabelPlugin(api) {
|
|
|
33
29
|
const asyncRoutes = api.caller(common_1.getAsyncRoutes);
|
|
34
30
|
const routerAbsoluteRoot = api.caller(common_1.getExpoRouterAbsoluteAppRoot);
|
|
35
31
|
function isFirstInAssign(path) {
|
|
36
|
-
return
|
|
32
|
+
return t.isAssignmentExpression(path.parent) && path.parent.left === path.node;
|
|
37
33
|
}
|
|
38
34
|
return {
|
|
39
35
|
name: 'expo-router',
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { ConfigAPI,
|
|
2
|
-
export declare function expoImportMetaTransformPluginFactory(pluginEnabled: boolean): (api: ConfigAPI &
|
|
3
|
-
types: typeof types;
|
|
4
|
-
}) => babel.PluginObj;
|
|
1
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
2
|
+
export declare function expoImportMetaTransformPluginFactory(pluginEnabled: boolean): (api: ConfigAPI & typeof import("@babel/core")) => PluginObj;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -11,6 +11,14 @@ const lazyImports_1 = require("./lazyImports");
|
|
|
11
11
|
const restricted_react_api_plugin_1 = require("./restricted-react-api-plugin");
|
|
12
12
|
const server_actions_plugin_1 = require("./server-actions-plugin");
|
|
13
13
|
const use_dom_directive_plugin_1 = require("./use-dom-directive-plugin");
|
|
14
|
+
// NOTE(@kitten): This shouldn't be higher than `expo/package.json`'s `@babel/runtime` version
|
|
15
|
+
// (the lowest version constraint we have).
|
|
16
|
+
// TODO(@kitten): This is a hotfix! In theory, we should pass an absolute runtime path
|
|
17
|
+
// and skip the internal resolution, which would mean we'd be able to guarantee a version here,
|
|
18
|
+
// but for now, we don't
|
|
19
|
+
// WARN: This does not reproduce in the expo/expo monorepo and we're not sure why. If you're changing this, run `expo export -p android` against this reproduction:
|
|
20
|
+
// - https://github.com/kitten/expo-bug-nested-async-generator-function-repro
|
|
21
|
+
const BABEL_RUNTIME_RANGE = '^7.20.0';
|
|
14
22
|
function getOptions(options, platform) {
|
|
15
23
|
const tag = platform === 'web' ? 'web' : 'native';
|
|
16
24
|
return {
|
|
@@ -200,7 +208,10 @@ function babelPresetExpo(api, options = {}) {
|
|
|
200
208
|
// Defaults to undefined, set to `true` to disable `@babel/plugin-transform-flow-strip-types`
|
|
201
209
|
disableFlowStripTypesTransform: platformOptions.disableFlowStripTypesTransform,
|
|
202
210
|
// Defaults to undefined, set to `false` to disable `@babel/plugin-transform-runtime`
|
|
203
|
-
|
|
211
|
+
// Passed on unchanged in most cases, except when `true` where we pass `BABEL_RUNTIME_RANGE` to avoid the 7.0.0-beta.0 default
|
|
212
|
+
enableBabelRuntime: platformOptions.enableBabelRuntime === true
|
|
213
|
+
? BABEL_RUNTIME_RANGE
|
|
214
|
+
: platformOptions.enableBabelRuntime,
|
|
204
215
|
// This reduces the amount of transforms required, as Hermes supports many modern language features.
|
|
205
216
|
unstable_transformProfile: platformOptions.unstable_transformProfile,
|
|
206
217
|
// Set true to disable `@babel/plugin-transform-react-jsx` and
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { ConfigAPI, PluginObj
|
|
2
|
-
export declare function expoInlineEnvVars(api: ConfigAPI &
|
|
3
|
-
types: typeof t;
|
|
4
|
-
}): PluginObj;
|
|
1
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
2
|
+
export declare function expoInlineEnvVars(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
package/build/inline-env-vars.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.expoInlineEnvVars = expoInlineEnvVars;
|
|
4
|
-
const core_1 = require("@babel/core");
|
|
5
4
|
const common_1 = require("./common");
|
|
6
5
|
const debug = require('debug')('expo:babel:env-vars');
|
|
7
6
|
function expoInlineEnvVars(api) {
|
|
7
|
+
const { types: t } = api;
|
|
8
8
|
const isProduction = api.caller(common_1.getIsProd);
|
|
9
9
|
function isFirstInAssign(path) {
|
|
10
|
-
return
|
|
10
|
+
return t.isAssignmentExpression(path.parent) && path.parent.left === path.node;
|
|
11
11
|
}
|
|
12
12
|
let addEnvImport;
|
|
13
13
|
const publicEnvVars = new Set();
|
|
14
14
|
return {
|
|
15
15
|
name: 'expo-inline-or-reference-env-vars',
|
|
16
16
|
pre(file) {
|
|
17
|
-
const addNamedImportOnce = (0, common_1.createAddNamedImportOnce)(
|
|
17
|
+
const addNamedImportOnce = (0, common_1.createAddNamedImportOnce)(t);
|
|
18
18
|
addEnvImport = () => {
|
|
19
19
|
return addNamedImportOnce(file.path, 'env', 'expo/virtual/env');
|
|
20
20
|
};
|
|
@@ -23,19 +23,18 @@ function expoInlineEnvVars(api) {
|
|
|
23
23
|
MemberExpression(path, state) {
|
|
24
24
|
const filename = state.filename;
|
|
25
25
|
if (path.get('object').matchesPattern('process.env')) {
|
|
26
|
-
// @ts-expect-error
|
|
27
26
|
const key = path.toComputedKey();
|
|
28
|
-
if (
|
|
27
|
+
if (t.isStringLiteral(key) &&
|
|
29
28
|
!isFirstInAssign(path) &&
|
|
30
29
|
key.value.startsWith('EXPO_PUBLIC_')) {
|
|
31
30
|
const envVar = key.value;
|
|
32
31
|
debug(`${isProduction ? 'Inlining' : 'Referencing'} environment variable in %s: %s`, filename, envVar);
|
|
33
32
|
publicEnvVars.add(envVar);
|
|
34
33
|
if (isProduction) {
|
|
35
|
-
path.replaceWith(
|
|
34
|
+
path.replaceWith(t.valueToNode(process.env[envVar]));
|
|
36
35
|
}
|
|
37
36
|
else {
|
|
38
|
-
path.replaceWith(
|
|
37
|
+
path.replaceWith(t.memberExpression(addEnvImport(), t.identifier(envVar)));
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
}
|
|
@@ -5,7 +5,5 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { ConfigAPI,
|
|
9
|
-
export default function minifyPlatformSelectPlugin({ types: t, }: ConfigAPI &
|
|
10
|
-
types: typeof types;
|
|
11
|
-
}): babel.PluginObj;
|
|
8
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
9
|
+
export default function minifyPlatformSelectPlugin({ types: t, }: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -8,15 +8,53 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.default = minifyPlatformSelectPlugin;
|
|
11
|
-
const core_1 = require("@babel/core");
|
|
12
11
|
function minifyPlatformSelectPlugin({ types: t, }) {
|
|
12
|
+
function isPlatformSelect(path) {
|
|
13
|
+
return (t.isMemberExpression(path.node.callee) &&
|
|
14
|
+
t.isIdentifier(path.node.callee.object) &&
|
|
15
|
+
t.isIdentifier(path.node.callee.property) &&
|
|
16
|
+
path.node.callee.object.name === 'Platform' &&
|
|
17
|
+
path.node.callee.property.name === 'select' &&
|
|
18
|
+
t.isObjectExpression(path.node.arguments[0]));
|
|
19
|
+
}
|
|
20
|
+
function findProperty(objectExpression, key, fallback) {
|
|
21
|
+
let value = null;
|
|
22
|
+
for (const p of objectExpression.properties) {
|
|
23
|
+
if (!t.isObjectProperty(p) && !t.isObjectMethod(p)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if ((t.isIdentifier(p.key) && p.key.name === key) ||
|
|
27
|
+
(t.isStringLiteral(p.key) && p.key.value === key)) {
|
|
28
|
+
if (t.isObjectProperty(p)) {
|
|
29
|
+
value = p.value;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
else if (t.isObjectMethod(p)) {
|
|
33
|
+
value = t.toExpression(p);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return value ?? fallback();
|
|
39
|
+
}
|
|
40
|
+
function hasStaticProperties(objectExpression) {
|
|
41
|
+
return objectExpression.properties.every((p) => {
|
|
42
|
+
if (('computed' in p && p.computed) || t.isSpreadElement(p)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (t.isObjectMethod(p) && p.kind !== 'method') {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return t.isIdentifier(p.key) || t.isStringLiteral(p.key);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
13
51
|
return {
|
|
14
52
|
visitor: {
|
|
15
53
|
CallExpression(path, state) {
|
|
16
54
|
const node = path.node;
|
|
17
55
|
const arg = node.arguments[0];
|
|
18
56
|
const opts = state.opts;
|
|
19
|
-
if (isPlatformSelect(path) &&
|
|
57
|
+
if (isPlatformSelect(path) && t.isObjectExpression(arg)) {
|
|
20
58
|
if (hasStaticProperties(arg)) {
|
|
21
59
|
let fallback;
|
|
22
60
|
if (opts.platform === 'web') {
|
|
@@ -32,42 +70,3 @@ function minifyPlatformSelectPlugin({ types: t, }) {
|
|
|
32
70
|
},
|
|
33
71
|
};
|
|
34
72
|
}
|
|
35
|
-
function isPlatformSelect(path) {
|
|
36
|
-
return (core_1.types.isMemberExpression(path.node.callee) &&
|
|
37
|
-
core_1.types.isIdentifier(path.node.callee.object) &&
|
|
38
|
-
core_1.types.isIdentifier(path.node.callee.property) &&
|
|
39
|
-
path.node.callee.object.name === 'Platform' &&
|
|
40
|
-
path.node.callee.property.name === 'select' &&
|
|
41
|
-
core_1.types.isObjectExpression(path.node.arguments[0]));
|
|
42
|
-
}
|
|
43
|
-
function findProperty(objectExpression, key, fallback) {
|
|
44
|
-
let value = null;
|
|
45
|
-
for (const p of objectExpression.properties) {
|
|
46
|
-
if (!core_1.types.isObjectProperty(p) && !core_1.types.isObjectMethod(p)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if ((core_1.types.isIdentifier(p.key) && p.key.name === key) ||
|
|
50
|
-
(core_1.types.isStringLiteral(p.key) && p.key.value === key)) {
|
|
51
|
-
if (core_1.types.isObjectProperty(p)) {
|
|
52
|
-
value = p.value;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
else if (core_1.types.isObjectMethod(p)) {
|
|
56
|
-
value = core_1.types.toExpression(p);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return value ?? fallback();
|
|
62
|
-
}
|
|
63
|
-
function hasStaticProperties(objectExpression) {
|
|
64
|
-
return objectExpression.properties.every((p) => {
|
|
65
|
-
if (('computed' in p && p.computed) || core_1.types.isSpreadElement(p)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if (core_1.types.isObjectMethod(p) && p.kind !== 'method') {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return core_1.types.isIdentifier(p.key) || core_1.types.isStringLiteral(p.key);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigAPI,
|
|
5
|
-
export declare function environmentRestrictedReactAPIsPlugin(api: ConfigAPI &
|
|
6
|
-
types: typeof types;
|
|
7
|
-
}): babel.PluginObj;
|
|
4
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
5
|
+
export declare function environmentRestrictedReactAPIsPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -7,7 +7,5 @@
|
|
|
7
7
|
*
|
|
8
8
|
* https://github.com/lubieowoce/tangle/blob/5229666fb317d0da9363363fc46dc542ba51e4f7/packages/babel-rsc/src/babel-rsc-actions.ts#L1C1-L909C25
|
|
9
9
|
*/
|
|
10
|
-
import { ConfigAPI,
|
|
11
|
-
export declare function reactServerActionsPlugin(api: ConfigAPI &
|
|
12
|
-
types: typeof types;
|
|
13
|
-
}): PluginObj<PluginPass>;
|
|
10
|
+
import type { ConfigAPI, PluginObj, PluginPass } from '@babel/core';
|
|
11
|
+
export declare function reactServerActionsPlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj<PluginPass>;
|
|
@@ -8,65 +8,31 @@
|
|
|
8
8
|
*
|
|
9
9
|
* https://github.com/lubieowoce/tangle/blob/5229666fb317d0da9363363fc46dc542ba51e4f7/packages/babel-rsc/src/babel-rsc-actions.ts#L1C1-L909C25
|
|
10
10
|
*/
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
-
var ownKeys = function(o) {
|
|
29
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
-
var ar = [];
|
|
31
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
-
return ar;
|
|
33
|
-
};
|
|
34
|
-
return ownKeys(o);
|
|
35
|
-
};
|
|
36
|
-
return function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
-
__setModuleDefault(result, mod);
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
})();
|
|
44
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
13
|
};
|
|
47
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
15
|
exports.reactServerActionsPlugin = reactServerActionsPlugin;
|
|
49
|
-
const core_1 = require("@babel/core");
|
|
50
|
-
const t = __importStar(require("@babel/types"));
|
|
51
16
|
const node_path_1 = require("node:path");
|
|
52
17
|
const node_url_1 = __importDefault(require("node:url"));
|
|
53
18
|
const common_1 = require("./common");
|
|
54
19
|
const debug = require('debug')('expo:babel:server-actions');
|
|
55
20
|
const LAZY_WRAPPER_VALUE_KEY = 'value';
|
|
56
|
-
// React doesn't like non-enumerable properties on serialized objects (see `isSimpleObject`),
|
|
57
|
-
// so we have to use closure scope for the cache (instead of a non-enumerable `this._cache`)
|
|
58
|
-
const _buildLazyWrapperHelper = (0, core_1.template)(`(thunk) => {
|
|
59
|
-
let cache;
|
|
60
|
-
return {
|
|
61
|
-
get ${LAZY_WRAPPER_VALUE_KEY}() {
|
|
62
|
-
return cache || (cache = thunk());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}`);
|
|
66
|
-
const buildLazyWrapperHelper = () => {
|
|
67
|
-
return _buildLazyWrapperHelper().expression;
|
|
68
|
-
};
|
|
69
21
|
function reactServerActionsPlugin(api) {
|
|
22
|
+
const { types: t } = api;
|
|
23
|
+
// React doesn't like non-enumerable properties on serialized objects (see `isSimpleObject`),
|
|
24
|
+
// so we have to use closure scope for the cache (instead of a non-enumerable `this._cache`)
|
|
25
|
+
const _buildLazyWrapperHelper = api.template(`(thunk) => {
|
|
26
|
+
let cache;
|
|
27
|
+
return {
|
|
28
|
+
get ${LAZY_WRAPPER_VALUE_KEY}() {
|
|
29
|
+
return cache || (cache = thunk());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}`);
|
|
33
|
+
const buildLazyWrapperHelper = () => {
|
|
34
|
+
return _buildLazyWrapperHelper().expression;
|
|
35
|
+
};
|
|
70
36
|
const possibleProjectRoot = api.caller(common_1.getPossibleProjectRoot);
|
|
71
37
|
let addReactImport;
|
|
72
38
|
let wrapBoundArgs;
|
|
@@ -153,7 +119,9 @@ function reactServerActionsPlugin(api) {
|
|
|
153
119
|
else {
|
|
154
120
|
// Fallback to inserting after the last import if no enclosing declaration is found
|
|
155
121
|
const programBody = moduleScope.path.get('body');
|
|
156
|
-
const lastImportPath =
|
|
122
|
+
const lastImportPath = (Array.isArray(programBody) ? programBody : [programBody]).findLast((statement) => {
|
|
123
|
+
return statement.isImportDeclaration();
|
|
124
|
+
});
|
|
157
125
|
[inserted] = lastImportPath.insertAfter(functionDeclaration);
|
|
158
126
|
moduleScope.registerBinding(bindingKind, inserted);
|
|
159
127
|
inserted.addComment('leading', ' hoisted action: ' + (getFnPathName(path) ?? '<anonymous>'), true);
|
|
@@ -179,6 +147,10 @@ function reactServerActionsPlugin(api) {
|
|
|
179
147
|
boundArgs,
|
|
180
148
|
]);
|
|
181
149
|
};
|
|
150
|
+
function hasUseServerDirective(path) {
|
|
151
|
+
const { body } = path.node;
|
|
152
|
+
return t.isBlockStatement(body) && body.directives.some((d) => d.value.value === 'use server');
|
|
153
|
+
}
|
|
182
154
|
return {
|
|
183
155
|
name: 'expo-server-actions',
|
|
184
156
|
pre(file) {
|
|
@@ -578,13 +550,6 @@ const isChildScope = ({ root, parent, child, }) => {
|
|
|
578
550
|
}
|
|
579
551
|
return false;
|
|
580
552
|
};
|
|
581
|
-
const findLast = (arr, predicate) => {
|
|
582
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
583
|
-
if (predicate(arr[i]))
|
|
584
|
-
return arr[i];
|
|
585
|
-
}
|
|
586
|
-
return undefined;
|
|
587
|
-
};
|
|
588
553
|
function findImmediatelyEnclosingDeclaration(path) {
|
|
589
554
|
let currentPath = path;
|
|
590
555
|
while (!currentPath.isProgram()) {
|
|
@@ -635,7 +600,3 @@ function assertExpoMetadata(metadata) {
|
|
|
635
600
|
throw new Error('Expected Babel state.file.metadata to be an object');
|
|
636
601
|
}
|
|
637
602
|
}
|
|
638
|
-
function hasUseServerDirective(path) {
|
|
639
|
-
const { body } = path.node;
|
|
640
|
-
return t.isBlockStatement(body) && body.directives.some((d) => d.value.value === 'use server');
|
|
641
|
-
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright © 2024 650 Industries.
|
|
3
3
|
*/
|
|
4
|
-
import { ConfigAPI,
|
|
5
|
-
export declare function expoUseDomDirectivePlugin(api: ConfigAPI &
|
|
6
|
-
types: typeof types;
|
|
7
|
-
}): babel.PluginObj;
|
|
4
|
+
import type { ConfigAPI, PluginObj } from '@babel/core';
|
|
5
|
+
export declare function expoUseDomDirectivePlugin(api: ConfigAPI & typeof import('@babel/core')): PluginObj;
|
|
@@ -4,16 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.expoUseDomDirectivePlugin = expoUseDomDirectivePlugin;
|
|
7
|
-
/**
|
|
8
|
-
* Copyright © 2024 650 Industries.
|
|
9
|
-
*/
|
|
10
|
-
const core_1 = require("@babel/core");
|
|
11
7
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
12
8
|
const node_path_1 = require("node:path");
|
|
13
9
|
const node_url_1 = __importDefault(require("node:url"));
|
|
14
10
|
const common_1 = require("./common");
|
|
15
11
|
function expoUseDomDirectivePlugin(api) {
|
|
16
|
-
const { types: t } = api;
|
|
12
|
+
const { template, types: t } = api;
|
|
17
13
|
const isProduction = api.caller(common_1.getIsProd);
|
|
18
14
|
const platform = api.caller((caller) => caller?.platform);
|
|
19
15
|
const projectRoot = api.caller(common_1.getPossibleProjectRoot);
|
|
@@ -107,7 +103,7 @@ function expoUseDomDirectivePlugin(api) {
|
|
|
107
103
|
export default _Expo_DOMProxyComponent;
|
|
108
104
|
`;
|
|
109
105
|
// Convert template to AST and push to body
|
|
110
|
-
const ast =
|
|
106
|
+
const ast = template.ast(proxyModuleTemplate);
|
|
111
107
|
const results = path.pushContainer('body', ast);
|
|
112
108
|
// Find and register the component declaration
|
|
113
109
|
results.forEach((nodePath) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -40,6 +40,15 @@
|
|
|
40
40
|
"eslintConfig": {
|
|
41
41
|
"extends": "universe/node"
|
|
42
42
|
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"react-refresh": ">=0.14.0 <1.0.0",
|
|
45
|
+
"expo": "*"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"expo": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
43
52
|
"dependencies": {
|
|
44
53
|
"@babel/helper-module-imports": "^7.25.9",
|
|
45
54
|
"@babel/plugin-proposal-decorators": "^7.12.9",
|
|
@@ -56,28 +65,21 @@
|
|
|
56
65
|
"@babel/plugin-transform-parameters": "^7.24.7",
|
|
57
66
|
"@babel/preset-react": "^7.22.15",
|
|
58
67
|
"@babel/preset-typescript": "^7.23.0",
|
|
59
|
-
"@react-native/babel-preset": "0.
|
|
60
|
-
"babel-plugin-react-
|
|
68
|
+
"@react-native/babel-preset": "0.81.0",
|
|
69
|
+
"babel-plugin-react-compiler": "^19.1.0-rc.2",
|
|
70
|
+
"babel-plugin-react-native-web": "~0.21.0",
|
|
61
71
|
"babel-plugin-transform-flow-enums": "^0.0.2",
|
|
62
72
|
"babel-plugin-syntax-hermes-parser": "^0.25.1",
|
|
63
73
|
"debug": "^4.3.4",
|
|
64
|
-
"react-refresh": "^0.14.2",
|
|
65
74
|
"resolve-from": "^5.0.0"
|
|
66
75
|
},
|
|
67
|
-
"peerDependencies": {
|
|
68
|
-
"babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250405"
|
|
69
|
-
},
|
|
70
|
-
"peerDependenciesMeta": {
|
|
71
|
-
"babel-plugin-react-compiler": {
|
|
72
|
-
"optional": true
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@babel/core": "^7.
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
}
|
|
77
|
+
"@babel/core": "^7.26.0",
|
|
78
|
+
"@types/babel__core": "^7.20.5",
|
|
79
|
+
"@expo/metro": "~0.1.1",
|
|
80
|
+
"expo-module-scripts": "^5.0.0",
|
|
81
|
+
"jest": "^29.2.1",
|
|
82
|
+
"react-refresh": "^0.14.2"
|
|
83
|
+
},
|
|
84
|
+
"gitHead": "cb7062e2c17d1fb09522834aaaac0e19b766df62"
|
|
83
85
|
}
|