[change] Remove inline requires

Replace CJS inline requires with top-level imports that will be removed via DCE
in production bundles.

Close #1895
This commit is contained in:
Francois Valdy
2021-02-04 22:18:47 +01:00
committed by Nicolas Gallagher
parent 4b8cd20aaa
commit 12532f67f2
2 changed files with 3 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
import ReactNativePropRegistry from './ReactNativePropRegistry';
import flattenStyle from './flattenStyle';
import validate from './validate';
const absoluteFillObject = {
position: 'absolute',
@@ -47,9 +48,7 @@ const StyleSheet = {
const result = {};
Object.keys(styles).forEach(key => {
if (process.env.NODE_ENV !== 'production') {
const validate = require('./validate');
const interopValidate = validate.default ? validate.default : validate;
interopValidate(key, styles);
validate(key, styles);
}
const id = styles[key] && ReactNativePropRegistry.register(styles[key]);
result[key] = id;

View File

@@ -13,6 +13,7 @@
import EventEmitter from './EventEmitter';
import EventEmitterWithHolding from './EventEmitterWithHolding';
import EventHolder from './EventHolder';
import EventValidator from './EventValidator';
import invariant from 'fbjs/lib/invariant';
import keyOf from 'fbjs/lib/keyOf';
@@ -121,7 +122,6 @@ const EventEmitterMixin = {
if (!this.__eventEmitter) {
let emitter = new EventEmitter();
if (__DEV__) {
const EventValidator = require('./EventValidator').default;
emitter = EventValidator.addValidation(emitter, this.__types);
}