mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-23 23:06:24 +00:00
Reduce babel junk in built files
This commit is contained in:
@@ -99,17 +99,13 @@ Please open an issue with a proposal for a new feature or refactoring before sta
|
||||
3. If you've changed APIs, update the documentation.
|
||||
4. Ensure the tests pass (`npm run test`).
|
||||
|
||||
You should see a pre-commit hook run before each commit. If it does not, you may need to reset you Git hookspath:
|
||||
|
||||
```
|
||||
git config --unset core.hookspath
|
||||
```
|
||||
You should see a pre-commit hook run before each commit.
|
||||
|
||||
You can now submit a pull request, referencing any issues it addresses.
|
||||
|
||||
Please try to keep your pull request focused in scope and avoid including unrelated commits.
|
||||
|
||||
After you have submitted your pull request, we'll try to get back to you as soon as possible. We may suggest some changes or improvements.
|
||||
After you have submitted your pull request, it's recommended that **you** perform the first code review. We'll try to get back to you as soon as possible and may suggest changes.
|
||||
|
||||
Thank you for contributing!
|
||||
|
||||
@@ -118,7 +114,7 @@ Thank you for contributing!
|
||||
To commit, publish, and push a final version:
|
||||
|
||||
```
|
||||
npm run release -- <version>
|
||||
npm run release -- <version> --opt=<opt-code>
|
||||
```
|
||||
|
||||
Release candidates or versions that you'd like to publish to npm, but do not want to produce a commit and push it to GitHub:
|
||||
|
||||
+34
-34
@@ -1,15 +1,22 @@
|
||||
module.exports = function (api) {
|
||||
if (api) {
|
||||
api.cache(true);
|
||||
}
|
||||
|
||||
let modules = false;
|
||||
|
||||
if (process.env.BABEL_ENV === 'commonjs' || process.env.NODE_ENV === 'test') {
|
||||
modules = 'commonjs';
|
||||
}
|
||||
const createConfig = ({ modules }) => {
|
||||
const plugins = [
|
||||
'@babel/plugin-transform-flow-strip-types',
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
|
||||
'@babel/plugin-proposal-nullish-coalescing-operator',
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
version: '7.18.6'
|
||||
}
|
||||
]
|
||||
].concat(modules ? ['babel-plugin-add-module-exports'] : []);
|
||||
|
||||
return {
|
||||
assumptions: {
|
||||
iterableIsArray: true
|
||||
},
|
||||
comments: true,
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
@@ -19,18 +26,12 @@ module.exports = function (api) {
|
||||
exclude: ['transform-typeof-symbol'],
|
||||
targets: {
|
||||
browsers: [
|
||||
'chrome 38',
|
||||
'android 4',
|
||||
'firefox 40',
|
||||
'ios_saf 7',
|
||||
'safari 7',
|
||||
'ie 10',
|
||||
'ie_mob 11',
|
||||
'edge 12',
|
||||
'opera 16',
|
||||
'op_mini 12',
|
||||
'and_uc 9',
|
||||
'and_chr 38'
|
||||
'chrome 49',
|
||||
'firefox 52',
|
||||
'ios_saf 11',
|
||||
'safari 11',
|
||||
'edge 79',
|
||||
'opera 36'
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -38,17 +39,16 @@ module.exports = function (api) {
|
||||
'@babel/preset-react',
|
||||
'@babel/preset-flow'
|
||||
],
|
||||
plugins: [
|
||||
'@babel/plugin-transform-flow-strip-types',
|
||||
['@babel/plugin-proposal-class-properties', { loose: true }],
|
||||
['@babel/plugin-proposal-object-rest-spread', { useBuiltIns: true }],
|
||||
'@babel/plugin-proposal-nullish-coalescing-operator',
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
version: '7.18.6'
|
||||
}
|
||||
]
|
||||
].concat(modules ? ['babel-plugin-add-module-exports'] : [])
|
||||
plugins: plugins
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = function (api) {
|
||||
if (api) {
|
||||
api.cache(true);
|
||||
}
|
||||
|
||||
return process.env.BABEL_ENV === 'commonjs' || process.env.NODE_ENV === 'test'
|
||||
? createConfig({ modules: 'commonjs' })
|
||||
: createConfig({ modules: false });
|
||||
};
|
||||
|
||||
+16
-13
@@ -23,19 +23,22 @@ import StyleSheet from '../StyleSheet';
|
||||
import TextAncestorContext from './TextAncestorContext';
|
||||
import { useLocaleContext, getLocaleDirection } from '../../modules/useLocale';
|
||||
|
||||
const forwardPropsList = {
|
||||
...forwardedProps.defaultProps,
|
||||
...forwardedProps.accessibilityProps,
|
||||
...forwardedProps.clickProps,
|
||||
...forwardedProps.focusProps,
|
||||
...forwardedProps.keyboardProps,
|
||||
...forwardedProps.mouseProps,
|
||||
...forwardedProps.touchProps,
|
||||
...forwardedProps.styleProps,
|
||||
href: true,
|
||||
lang: true,
|
||||
pointerEvents: true
|
||||
};
|
||||
const forwardPropsList = Object.assign(
|
||||
{},
|
||||
forwardedProps.defaultProps,
|
||||
forwardedProps.accessibilityProps,
|
||||
forwardedProps.clickProps,
|
||||
forwardedProps.focusProps,
|
||||
forwardedProps.keyboardProps,
|
||||
forwardedProps.mouseProps,
|
||||
forwardedProps.touchProps,
|
||||
forwardedProps.styleProps,
|
||||
{
|
||||
href: true,
|
||||
lang: true,
|
||||
pointerEvents: true
|
||||
}
|
||||
);
|
||||
|
||||
const pickProps = (props) => pick(props, forwardPropsList);
|
||||
|
||||
|
||||
+30
-27
@@ -47,33 +47,36 @@ const setSelection = (node, selection) => {
|
||||
}
|
||||
};
|
||||
|
||||
const forwardPropsList = {
|
||||
...forwardedProps.defaultProps,
|
||||
...forwardedProps.accessibilityProps,
|
||||
...forwardedProps.clickProps,
|
||||
...forwardedProps.focusProps,
|
||||
...forwardedProps.keyboardProps,
|
||||
...forwardedProps.mouseProps,
|
||||
...forwardedProps.touchProps,
|
||||
...forwardedProps.styleProps,
|
||||
autoCapitalize: true,
|
||||
autoComplete: true,
|
||||
autoCorrect: true,
|
||||
autoFocus: true,
|
||||
defaultValue: true,
|
||||
disabled: true,
|
||||
lang: true,
|
||||
maxLength: true,
|
||||
onChange: true,
|
||||
onScroll: true,
|
||||
placeholder: true,
|
||||
pointerEvents: true,
|
||||
readOnly: true,
|
||||
rows: true,
|
||||
spellCheck: true,
|
||||
value: true,
|
||||
type: true
|
||||
};
|
||||
const forwardPropsList = Object.assign(
|
||||
{},
|
||||
forwardedProps.defaultProps,
|
||||
forwardedProps.accessibilityProps,
|
||||
forwardedProps.clickProps,
|
||||
forwardedProps.focusProps,
|
||||
forwardedProps.keyboardProps,
|
||||
forwardedProps.mouseProps,
|
||||
forwardedProps.touchProps,
|
||||
forwardedProps.styleProps,
|
||||
{
|
||||
autoCapitalize: true,
|
||||
autoComplete: true,
|
||||
autoCorrect: true,
|
||||
autoFocus: true,
|
||||
defaultValue: true,
|
||||
disabled: true,
|
||||
lang: true,
|
||||
maxLength: true,
|
||||
onChange: true,
|
||||
onScroll: true,
|
||||
placeholder: true,
|
||||
pointerEvents: true,
|
||||
readOnly: true,
|
||||
rows: true,
|
||||
spellCheck: true,
|
||||
value: true,
|
||||
type: true
|
||||
}
|
||||
);
|
||||
|
||||
const pickProps = (props) => pick(props, forwardPropsList);
|
||||
|
||||
|
||||
+21
-15
@@ -23,21 +23,27 @@ import StyleSheet from '../StyleSheet';
|
||||
import TextAncestorContext from '../Text/TextAncestorContext';
|
||||
import { useLocaleContext, getLocaleDirection } from '../../modules/useLocale';
|
||||
|
||||
const forwardPropsList = {
|
||||
...forwardedProps.defaultProps,
|
||||
...forwardedProps.accessibilityProps,
|
||||
...forwardedProps.clickProps,
|
||||
...forwardedProps.focusProps,
|
||||
...forwardedProps.keyboardProps,
|
||||
...forwardedProps.mouseProps,
|
||||
...forwardedProps.touchProps,
|
||||
...forwardedProps.styleProps,
|
||||
href: true,
|
||||
lang: true,
|
||||
onScroll: true,
|
||||
onWheel: true,
|
||||
pointerEvents: true
|
||||
};
|
||||
const forwardPropsList = Object.assign(
|
||||
{},
|
||||
forwardedProps.defaultProps,
|
||||
forwardedProps.accessibilityProps,
|
||||
forwardedProps.clickProps,
|
||||
forwardedProps.defaultProps,
|
||||
forwardedProps.accessibilityProps,
|
||||
forwardedProps.clickProps,
|
||||
forwardedProps.focusProps,
|
||||
forwardedProps.keyboardProps,
|
||||
forwardedProps.mouseProps,
|
||||
forwardedProps.touchProps,
|
||||
forwardedProps.styleProps,
|
||||
{
|
||||
href: true,
|
||||
lang: true,
|
||||
onScroll: true,
|
||||
onWheel: true,
|
||||
pointerEvents: true
|
||||
}
|
||||
);
|
||||
|
||||
const pickProps = (props) => pick(props, forwardPropsList);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user