babel-preset-expo 0.0.1-canary-20240328-24ecc5e → 0.0.1-canary-20240405-cdfd9c1
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 +5 -3
- package/build/web-preset.d.ts +11 -0
- package/build/web-preset.js +73 -0
- package/package.json +5 -4
package/build/index.js
CHANGED
|
@@ -26,6 +26,7 @@ function babelPresetExpo(api, options = {}) {
|
|
|
26
26
|
const isFastRefreshEnabled = api.caller(common_1.getIsFastRefreshEnabled);
|
|
27
27
|
const baseUrl = api.caller(common_1.getBaseUrl);
|
|
28
28
|
const supportsStaticESM = api.caller((caller) => caller?.supportsStaticESM);
|
|
29
|
+
const isServerEnv = isServer || isReactServer;
|
|
29
30
|
// Unlike `isDev`, this will be `true` when the bundler is explicitly set to `production`,
|
|
30
31
|
// i.e. `false` when testing, development, or used with a bundler that doesn't specify the correct inputs.
|
|
31
32
|
const isProduction = api.caller(common_1.getIsProd);
|
|
@@ -62,13 +63,12 @@ function babelPresetExpo(api, options = {}) {
|
|
|
62
63
|
// @see https://github.com/expo/expo/pull/11960#issuecomment-887796455
|
|
63
64
|
extraPlugins.push([require('@babel/plugin-transform-object-rest-spread'), { loose: false }]);
|
|
64
65
|
}
|
|
65
|
-
else {
|
|
66
|
+
else if (!isServerEnv) {
|
|
66
67
|
// This is added back on hermes to ensure the react-jsx-dev plugin (`@babel/preset-react`) works as expected when
|
|
67
68
|
// JSX is used in a function body. This is technically not required in production, but we
|
|
68
69
|
// should retain the same behavior since it's hard to debug the differences.
|
|
69
70
|
extraPlugins.push(require('@babel/plugin-transform-parameters'));
|
|
70
71
|
}
|
|
71
|
-
const isServerEnv = isServer || isReactServer;
|
|
72
72
|
const inlines = {
|
|
73
73
|
'process.env.EXPO_OS': platform,
|
|
74
74
|
// 'typeof document': isServerEnv ? 'undefined' : 'object',
|
|
@@ -136,6 +136,8 @@ function babelPresetExpo(api, options = {}) {
|
|
|
136
136
|
},
|
|
137
137
|
]);
|
|
138
138
|
}
|
|
139
|
+
// Use the simpler babel preset for web and server environments (both web and native SSR).
|
|
140
|
+
const isModernEngine = platform === 'web' || isServerEnv;
|
|
139
141
|
return {
|
|
140
142
|
presets: [
|
|
141
143
|
[
|
|
@@ -143,7 +145,7 @@ function babelPresetExpo(api, options = {}) {
|
|
|
143
145
|
// specifically use the `@react-native/babel-preset` installed by this package (ex:
|
|
144
146
|
// `babel-preset-expo/node_modules/`). This way the preset will not change unintentionally.
|
|
145
147
|
// Reference: https://github.com/expo/expo/pull/4685#discussion_r307143920
|
|
146
|
-
require('@react-native/babel-preset'),
|
|
148
|
+
isModernEngine ? require('./web-preset') : require('@react-native/babel-preset'),
|
|
147
149
|
{
|
|
148
150
|
// Defaults to undefined, set to `true` to disable `@babel/plugin-transform-flow-strip-types`
|
|
149
151
|
disableFlowStripTypesTransform: platformOptions.disableFlowStripTypesTransform,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © 2024 650 Industries.
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* A fork of `@react-native/babel-preset` but with everything unrelated to web/ssr removed.
|
|
9
|
+
* https://github.com/facebook/react-native/blob/2af1da42ff517232f1309efed7565fe9ddbbac77/packages/react-native-babel-preset/src/configs/main.js#L1
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright © 2024 650 Industries.
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* A fork of `@react-native/babel-preset` but with everything unrelated to web/ssr removed.
|
|
10
|
+
* https://github.com/facebook/react-native/blob/2af1da42ff517232f1309efed7565fe9ddbbac77/packages/react-native-babel-preset/src/configs/main.js#L1
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
|
|
14
|
+
const loose = true;
|
|
15
|
+
const defaultPlugins = [
|
|
16
|
+
[require('@babel/plugin-syntax-flow')],
|
|
17
|
+
[require('babel-plugin-transform-flow-enums')],
|
|
18
|
+
[require('@babel/plugin-transform-private-methods'), { loose }],
|
|
19
|
+
[require('@babel/plugin-transform-private-property-in-object'), { loose }],
|
|
20
|
+
// [require('@babel/plugin-syntax-dynamic-import')],
|
|
21
|
+
[require('@babel/plugin-syntax-export-default-from')],
|
|
22
|
+
// [require('@babel/plugin-syntax-nullish-coalescing-operator')],
|
|
23
|
+
// [require('@babel/plugin-syntax-optional-chaining')],
|
|
24
|
+
// [require('@babel/plugin-transform-unicode-regex')],
|
|
25
|
+
];
|
|
26
|
+
module.exports = function (babel, options) {
|
|
27
|
+
const extraPlugins = [];
|
|
28
|
+
// NOTE: We also remove `@react-native/babel-plugin-codegen` since it doesn't seem needed on web.
|
|
29
|
+
if (!options || !options.disableImportExportTransform) {
|
|
30
|
+
extraPlugins.push([require('@babel/plugin-proposal-export-default-from')], [
|
|
31
|
+
require('@babel/plugin-transform-modules-commonjs'),
|
|
32
|
+
{
|
|
33
|
+
strict: false,
|
|
34
|
+
strictMode: false, // prevent "use strict" injections
|
|
35
|
+
lazy: options.lazyImportExportTransform,
|
|
36
|
+
allowTopLevelThis: true, // dont rewrite global `this` -> `undefined`
|
|
37
|
+
},
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
if (!options || options.enableBabelRuntime !== false) {
|
|
41
|
+
// Allows configuring a specific runtime version to optimize output
|
|
42
|
+
const isVersion = typeof options?.enableBabelRuntime === 'string';
|
|
43
|
+
extraPlugins.push([
|
|
44
|
+
require('@babel/plugin-transform-runtime'),
|
|
45
|
+
{
|
|
46
|
+
helpers: true,
|
|
47
|
+
regenerator: false,
|
|
48
|
+
...(isVersion && { version: options.enableBabelRuntime }),
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
comments: false,
|
|
54
|
+
compact: true,
|
|
55
|
+
presets: [
|
|
56
|
+
// TypeScript support
|
|
57
|
+
[require('@babel/preset-typescript'), { allowNamespaces: true }],
|
|
58
|
+
],
|
|
59
|
+
overrides: [
|
|
60
|
+
// the flow strip types plugin must go BEFORE class properties!
|
|
61
|
+
// there'll be a test case that fails if you don't.
|
|
62
|
+
{
|
|
63
|
+
plugins: [require('@babel/plugin-transform-flow-strip-types')],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
plugins: defaultPlugins,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
plugins: extraPlugins,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-preset-expo",
|
|
3
|
-
"version": "0.0.1-canary-
|
|
3
|
+
"version": "0.0.1-canary-20240405-cdfd9c1",
|
|
4
4
|
"description": "The Babel preset for Expo projects",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"files": [
|
|
@@ -45,15 +45,16 @@
|
|
|
45
45
|
"@babel/plugin-transform-export-namespace-from": "^7.22.11",
|
|
46
46
|
"@babel/plugin-transform-object-rest-spread": "^7.12.13",
|
|
47
47
|
"@babel/plugin-transform-parameters": "^7.22.15",
|
|
48
|
+
"@babel/preset-typescript": "^7.23.0",
|
|
48
49
|
"@babel/preset-react": "^7.22.15",
|
|
49
|
-
"@react-native/babel-preset": "~0.74.
|
|
50
|
+
"@react-native/babel-preset": "~0.74.77",
|
|
50
51
|
"babel-plugin-react-native-web": "~0.19.10",
|
|
51
52
|
"react-refresh": "0.14.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@babel/core": "^7.20.0",
|
|
55
|
-
"expo-module-scripts": "0.0.1-canary-
|
|
56
|
+
"expo-module-scripts": "0.0.1-canary-20240405-cdfd9c1",
|
|
56
57
|
"jest": "^29.2.1"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "cdfd9c1a0b8d8860b542edea45cb452f3eea5269"
|
|
59
60
|
}
|