babel-preset-expo 13.0.0-canary-20250402-161f57b → 13.0.0-canary-20250404-42b6263
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/index.js +24 -10
- package/build/server-actions-plugin.js +9 -2
- package/build/web-preset.js +1 -0
- package/package.json +4 -5
package/build/index.js
CHANGED
|
@@ -183,13 +183,8 @@ function babelPresetExpo(api, options = {}) {
|
|
|
183
183
|
}
|
|
184
184
|
return {
|
|
185
185
|
presets: [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
// specifically use the `@react-native/babel-preset` installed by this package (ex:
|
|
189
|
-
// `babel-preset-expo/node_modules/`). This way the preset will not change unintentionally.
|
|
190
|
-
// Reference: https://github.com/expo/expo/pull/4685#discussion_r307143920
|
|
191
|
-
isModernEngine ? require('./web-preset') : require('@react-native/babel-preset'),
|
|
192
|
-
{
|
|
186
|
+
(() => {
|
|
187
|
+
const presetOpts = {
|
|
193
188
|
// Defaults to undefined, set to `true` to disable `@babel/plugin-transform-flow-strip-types`
|
|
194
189
|
disableFlowStripTypesTransform: platformOptions.disableFlowStripTypesTransform,
|
|
195
190
|
// Defaults to undefined, set to `false` to disable `@babel/plugin-transform-runtime`
|
|
@@ -217,8 +212,28 @@ function babelPresetExpo(api, options = {}) {
|
|
|
217
212
|
: // Pass the option directly to `@react-native/babel-preset`, which in turn
|
|
218
213
|
// passes it to `babel-plugin-transform-modules-commonjs`
|
|
219
214
|
lazyImportsOption,
|
|
220
|
-
|
|
221
|
-
|
|
215
|
+
dev: isDev,
|
|
216
|
+
};
|
|
217
|
+
if (isModernEngine) {
|
|
218
|
+
return [require('./web-preset'), presetOpts];
|
|
219
|
+
}
|
|
220
|
+
// We use `require` here instead of directly using the package name because we want to
|
|
221
|
+
// specifically use the `@react-native/babel-preset` installed by this package (ex:
|
|
222
|
+
// `babel-preset-expo/node_modules/`). This way the preset will not change unintentionally.
|
|
223
|
+
// Reference: https://github.com/expo/expo/pull/4685#discussion_r307143920
|
|
224
|
+
const { getPreset } = require('@react-native/babel-preset');
|
|
225
|
+
// We need to customize the `@react-native/babel-preset` to ensure that the `@babel/plugin-transform-export-namespace-from`
|
|
226
|
+
// plugin is run after the TypeScript plugins. This is normally handled by the combination of standard `@babel/preset-env` and `@babel/preset-typescript` but React Native
|
|
227
|
+
// doesn't do that and we can't rely on Hermes spec compliance enough to use standard presets.
|
|
228
|
+
const babelPresetReactNativeEnv = getPreset(null, presetOpts);
|
|
229
|
+
// Add the `@babel/plugin-transform-export-namespace-from` plugin to the preset but ensure it runs after
|
|
230
|
+
// the TypeScript plugins to ensure namespace type exports (TypeScript 5.0+) `export type * as Types from './module';`
|
|
231
|
+
// are stripped before the transform. Otherwise the transform will extraneously include the types as syntax.
|
|
232
|
+
babelPresetReactNativeEnv.overrides.push({
|
|
233
|
+
plugins: [require('@babel/plugin-transform-export-namespace-from')],
|
|
234
|
+
});
|
|
235
|
+
return babelPresetReactNativeEnv;
|
|
236
|
+
})(),
|
|
222
237
|
// React support with similar options to Metro.
|
|
223
238
|
// We override this logic outside of the metro preset so we can add support for
|
|
224
239
|
// React 17 automatic JSX transformations.
|
|
@@ -251,7 +266,6 @@ function babelPresetExpo(api, options = {}) {
|
|
|
251
266
|
require('@babel/plugin-proposal-decorators'),
|
|
252
267
|
platformOptions.decorators ?? { legacy: true },
|
|
253
268
|
],
|
|
254
|
-
require('@babel/plugin-transform-export-namespace-from'),
|
|
255
269
|
// Automatically add `react-native-reanimated/plugin` when the package is installed.
|
|
256
270
|
// TODO: Move to be a customTransformOption.
|
|
257
271
|
(0, common_1.hasModule)('react-native-reanimated') &&
|
|
@@ -386,15 +386,18 @@ function reactServerActionsPlugin(api) {
|
|
|
386
386
|
if (!state.file.metadata.isModuleMarkedWithUseServerDirective) {
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
|
+
// Skip type-only exports (`export type { Foo } from '...'` or `export { type Foo }`)
|
|
390
|
+
if (path.node.exportKind === 'type') {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
389
393
|
// This can happen with `export {};` and TypeScript types.
|
|
390
394
|
if (!path.node.declaration && !path.node.specifiers.length) {
|
|
391
395
|
return;
|
|
392
396
|
}
|
|
393
|
-
const registerServerReferenceId = addReactImport();
|
|
394
397
|
const actionModuleId = getActionModuleId();
|
|
395
398
|
const createRegisterCall = (identifier, exported = identifier) => {
|
|
396
399
|
const exportedName = t.isIdentifier(exported) ? exported.name : exported.value;
|
|
397
|
-
const call = t.callExpression(
|
|
400
|
+
const call = t.callExpression(addReactImport(), [
|
|
398
401
|
identifier,
|
|
399
402
|
t.stringLiteral(actionModuleId),
|
|
400
403
|
t.stringLiteral(exportedName),
|
|
@@ -414,6 +417,10 @@ function reactServerActionsPlugin(api) {
|
|
|
414
417
|
throw path.buildCodeFrameError('Internal error while extracting server actions. Expected `export default variable;` to be extracted. (ExportDefaultSpecifier in ExportNamedDeclaration)');
|
|
415
418
|
}
|
|
416
419
|
else if (t.isExportSpecifier(specifier)) {
|
|
420
|
+
// Skip TypeScript type re-exports (e.g., `export { type Foo }`)
|
|
421
|
+
if (specifier.exportKind === 'type') {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
417
424
|
// `export { foo };`
|
|
418
425
|
// `export { foo as [bar|default] };`
|
|
419
426
|
const localName = specifier.local.name;
|
package/build/web-preset.js
CHANGED
|
@@ -20,6 +20,7 @@ const defaultPlugins = [
|
|
|
20
20
|
[require('@babel/plugin-transform-private-methods'), { loose }],
|
|
21
21
|
[require('@babel/plugin-transform-private-property-in-object'), { loose }],
|
|
22
22
|
[require('@babel/plugin-syntax-export-default-from')],
|
|
23
|
+
[require('@babel/plugin-transform-export-namespace-from')],
|
|
23
24
|
];
|
|
24
25
|
module.exports = function (babel, options) {
|
|
25
26
|
const extraPlugins = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "13.0.0-canary-
|
|
3
|
+
"version": "13.0.0-canary-20250404-42b6263",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/plugin-proposal-decorators": "^7.12.9",
|
|
46
46
|
"@babel/plugin-syntax-export-default-from": "^7.24.7",
|
|
47
47
|
"@babel/plugin-proposal-export-default-from": "^7.24.7",
|
|
48
|
-
"@babel/plugin-transform-export-namespace-from": "^7.
|
|
48
|
+
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
|
|
49
49
|
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
|
|
50
50
|
"@babel/plugin-transform-private-methods": "^7.24.7",
|
|
51
51
|
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
|
|
@@ -80,9 +80,8 @@
|
|
|
80
80
|
"@babel/traverse": "^7.9.0",
|
|
81
81
|
"@babel/types": "^7.9.0",
|
|
82
82
|
"babel-plugin-react-compiler": "^19.0.0-beta-9ee70a1-20241017",
|
|
83
|
-
"expo-module-scripts": "4.0.
|
|
83
|
+
"expo-module-scripts": "4.0.6-canary-20250404-42b6263",
|
|
84
84
|
"jest": "^29.2.1",
|
|
85
85
|
"react-compiler-runtime": "^19.0.0-beta-8a03594-20241020"
|
|
86
|
-
}
|
|
87
|
-
"gitHead": "161f57bb5f579c84f8fa0337ec596034e21760f6"
|
|
86
|
+
}
|
|
88
87
|
}
|