@react-native/babel-preset 0.73.9 → 0.73.10
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/.babelrc +12 -0
- package/.prettierrc +8 -0
- package/BUCK +23 -0
- package/index.js.flow +12 -0
- package/package.json +28 -9
- package/scripts/build.js +114 -0
- package/{dist → src}/configs/hmr.js +2 -2
- package/src/configs/lazy-imports.js +91 -0
- package/src/configs/main.js +293 -0
- package/{dist → src}/index.js +3 -3
- package/{dist → src}/passthrough-syntax-plugins.js +3 -3
- package/dist/configs/lazy-imports.js +0 -91
- package/dist/configs/main.js +0 -226
package/.babelrc
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
"@babel/plugin-proposal-object-rest-spread",
|
|
4
|
+
"@babel/plugin-transform-async-to-generator",
|
|
5
|
+
"@babel/plugin-transform-destructuring",
|
|
6
|
+
"@babel/plugin-transform-flow-strip-types",
|
|
7
|
+
"@babel/plugin-syntax-dynamic-import",
|
|
8
|
+
"@babel/plugin-proposal-class-properties",
|
|
9
|
+
"@babel/plugin-proposal-nullish-coalescing-operator",
|
|
10
|
+
"@babel/plugin-proposal-optional-chaining"
|
|
11
|
+
]
|
|
12
|
+
}
|
package/.prettierrc
ADDED
package/BUCK
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
|
|
2
|
+
|
|
3
|
+
oncall("react_native")
|
|
4
|
+
|
|
5
|
+
yarn_workspace(
|
|
6
|
+
name = "yarn-workspace",
|
|
7
|
+
srcs = glob(
|
|
8
|
+
["src/**/*.js"],
|
|
9
|
+
exclude = [
|
|
10
|
+
"**/__fixtures__/**",
|
|
11
|
+
"**/__flowtests__/**",
|
|
12
|
+
"**/__mocks__/**",
|
|
13
|
+
"**/__server_snapshot_tests__/**",
|
|
14
|
+
"**/__tests__/**",
|
|
15
|
+
"**/.*",
|
|
16
|
+
"**/.*/**",
|
|
17
|
+
"**/.*/.*",
|
|
18
|
+
"**/*.xcodeproj/**",
|
|
19
|
+
"**/*.xcworkspace/**",
|
|
20
|
+
],
|
|
21
|
+
),
|
|
22
|
+
visibility = ["PUBLIC"],
|
|
23
|
+
)
|
package/index.js.flow
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
* @oncall react_native
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export * from './src';
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/babel-preset",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.10",
|
|
4
4
|
"description": "Babel preset for React Native applications",
|
|
5
|
-
"
|
|
6
|
-
".": "./dist/index.js",
|
|
7
|
-
"./package.json": "./package.json"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
5
|
+
"main": "src/index.js",
|
|
12
6
|
"repository": {
|
|
13
7
|
"type": "git",
|
|
14
8
|
"url": "git@github.com:facebook/react-native.git"
|
|
15
9
|
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepare-release": "test -d lib && mv src src.real && mv lib src",
|
|
12
|
+
"cleanup-release": "test ! -e lib && mv src lib && mv src.real src && rimraf lib",
|
|
13
|
+
"build-clean": "rimraf build && rimraf src.real",
|
|
14
|
+
"build": " node scripts/build.js --verbose",
|
|
15
|
+
"prepare": "yarn run build-clean && yarn run build && yarn run prepare-release",
|
|
16
|
+
"postpublish": "yarn run cleanup-release"
|
|
17
|
+
},
|
|
16
18
|
"keywords": [
|
|
17
19
|
"babel",
|
|
18
20
|
"preset",
|
|
@@ -57,10 +59,27 @@
|
|
|
57
59
|
"@babel/plugin-transform-typescript": "^7.5.0",
|
|
58
60
|
"@babel/plugin-transform-unicode-regex": "^7.0.0",
|
|
59
61
|
"@babel/template": "^7.0.0",
|
|
60
|
-
"@react-native/babel-plugin-codegen": "*",
|
|
61
62
|
"babel-plugin-transform-flow-enums": "^0.0.2",
|
|
62
63
|
"react-refresh": "^0.4.0"
|
|
63
64
|
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@babel/plugin-proposal-class-properties": "^7.18.0",
|
|
67
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.0",
|
|
68
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.0",
|
|
69
|
+
"@babel/plugin-proposal-optional-chaining": "^7.20.0",
|
|
70
|
+
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
|
|
71
|
+
"@babel/plugin-transform-async-to-generator": "^7.20.0",
|
|
72
|
+
"@babel/plugin-transform-destructuring": "^7.20.0",
|
|
73
|
+
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
|
|
74
|
+
"@babel/preset-env": "^7.20.0",
|
|
75
|
+
"chalk": "^4.0.0",
|
|
76
|
+
"glob": "^7.1.1",
|
|
77
|
+
"invariant": "^2.2.4",
|
|
78
|
+
"micromatch": "^4.0.4",
|
|
79
|
+
"mkdirp": "^0.5.1",
|
|
80
|
+
"prettier": "2.8.8",
|
|
81
|
+
"rimraf": "^3.0.2"
|
|
82
|
+
},
|
|
64
83
|
"peerDependencies": {
|
|
65
84
|
"@babel/core": "*"
|
|
66
85
|
},
|
package/scripts/build.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* script to build (transpile) files.
|
|
12
|
+
*
|
|
13
|
+
* Based off of the build script from Metro, and tweaked to run in just one
|
|
14
|
+
* package instead of in a monorepo. Just run `build.js` and the JS files in
|
|
15
|
+
* `src/` will be built in `lib/`, and the original source files will be copied
|
|
16
|
+
* over as `Example.js.flow`, so consumers of this module can still make use of
|
|
17
|
+
* type checking.
|
|
18
|
+
*
|
|
19
|
+
* Call this script with the `--verbose` flag to show the full output of this
|
|
20
|
+
* script.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
'use strict';
|
|
24
|
+
|
|
25
|
+
const babel = require('@babel/core');
|
|
26
|
+
const chalk = require('chalk');
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const glob = require('glob');
|
|
29
|
+
const micromatch = require('micromatch');
|
|
30
|
+
const mkdirp = require('mkdirp');
|
|
31
|
+
const path = require('path');
|
|
32
|
+
const prettier = require('prettier');
|
|
33
|
+
const prettierConfig = JSON.parse(
|
|
34
|
+
fs.readFileSync(path.resolve(__dirname, '..', '.prettierrc'), 'utf8'),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const SRC_DIR = 'src';
|
|
38
|
+
const BUILD_DIR = 'lib';
|
|
39
|
+
const JS_FILES_PATTERN = '**/*.js';
|
|
40
|
+
const IGNORE_PATTERN = '**/__tests__/**';
|
|
41
|
+
const PACKAGE_DIR = path.resolve(__dirname, '../');
|
|
42
|
+
|
|
43
|
+
const fixedWidth = str => {
|
|
44
|
+
const WIDTH = 80;
|
|
45
|
+
const strs = str.match(new RegExp(`(.{1,${WIDTH}})`, 'g')) || [str];
|
|
46
|
+
let lastString = strs[strs.length - 1];
|
|
47
|
+
if (lastString.length < WIDTH) {
|
|
48
|
+
lastString += Array(WIDTH - lastString.length).join(chalk.dim('.'));
|
|
49
|
+
}
|
|
50
|
+
return strs.slice(0, -1).concat(lastString).join('\n');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function getBuildPath(file, buildFolder) {
|
|
54
|
+
const pkgSrcPath = path.resolve(PACKAGE_DIR, SRC_DIR);
|
|
55
|
+
const pkgBuildPath = path.resolve(PACKAGE_DIR, BUILD_DIR);
|
|
56
|
+
const relativeToSrcPath = path.relative(pkgSrcPath, file);
|
|
57
|
+
return path.resolve(pkgBuildPath, relativeToSrcPath);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function buildFile(file, silent) {
|
|
61
|
+
const destPath = getBuildPath(file, BUILD_DIR);
|
|
62
|
+
|
|
63
|
+
mkdirp.sync(path.dirname(destPath));
|
|
64
|
+
if (micromatch.isMatch(file, IGNORE_PATTERN)) {
|
|
65
|
+
silent ||
|
|
66
|
+
process.stdout.write(
|
|
67
|
+
chalk.dim(' \u2022 ') +
|
|
68
|
+
path.relative(PACKAGE_DIR, file) +
|
|
69
|
+
' (ignore)\n',
|
|
70
|
+
);
|
|
71
|
+
} else if (!micromatch.isMatch(file, JS_FILES_PATTERN)) {
|
|
72
|
+
fs.createReadStream(file).pipe(fs.createWriteStream(destPath));
|
|
73
|
+
silent ||
|
|
74
|
+
process.stdout.write(
|
|
75
|
+
chalk.red(' \u2022 ') +
|
|
76
|
+
path.relative(PACKAGE_DIR, file) +
|
|
77
|
+
chalk.red(' \u21D2 ') +
|
|
78
|
+
path.relative(PACKAGE_DIR, destPath) +
|
|
79
|
+
' (copy)' +
|
|
80
|
+
'\n',
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
const transformed = prettier.format(
|
|
84
|
+
babel.transformFileSync(file, {}).code,
|
|
85
|
+
{
|
|
86
|
+
...prettierConfig,
|
|
87
|
+
parser: 'babel',
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
fs.writeFileSync(destPath, transformed);
|
|
91
|
+
const source = fs.readFileSync(file).toString('utf-8');
|
|
92
|
+
if (/@flow/.test(source)) {
|
|
93
|
+
fs.createReadStream(file).pipe(fs.createWriteStream(destPath + '.flow'));
|
|
94
|
+
}
|
|
95
|
+
silent ||
|
|
96
|
+
process.stdout.write(
|
|
97
|
+
chalk.green(' \u2022 ') +
|
|
98
|
+
path.relative(PACKAGE_DIR, file) +
|
|
99
|
+
chalk.green(' \u21D2 ') +
|
|
100
|
+
path.relative(PACKAGE_DIR, destPath) +
|
|
101
|
+
'\n',
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const srcDir = path.resolve(__dirname, '..', SRC_DIR);
|
|
107
|
+
const pattern = path.resolve(srcDir, '**/*');
|
|
108
|
+
const files = glob.sync(pattern, {nodir: true});
|
|
109
|
+
|
|
110
|
+
process.stdout.write(fixedWidth(`${path.basename(PACKAGE_DIR)}\n`));
|
|
111
|
+
|
|
112
|
+
files.forEach(file => buildFile(file, !process.argv.includes('--verbose')));
|
|
113
|
+
|
|
114
|
+
process.stdout.write(`[ ${chalk.green('OK')} ]\n`);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// This is the set of modules that React Native publicly exports and that we
|
|
12
|
+
// want to require lazily. Keep this list in sync with
|
|
13
|
+
// react-native/index.js (though having extra entries here is fairly harmless).
|
|
14
|
+
|
|
15
|
+
'use strict';
|
|
16
|
+
|
|
17
|
+
module.exports = new Set([
|
|
18
|
+
'AccessibilityInfo',
|
|
19
|
+
'ActivityIndicator',
|
|
20
|
+
'Button',
|
|
21
|
+
'DatePickerIOS',
|
|
22
|
+
'DrawerLayoutAndroid',
|
|
23
|
+
'FlatList',
|
|
24
|
+
'Image',
|
|
25
|
+
'ImageBackground',
|
|
26
|
+
'InputAccessoryView',
|
|
27
|
+
'KeyboardAvoidingView',
|
|
28
|
+
'Modal',
|
|
29
|
+
'Pressable',
|
|
30
|
+
'ProgressBarAndroid',
|
|
31
|
+
'ProgressViewIOS',
|
|
32
|
+
'SafeAreaView',
|
|
33
|
+
'ScrollView',
|
|
34
|
+
'SectionList',
|
|
35
|
+
'Slider',
|
|
36
|
+
'Switch',
|
|
37
|
+
'RefreshControl',
|
|
38
|
+
'StatusBar',
|
|
39
|
+
'Text',
|
|
40
|
+
'TextInput',
|
|
41
|
+
'Touchable',
|
|
42
|
+
'TouchableHighlight',
|
|
43
|
+
'TouchableNativeFeedback',
|
|
44
|
+
'TouchableOpacity',
|
|
45
|
+
'TouchableWithoutFeedback',
|
|
46
|
+
'View',
|
|
47
|
+
'VirtualizedList',
|
|
48
|
+
'VirtualizedSectionList',
|
|
49
|
+
// APIs
|
|
50
|
+
'ActionSheetIOS',
|
|
51
|
+
'Alert',
|
|
52
|
+
'Animated',
|
|
53
|
+
'Appearance',
|
|
54
|
+
'AppRegistry',
|
|
55
|
+
'AppState',
|
|
56
|
+
'AsyncStorage',
|
|
57
|
+
'BackHandler',
|
|
58
|
+
'Clipboard',
|
|
59
|
+
'DeviceInfo',
|
|
60
|
+
'Dimensions',
|
|
61
|
+
'Easing',
|
|
62
|
+
'ReactNative',
|
|
63
|
+
'I18nManager',
|
|
64
|
+
'InteractionManager',
|
|
65
|
+
'Keyboard',
|
|
66
|
+
'LayoutAnimation',
|
|
67
|
+
'Linking',
|
|
68
|
+
'LogBox',
|
|
69
|
+
'NativeEventEmitter',
|
|
70
|
+
'PanResponder',
|
|
71
|
+
'PermissionsAndroid',
|
|
72
|
+
'PixelRatio',
|
|
73
|
+
'PushNotificationIOS',
|
|
74
|
+
'Settings',
|
|
75
|
+
'Share',
|
|
76
|
+
'StyleSheet',
|
|
77
|
+
'Systrace',
|
|
78
|
+
'ToastAndroid',
|
|
79
|
+
'TVEventHandler',
|
|
80
|
+
'UIManager',
|
|
81
|
+
'ReactNative',
|
|
82
|
+
'UTFSequence',
|
|
83
|
+
'Vibration',
|
|
84
|
+
// Plugins
|
|
85
|
+
'RCTDeviceEventEmitter',
|
|
86
|
+
'RCTNativeAppEventEmitter',
|
|
87
|
+
'NativeModules',
|
|
88
|
+
'Platform',
|
|
89
|
+
'processColor',
|
|
90
|
+
'requireNativeComponent',
|
|
91
|
+
]);
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @oncall react_native
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) {
|
|
14
|
+
var keys = Object.keys(object);
|
|
15
|
+
if (Object.getOwnPropertySymbols) {
|
|
16
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
+
enumerableOnly &&
|
|
18
|
+
(symbols = symbols.filter(function (sym) {
|
|
19
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
20
|
+
})),
|
|
21
|
+
keys.push.apply(keys, symbols);
|
|
22
|
+
}
|
|
23
|
+
return keys;
|
|
24
|
+
}
|
|
25
|
+
function _objectSpread(target) {
|
|
26
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
27
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
28
|
+
i % 2
|
|
29
|
+
? ownKeys(Object(source), !0).forEach(function (key) {
|
|
30
|
+
_defineProperty(target, key, source[key]);
|
|
31
|
+
})
|
|
32
|
+
: Object.getOwnPropertyDescriptors
|
|
33
|
+
? Object.defineProperties(
|
|
34
|
+
target,
|
|
35
|
+
Object.getOwnPropertyDescriptors(source),
|
|
36
|
+
)
|
|
37
|
+
: ownKeys(Object(source)).forEach(function (key) {
|
|
38
|
+
Object.defineProperty(
|
|
39
|
+
target,
|
|
40
|
+
key,
|
|
41
|
+
Object.getOwnPropertyDescriptor(source, key),
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
47
|
+
function _defineProperty(obj, key, value) {
|
|
48
|
+
key = _toPropertyKey(key);
|
|
49
|
+
if (key in obj) {
|
|
50
|
+
Object.defineProperty(obj, key, {
|
|
51
|
+
value: value,
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
obj[key] = value;
|
|
58
|
+
}
|
|
59
|
+
return obj;
|
|
60
|
+
}
|
|
61
|
+
function _toPropertyKey(arg) {
|
|
62
|
+
var key = _toPrimitive(arg, 'string');
|
|
63
|
+
return typeof key === 'symbol' ? key : String(key);
|
|
64
|
+
}
|
|
65
|
+
function _toPrimitive(input, hint) {
|
|
66
|
+
if (typeof input !== 'object' || input === null) return input;
|
|
67
|
+
var prim = input[Symbol.toPrimitive];
|
|
68
|
+
if (prim !== undefined) {
|
|
69
|
+
var res = prim.call(input, hint || 'default');
|
|
70
|
+
if (typeof res !== 'object') return res;
|
|
71
|
+
throw new TypeError('@@toPrimitive must return a primitive value.');
|
|
72
|
+
}
|
|
73
|
+
return (hint === 'string' ? String : Number)(input);
|
|
74
|
+
}
|
|
75
|
+
const passthroughSyntaxPlugins = require('../passthrough-syntax-plugins');
|
|
76
|
+
const lazyImports = require('./lazy-imports');
|
|
77
|
+
function isTypeScriptSource(fileName) {
|
|
78
|
+
return !!fileName && fileName.endsWith('.ts');
|
|
79
|
+
}
|
|
80
|
+
function isTSXSource(fileName) {
|
|
81
|
+
return !!fileName && fileName.endsWith('.tsx');
|
|
82
|
+
}
|
|
83
|
+
const defaultPlugins = [
|
|
84
|
+
[require('@babel/plugin-syntax-flow')],
|
|
85
|
+
[require('babel-plugin-transform-flow-enums')],
|
|
86
|
+
[require('@babel/plugin-transform-block-scoping')],
|
|
87
|
+
[
|
|
88
|
+
require('@babel/plugin-proposal-class-properties'),
|
|
89
|
+
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
|
|
90
|
+
{
|
|
91
|
+
loose: true,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
[require('@babel/plugin-syntax-dynamic-import')],
|
|
95
|
+
[require('@babel/plugin-syntax-export-default-from')],
|
|
96
|
+
...passthroughSyntaxPlugins,
|
|
97
|
+
[require('@babel/plugin-transform-unicode-regex')],
|
|
98
|
+
];
|
|
99
|
+
const getPreset = (src, options) => {
|
|
100
|
+
const transformProfile =
|
|
101
|
+
(options && options.unstable_transformProfile) || 'default';
|
|
102
|
+
const isHermesStable = transformProfile === 'hermes-stable';
|
|
103
|
+
const isHermesCanary = transformProfile === 'hermes-canary';
|
|
104
|
+
const isHermes = isHermesStable || isHermesCanary;
|
|
105
|
+
const isNull = src == null;
|
|
106
|
+
const hasClass = isNull || src.indexOf('class') !== -1;
|
|
107
|
+
const extraPlugins = [];
|
|
108
|
+
if (!options.useTransformReactJSXExperimental) {
|
|
109
|
+
extraPlugins.push([
|
|
110
|
+
require('@babel/plugin-transform-react-jsx'),
|
|
111
|
+
{
|
|
112
|
+
runtime: 'automatic',
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
116
|
+
if (!options || !options.disableImportExportTransform) {
|
|
117
|
+
extraPlugins.push(
|
|
118
|
+
[require('@babel/plugin-proposal-export-default-from')],
|
|
119
|
+
[
|
|
120
|
+
require('@babel/plugin-transform-modules-commonjs'),
|
|
121
|
+
{
|
|
122
|
+
strict: false,
|
|
123
|
+
strictMode: false,
|
|
124
|
+
// prevent "use strict" injections
|
|
125
|
+
lazy:
|
|
126
|
+
options && options.lazyImportExportTransform != null
|
|
127
|
+
? options.lazyImportExportTransform
|
|
128
|
+
: importSpecifier => lazyImports.has(importSpecifier),
|
|
129
|
+
allowTopLevelThis: true, // dont rewrite global `this` -> `undefined`
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (hasClass) {
|
|
136
|
+
extraPlugins.push([require('@babel/plugin-transform-classes')]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// TODO(gaearon): put this back into '=>' indexOf bailout
|
|
140
|
+
// and patch react-refresh to not depend on this transform.
|
|
141
|
+
extraPlugins.push([require('@babel/plugin-transform-arrow-functions')]);
|
|
142
|
+
if (!isHermes) {
|
|
143
|
+
extraPlugins.push([require('@babel/plugin-transform-computed-properties')]);
|
|
144
|
+
extraPlugins.push([require('@babel/plugin-transform-parameters')]);
|
|
145
|
+
extraPlugins.push([
|
|
146
|
+
require('@babel/plugin-transform-shorthand-properties'),
|
|
147
|
+
]);
|
|
148
|
+
extraPlugins.push([
|
|
149
|
+
require('@babel/plugin-proposal-optional-catch-binding'),
|
|
150
|
+
]);
|
|
151
|
+
extraPlugins.push([require('@babel/plugin-transform-function-name')]);
|
|
152
|
+
extraPlugins.push([require('@babel/plugin-transform-literals')]);
|
|
153
|
+
extraPlugins.push([require('@babel/plugin-proposal-numeric-separator')]);
|
|
154
|
+
extraPlugins.push([require('@babel/plugin-transform-sticky-regex')]);
|
|
155
|
+
} else {
|
|
156
|
+
extraPlugins.push([
|
|
157
|
+
require('@babel/plugin-transform-named-capturing-groups-regex'),
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
if (!isHermesCanary) {
|
|
161
|
+
extraPlugins.push([
|
|
162
|
+
require('@babel/plugin-transform-destructuring'),
|
|
163
|
+
{
|
|
164
|
+
useBuiltIns: true,
|
|
165
|
+
},
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
if (!isHermes && (isNull || hasClass || src.indexOf('...') !== -1)) {
|
|
169
|
+
extraPlugins.push(
|
|
170
|
+
[require('@babel/plugin-transform-spread')],
|
|
171
|
+
[
|
|
172
|
+
require('@babel/plugin-proposal-object-rest-spread'),
|
|
173
|
+
// Assume no dependence on getters or evaluation order. See https://github.com/babel/babel/pull/11520
|
|
174
|
+
{
|
|
175
|
+
loose: true,
|
|
176
|
+
useBuiltIns: true,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (isNull || src.indexOf('async') !== -1) {
|
|
182
|
+
extraPlugins.push([
|
|
183
|
+
require('@babel/plugin-proposal-async-generator-functions'),
|
|
184
|
+
]);
|
|
185
|
+
extraPlugins.push([require('@babel/plugin-transform-async-to-generator')]);
|
|
186
|
+
}
|
|
187
|
+
if (
|
|
188
|
+
isNull ||
|
|
189
|
+
src.indexOf('React.createClass') !== -1 ||
|
|
190
|
+
src.indexOf('createReactClass') !== -1
|
|
191
|
+
) {
|
|
192
|
+
extraPlugins.push([require('@babel/plugin-transform-react-display-name')]);
|
|
193
|
+
}
|
|
194
|
+
if (!isHermes && (isNull || src.indexOf('?.') !== -1)) {
|
|
195
|
+
extraPlugins.push([
|
|
196
|
+
require('@babel/plugin-proposal-optional-chaining'),
|
|
197
|
+
{
|
|
198
|
+
loose: true,
|
|
199
|
+
},
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
if (!isHermes && (isNull || src.indexOf('??') !== -1)) {
|
|
203
|
+
extraPlugins.push([
|
|
204
|
+
require('@babel/plugin-proposal-nullish-coalescing-operator'),
|
|
205
|
+
{
|
|
206
|
+
loose: true,
|
|
207
|
+
},
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
if (options && options.dev && !options.useTransformReactJSXExperimental) {
|
|
211
|
+
extraPlugins.push([require('@babel/plugin-transform-react-jsx-source')]);
|
|
212
|
+
extraPlugins.push([require('@babel/plugin-transform-react-jsx-self')]);
|
|
213
|
+
}
|
|
214
|
+
if (!options || options.enableBabelRuntime !== false) {
|
|
215
|
+
// Allows configuring a specific runtime version to optimize output
|
|
216
|
+
const isVersion =
|
|
217
|
+
typeof (options === null || options === void 0
|
|
218
|
+
? void 0
|
|
219
|
+
: options.enableBabelRuntime) === 'string';
|
|
220
|
+
extraPlugins.push([
|
|
221
|
+
require('@babel/plugin-transform-runtime'),
|
|
222
|
+
_objectSpread(
|
|
223
|
+
{
|
|
224
|
+
helpers: true,
|
|
225
|
+
regenerator: !isHermes,
|
|
226
|
+
},
|
|
227
|
+
isVersion && {
|
|
228
|
+
version: options.enableBabelRuntime,
|
|
229
|
+
},
|
|
230
|
+
),
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
comments: false,
|
|
235
|
+
compact: true,
|
|
236
|
+
overrides: [
|
|
237
|
+
// the flow strip types plugin must go BEFORE class properties!
|
|
238
|
+
// there'll be a test case that fails if you don't.
|
|
239
|
+
{
|
|
240
|
+
plugins: [require('@babel/plugin-transform-flow-strip-types')],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
plugins: defaultPlugins,
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
test: isTypeScriptSource,
|
|
247
|
+
plugins: [
|
|
248
|
+
[
|
|
249
|
+
require('@babel/plugin-transform-typescript'),
|
|
250
|
+
{
|
|
251
|
+
isTSX: false,
|
|
252
|
+
allowNamespaces: true,
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
test: isTSXSource,
|
|
259
|
+
plugins: [
|
|
260
|
+
[
|
|
261
|
+
require('@babel/plugin-transform-typescript'),
|
|
262
|
+
{
|
|
263
|
+
isTSX: true,
|
|
264
|
+
allowNamespaces: true,
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
plugins: extraPlugins,
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
module.exports = options => {
|
|
276
|
+
if (options.withDevTools == null) {
|
|
277
|
+
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
|
|
278
|
+
if (!env || env === 'development') {
|
|
279
|
+
return getPreset(
|
|
280
|
+
null,
|
|
281
|
+
_objectSpread(
|
|
282
|
+
_objectSpread({}, options),
|
|
283
|
+
{},
|
|
284
|
+
{
|
|
285
|
+
dev: true,
|
|
286
|
+
},
|
|
287
|
+
),
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return getPreset(null, options);
|
|
292
|
+
};
|
|
293
|
+
module.exports.getPreset = getPreset;
|
package/{dist → src}/index.js
RENAMED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
'use strict';
|
|
12
12
|
|
|
13
|
-
const main = require(
|
|
13
|
+
const main = require('./configs/main');
|
|
14
14
|
module.exports = function (babel, options) {
|
|
15
15
|
return main(options);
|
|
16
16
|
};
|
|
17
17
|
module.exports.getPreset = main.getPreset;
|
|
18
|
-
module.exports.passthroughSyntaxPlugins = require(
|
|
18
|
+
module.exports.passthroughSyntaxPlugins = require('./passthrough-syntax-plugins');
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @oncall react_native
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
'use strict';
|
|
12
12
|
|
|
13
13
|
// This list of syntax plugins is used for two purposes:
|
|
14
14
|
// 1. Enabling experimental syntax features in the INPUT to the Metro Babel
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// 2. Enabling these same features in parser passes that consume the OUTPUT of
|
|
17
17
|
// the Metro Babel transformer.
|
|
18
18
|
const passthroughSyntaxPlugins = [
|
|
19
|
-
[require(
|
|
20
|
-
[require(
|
|
19
|
+
[require('@babel/plugin-syntax-nullish-coalescing-operator')],
|
|
20
|
+
[require('@babel/plugin-syntax-optional-chaining')],
|
|
21
21
|
];
|
|
22
22
|
module.exports = passthroughSyntaxPlugins;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// This is the set of modules that React Native publicly exports and that we
|
|
12
|
-
// want to require lazily. Keep this list in sync with
|
|
13
|
-
// react-native/index.js (though having extra entries here is fairly harmless).
|
|
14
|
-
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
module.exports = new Set([
|
|
18
|
-
"AccessibilityInfo",
|
|
19
|
-
"ActivityIndicator",
|
|
20
|
-
"Button",
|
|
21
|
-
"DatePickerIOS",
|
|
22
|
-
"DrawerLayoutAndroid",
|
|
23
|
-
"FlatList",
|
|
24
|
-
"Image",
|
|
25
|
-
"ImageBackground",
|
|
26
|
-
"InputAccessoryView",
|
|
27
|
-
"KeyboardAvoidingView",
|
|
28
|
-
"Modal",
|
|
29
|
-
"Pressable",
|
|
30
|
-
"ProgressBarAndroid",
|
|
31
|
-
"ProgressViewIOS",
|
|
32
|
-
"SafeAreaView",
|
|
33
|
-
"ScrollView",
|
|
34
|
-
"SectionList",
|
|
35
|
-
"Slider",
|
|
36
|
-
"Switch",
|
|
37
|
-
"RefreshControl",
|
|
38
|
-
"StatusBar",
|
|
39
|
-
"Text",
|
|
40
|
-
"TextInput",
|
|
41
|
-
"Touchable",
|
|
42
|
-
"TouchableHighlight",
|
|
43
|
-
"TouchableNativeFeedback",
|
|
44
|
-
"TouchableOpacity",
|
|
45
|
-
"TouchableWithoutFeedback",
|
|
46
|
-
"View",
|
|
47
|
-
"VirtualizedList",
|
|
48
|
-
"VirtualizedSectionList",
|
|
49
|
-
// APIs
|
|
50
|
-
"ActionSheetIOS",
|
|
51
|
-
"Alert",
|
|
52
|
-
"Animated",
|
|
53
|
-
"Appearance",
|
|
54
|
-
"AppRegistry",
|
|
55
|
-
"AppState",
|
|
56
|
-
"AsyncStorage",
|
|
57
|
-
"BackHandler",
|
|
58
|
-
"Clipboard",
|
|
59
|
-
"DeviceInfo",
|
|
60
|
-
"Dimensions",
|
|
61
|
-
"Easing",
|
|
62
|
-
"ReactNative",
|
|
63
|
-
"I18nManager",
|
|
64
|
-
"InteractionManager",
|
|
65
|
-
"Keyboard",
|
|
66
|
-
"LayoutAnimation",
|
|
67
|
-
"Linking",
|
|
68
|
-
"LogBox",
|
|
69
|
-
"NativeEventEmitter",
|
|
70
|
-
"PanResponder",
|
|
71
|
-
"PermissionsAndroid",
|
|
72
|
-
"PixelRatio",
|
|
73
|
-
"PushNotificationIOS",
|
|
74
|
-
"Settings",
|
|
75
|
-
"Share",
|
|
76
|
-
"StyleSheet",
|
|
77
|
-
"Systrace",
|
|
78
|
-
"ToastAndroid",
|
|
79
|
-
"TVEventHandler",
|
|
80
|
-
"UIManager",
|
|
81
|
-
"ReactNative",
|
|
82
|
-
"UTFSequence",
|
|
83
|
-
"Vibration",
|
|
84
|
-
// Plugins
|
|
85
|
-
"RCTDeviceEventEmitter",
|
|
86
|
-
"RCTNativeAppEventEmitter",
|
|
87
|
-
"NativeModules",
|
|
88
|
-
"Platform",
|
|
89
|
-
"processColor",
|
|
90
|
-
"requireNativeComponent",
|
|
91
|
-
]);
|
package/dist/configs/main.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @format
|
|
8
|
-
* @oncall react_native
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
"use strict";
|
|
12
|
-
|
|
13
|
-
const passthroughSyntaxPlugins = require("../passthrough-syntax-plugins");
|
|
14
|
-
const lazyImports = require("./lazy-imports");
|
|
15
|
-
function isTypeScriptSource(fileName) {
|
|
16
|
-
return !!fileName && fileName.endsWith(".ts");
|
|
17
|
-
}
|
|
18
|
-
function isTSXSource(fileName) {
|
|
19
|
-
return !!fileName && fileName.endsWith(".tsx");
|
|
20
|
-
}
|
|
21
|
-
const defaultPlugins = [
|
|
22
|
-
[require("@babel/plugin-syntax-flow")],
|
|
23
|
-
[require("babel-plugin-transform-flow-enums")],
|
|
24
|
-
[require("@babel/plugin-transform-block-scoping")],
|
|
25
|
-
[
|
|
26
|
-
require("@babel/plugin-proposal-class-properties"),
|
|
27
|
-
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
|
|
28
|
-
{
|
|
29
|
-
loose: true,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
[require("@babel/plugin-syntax-dynamic-import")],
|
|
33
|
-
[require("@babel/plugin-syntax-export-default-from")],
|
|
34
|
-
...passthroughSyntaxPlugins,
|
|
35
|
-
[require("@babel/plugin-transform-unicode-regex")],
|
|
36
|
-
];
|
|
37
|
-
const getPreset = (src, options) => {
|
|
38
|
-
const transformProfile =
|
|
39
|
-
(options && options.unstable_transformProfile) || "default";
|
|
40
|
-
const isHermesStable = transformProfile === "hermes-stable";
|
|
41
|
-
const isHermesCanary = transformProfile === "hermes-canary";
|
|
42
|
-
const isHermes = isHermesStable || isHermesCanary;
|
|
43
|
-
const isNull = src == null;
|
|
44
|
-
const hasClass = isNull || src.indexOf("class") !== -1;
|
|
45
|
-
const extraPlugins = [];
|
|
46
|
-
if (!options.useTransformReactJSXExperimental) {
|
|
47
|
-
extraPlugins.push([
|
|
48
|
-
require("@babel/plugin-transform-react-jsx"),
|
|
49
|
-
{
|
|
50
|
-
runtime: "automatic",
|
|
51
|
-
},
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
if (
|
|
55
|
-
!options.disableStaticViewConfigsCodegen &&
|
|
56
|
-
/\bcodegenNativeComponent</.test(src)
|
|
57
|
-
) {
|
|
58
|
-
extraPlugins.push([require("@react-native/babel-plugin-codegen")]);
|
|
59
|
-
}
|
|
60
|
-
if (!options || !options.disableImportExportTransform) {
|
|
61
|
-
extraPlugins.push(
|
|
62
|
-
[require("@babel/plugin-proposal-export-default-from")],
|
|
63
|
-
[
|
|
64
|
-
require("@babel/plugin-transform-modules-commonjs"),
|
|
65
|
-
{
|
|
66
|
-
strict: false,
|
|
67
|
-
strictMode: false,
|
|
68
|
-
// prevent "use strict" injections
|
|
69
|
-
lazy:
|
|
70
|
-
options && options.lazyImportExportTransform != null
|
|
71
|
-
? options.lazyImportExportTransform
|
|
72
|
-
: (importSpecifier) => lazyImports.has(importSpecifier),
|
|
73
|
-
allowTopLevelThis: true, // dont rewrite global `this` -> `undefined`
|
|
74
|
-
},
|
|
75
|
-
]
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (hasClass) {
|
|
80
|
-
extraPlugins.push([require("@babel/plugin-transform-classes")]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// TODO(gaearon): put this back into '=>' indexOf bailout
|
|
84
|
-
// and patch react-refresh to not depend on this transform.
|
|
85
|
-
extraPlugins.push([require("@babel/plugin-transform-arrow-functions")]);
|
|
86
|
-
if (!isHermes) {
|
|
87
|
-
extraPlugins.push([require("@babel/plugin-transform-computed-properties")]);
|
|
88
|
-
extraPlugins.push([require("@babel/plugin-transform-parameters")]);
|
|
89
|
-
extraPlugins.push([
|
|
90
|
-
require("@babel/plugin-transform-shorthand-properties"),
|
|
91
|
-
]);
|
|
92
|
-
extraPlugins.push([
|
|
93
|
-
require("@babel/plugin-proposal-optional-catch-binding"),
|
|
94
|
-
]);
|
|
95
|
-
extraPlugins.push([require("@babel/plugin-transform-function-name")]);
|
|
96
|
-
extraPlugins.push([require("@babel/plugin-transform-literals")]);
|
|
97
|
-
extraPlugins.push([require("@babel/plugin-proposal-numeric-separator")]);
|
|
98
|
-
extraPlugins.push([require("@babel/plugin-transform-sticky-regex")]);
|
|
99
|
-
} else {
|
|
100
|
-
extraPlugins.push([
|
|
101
|
-
require("@babel/plugin-transform-named-capturing-groups-regex"),
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
if (!isHermesCanary) {
|
|
105
|
-
extraPlugins.push([
|
|
106
|
-
require("@babel/plugin-transform-destructuring"),
|
|
107
|
-
{
|
|
108
|
-
useBuiltIns: true,
|
|
109
|
-
},
|
|
110
|
-
]);
|
|
111
|
-
}
|
|
112
|
-
if (!isHermes && (isNull || hasClass || src.indexOf("...") !== -1)) {
|
|
113
|
-
extraPlugins.push(
|
|
114
|
-
[require("@babel/plugin-transform-spread")],
|
|
115
|
-
[
|
|
116
|
-
require("@babel/plugin-proposal-object-rest-spread"),
|
|
117
|
-
// Assume no dependence on getters or evaluation order. See https://github.com/babel/babel/pull/11520
|
|
118
|
-
{
|
|
119
|
-
loose: true,
|
|
120
|
-
useBuiltIns: true,
|
|
121
|
-
},
|
|
122
|
-
]
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
if (isNull || src.indexOf("async") !== -1) {
|
|
126
|
-
extraPlugins.push([
|
|
127
|
-
require("@babel/plugin-proposal-async-generator-functions"),
|
|
128
|
-
]);
|
|
129
|
-
extraPlugins.push([require("@babel/plugin-transform-async-to-generator")]);
|
|
130
|
-
}
|
|
131
|
-
if (
|
|
132
|
-
isNull ||
|
|
133
|
-
src.indexOf("React.createClass") !== -1 ||
|
|
134
|
-
src.indexOf("createReactClass") !== -1
|
|
135
|
-
) {
|
|
136
|
-
extraPlugins.push([require("@babel/plugin-transform-react-display-name")]);
|
|
137
|
-
}
|
|
138
|
-
if (!isHermes && (isNull || src.indexOf("?.") !== -1)) {
|
|
139
|
-
extraPlugins.push([
|
|
140
|
-
require("@babel/plugin-proposal-optional-chaining"),
|
|
141
|
-
{
|
|
142
|
-
loose: true,
|
|
143
|
-
},
|
|
144
|
-
]);
|
|
145
|
-
}
|
|
146
|
-
if (!isHermes && (isNull || src.indexOf("??") !== -1)) {
|
|
147
|
-
extraPlugins.push([
|
|
148
|
-
require("@babel/plugin-proposal-nullish-coalescing-operator"),
|
|
149
|
-
{
|
|
150
|
-
loose: true,
|
|
151
|
-
},
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
154
|
-
if (options && options.dev && !options.useTransformReactJSXExperimental) {
|
|
155
|
-
extraPlugins.push([require("@babel/plugin-transform-react-jsx-source")]);
|
|
156
|
-
extraPlugins.push([require("@babel/plugin-transform-react-jsx-self")]);
|
|
157
|
-
}
|
|
158
|
-
if (!options || options.enableBabelRuntime !== false) {
|
|
159
|
-
// Allows configuring a specific runtime version to optimize output
|
|
160
|
-
const isVersion = typeof options?.enableBabelRuntime === "string";
|
|
161
|
-
extraPlugins.push([
|
|
162
|
-
require("@babel/plugin-transform-runtime"),
|
|
163
|
-
{
|
|
164
|
-
helpers: true,
|
|
165
|
-
regenerator: !isHermes,
|
|
166
|
-
...(isVersion && {
|
|
167
|
-
version: options.enableBabelRuntime,
|
|
168
|
-
}),
|
|
169
|
-
},
|
|
170
|
-
]);
|
|
171
|
-
}
|
|
172
|
-
return {
|
|
173
|
-
comments: false,
|
|
174
|
-
compact: true,
|
|
175
|
-
overrides: [
|
|
176
|
-
// the flow strip types plugin must go BEFORE class properties!
|
|
177
|
-
// there'll be a test case that fails if you don't.
|
|
178
|
-
{
|
|
179
|
-
plugins: [require("@babel/plugin-transform-flow-strip-types")],
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
plugins: defaultPlugins,
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
test: isTypeScriptSource,
|
|
186
|
-
plugins: [
|
|
187
|
-
[
|
|
188
|
-
require("@babel/plugin-transform-typescript"),
|
|
189
|
-
{
|
|
190
|
-
isTSX: false,
|
|
191
|
-
allowNamespaces: true,
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
test: isTSXSource,
|
|
198
|
-
plugins: [
|
|
199
|
-
[
|
|
200
|
-
require("@babel/plugin-transform-typescript"),
|
|
201
|
-
{
|
|
202
|
-
isTSX: true,
|
|
203
|
-
allowNamespaces: true,
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
],
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
plugins: extraPlugins,
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
module.exports = (options) => {
|
|
215
|
-
if (options.withDevTools == null) {
|
|
216
|
-
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
|
|
217
|
-
if (!env || env === "development") {
|
|
218
|
-
return getPreset(null, {
|
|
219
|
-
...options,
|
|
220
|
-
dev: true,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return getPreset(null, options);
|
|
225
|
-
};
|
|
226
|
-
module.exports.getPreset = getPreset;
|