Browse Source

Use lodash submodules to reduce bundle size (#5734)

Import lodash sub modules
Pontus Abrahamsson 4 years ago
parent
commit
e53a9feb20

+ 2
- 2
e2e/ApplicationLifecycleTest.test.js View File

1
 const Utils = require('./Utils');
1
 const Utils = require('./Utils');
2
 const Android = require('./AndroidUtils');
2
 const Android = require('./AndroidUtils');
3
 const TestIDs = require('../playground/src/testIDs');
3
 const TestIDs = require('../playground/src/testIDs');
4
-const _ = require('lodash');
4
+const includes = require('lodash/includes');
5
 
5
 
6
 const { elementByLabel, elementById, sleep } = Utils;
6
 const { elementByLabel, elementById, sleep } = Utils;
7
-const IS_RELEASE = _.includes(process.argv, '--release');
7
+const IS_RELEASE = includes(process.argv, '--release');
8
 const KEY_CODE_R = 46;
8
 const KEY_CODE_R = 46;
9
 
9
 
10
 describe('application lifecycle test', () => {
10
 describe('application lifecycle test', () => {

+ 8
- 7
integration/env.test.js View File

1
-const _ = require('lodash');
1
+const eq = require('lodash/eq');
2
+const isEqual = require('lodash/isEqual');
2
 
3
 
3
 describe('testing that the environment is working properly', () => {
4
 describe('testing that the environment is working properly', () => {
4
   it('object spread', () => {
5
   it('object spread', () => {
14
   });
15
   });
15
 
16
 
16
   it('equality tests', () => {
17
   it('equality tests', () => {
17
-    expect(_.eq('hello', 'hello')).toBe(true);
18
-    expect(_.isEqual('hello', 'hello')).toBe(true);
18
+    expect(eq('hello', 'hello')).toBe(true);
19
+    expect(isEqual('hello', 'hello')).toBe(true);
19
 
20
 
20
-    expect(_.eq('hello', Object('hello'))).toBe(false);
21
-    expect(_.isEqual('hello', Object('hello'))).toBe(true);
21
+    expect(eq('hello', Object('hello'))).toBe(false);
22
+    expect(isEqual('hello', Object('hello'))).toBe(true);
22
 
23
 
23
     const a = {};
24
     const a = {};
24
     const b = {};
25
     const b = {};
25
 
26
 
26
-    expect(_.eq(a, b)).toBe(false);
27
-    expect(_.isEqual(a, b)).toBe(true);
27
+    expect(eq(a, b)).toBe(false);
28
+    expect(isEqual(a, b)).toBe(true);
28
   });
29
   });
29
 });
30
 });

+ 5
- 4
integration/redux/MyStore.js View File

1
 const redux = require('redux');
1
 const redux = require('redux');
2
-const _ = require('lodash');
2
+const merge = require('lodash/merge');
3
+const get = require('lodash/get');
3
 
4
 
4
 const initialState = {
5
 const initialState = {
5
   person: {
6
   person: {
10
 const reducer = (state = initialState, action) => {
11
 const reducer = (state = initialState, action) => {
11
   switch (action.type) {
12
   switch (action.type) {
12
     case 'redux.MyStore.setName': {
13
     case 'redux.MyStore.setName': {
13
-      return _.merge({}, state, { person: { name: action.name } });
14
+      return merge({}, state, { person: { name: action.name } });
14
     }
15
     }
15
     case 'redux.MyStore.setAge': {
16
     case 'redux.MyStore.setAge': {
16
-      return _.merge({}, state, { person: { age: action.age } });
17
+      return merge({}, state, { person: { age: action.age } });
17
     }
18
     }
18
     default: {
19
     default: {
19
       return state;
20
       return state;
23
 
24
 
24
 const selectors = {
25
 const selectors = {
25
   getName(state) {
26
   getName(state) {
26
-    return _.get(state, 'person.name');
27
+    return get(state, 'person.name');
27
   },
28
   },
28
 
29
 
29
   getAge(state) {
30
   getAge(state) {

+ 1
- 1
lib/src/Navigation.ts View File

1
-import { isArray } from 'lodash';
1
+import isArray from 'lodash/isArray';
2
 import { NativeCommandsSender } from './adapters/NativeCommandsSender';
2
 import { NativeCommandsSender } from './adapters/NativeCommandsSender';
3
 import { NativeEventsReceiver } from './adapters/NativeEventsReceiver';
3
 import { NativeEventsReceiver } from './adapters/NativeEventsReceiver';
4
 import { UniqueIdProvider } from './adapters/UniqueIdProvider';
4
 import { UniqueIdProvider } from './adapters/UniqueIdProvider';

+ 2
- 2
lib/src/adapters/UniqueIdProvider.ts View File

1
-import * as _ from 'lodash';
1
+import uniqueId from 'lodash/uniqueId';
2
 
2
 
3
 export class UniqueIdProvider {
3
 export class UniqueIdProvider {
4
   generate(prefix?: string): string {
4
   generate(prefix?: string): string {
5
-    return _.uniqueId(prefix);
5
+    return uniqueId(prefix);
6
   }
6
   }
7
 }
7
 }

+ 6
- 4
lib/src/commands/Commands.test.ts View File

1
-import * as _ from 'lodash';
1
+import forEach from 'lodash/forEach'
2
+import filter from 'lodash/filter'
3
+import invoke from 'lodash/invoke'
2
 import { mock, verify, instance, deepEqual, when, anything, anyString } from 'ts-mockito';
4
 import { mock, verify, instance, deepEqual, when, anything, anyString } from 'ts-mockito';
3
 
5
 
4
 import { LayoutTreeParser } from './LayoutTreeParser';
6
 import { LayoutTreeParser } from './LayoutTreeParser';
398
 
400
 
399
     function getAllMethodsOfUut() {
401
     function getAllMethodsOfUut() {
400
       const uutFns = Object.getOwnPropertyNames(Commands.prototype);
402
       const uutFns = Object.getOwnPropertyNames(Commands.prototype);
401
-      const methods = _.filter(uutFns, (fn) => fn !== 'constructor');
403
+      const methods = filter(uutFns, (fn) => fn !== 'constructor');
402
       expect(methods.length).toBeGreaterThan(1);
404
       expect(methods.length).toBeGreaterThan(1);
403
       return methods;
405
       return methods;
404
     }
406
     }
445
         dismissOverlay: { commandId: 'dismissOverlay+UNIQUE_ID', componentId: 'id' },
447
         dismissOverlay: { commandId: 'dismissOverlay+UNIQUE_ID', componentId: 'id' },
446
         getLaunchArgs: { commandId: 'getLaunchArgs+UNIQUE_ID' }
448
         getLaunchArgs: { commandId: 'getLaunchArgs+UNIQUE_ID' }
447
       };
449
       };
448
-      _.forEach(getAllMethodsOfUut(), (m) => {
450
+      forEach(getAllMethodsOfUut(), (m) => {
449
         it(`for ${m}`, () => {
451
         it(`for ${m}`, () => {
450
           expect(argsForMethodName).toHaveProperty(m);
452
           expect(argsForMethodName).toHaveProperty(m);
451
           expect(paramsForMethodName).toHaveProperty(m);
453
           expect(paramsForMethodName).toHaveProperty(m);
452
-          _.invoke(uut, m, ...argsForMethodName[m]);
454
+          invoke(uut, m, ...argsForMethodName[m]);
453
           expect(cb).toHaveBeenCalledTimes(1);
455
           expect(cb).toHaveBeenCalledTimes(1);
454
           expect(cb).toHaveBeenCalledWith(m, paramsForMethodName[m]);
456
           expect(cb).toHaveBeenCalledWith(m, paramsForMethodName[m]);
455
         });
457
         });

+ 12
- 11
lib/src/commands/Commands.ts View File

1
-import * as _ from 'lodash';
1
+import cloneDeep from 'lodash/cloneDeep'
2
+import map from 'lodash/map'
2
 import { CommandsObserver } from '../events/CommandsObserver';
3
 import { CommandsObserver } from '../events/CommandsObserver';
3
 import { NativeCommandsSender } from '../adapters/NativeCommandsSender';
4
 import { NativeCommandsSender } from '../adapters/NativeCommandsSender';
4
 import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
5
 import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
21
   ) {}
22
   ) {}
22
 
23
 
23
   public setRoot(simpleApi: LayoutRoot) {
24
   public setRoot(simpleApi: LayoutRoot) {
24
-    const input = _.cloneDeep(simpleApi);
25
+    const input = cloneDeep(simpleApi);
25
     const root = this.layoutTreeParser.parse(input.root);
26
     const root = this.layoutTreeParser.parse(input.root);
26
 
27
 
27
-    const modals = _.map(input.modals, (modal) => {
28
+    const modals = map(input.modals, (modal) => {
28
       return this.layoutTreeParser.parse(modal);
29
       return this.layoutTreeParser.parse(modal);
29
     });
30
     });
30
 
31
 
31
-    const overlays = _.map(input.overlays, (overlay) => {
32
+    const overlays = map(input.overlays, (overlay) => {
32
       return this.layoutTreeParser.parse(overlay);
33
       return this.layoutTreeParser.parse(overlay);
33
     });
34
     });
34
 
35
 
48
   }
49
   }
49
 
50
 
50
   public setDefaultOptions(options: Options) {
51
   public setDefaultOptions(options: Options) {
51
-    const input = _.cloneDeep(options);
52
+    const input = cloneDeep(options);
52
     this.optionsProcessor.processOptions(input);
53
     this.optionsProcessor.processOptions(input);
53
 
54
 
54
     this.nativeCommandsSender.setDefaultOptions(input);
55
     this.nativeCommandsSender.setDefaultOptions(input);
56
   }
57
   }
57
 
58
 
58
   public mergeOptions(componentId: string, options: Options) {
59
   public mergeOptions(componentId: string, options: Options) {
59
-    const input = _.cloneDeep(options);
60
+    const input = cloneDeep(options);
60
     this.optionsProcessor.processOptions(input);
61
     this.optionsProcessor.processOptions(input);
61
 
62
 
62
     this.nativeCommandsSender.mergeOptions(componentId, input);
63
     this.nativeCommandsSender.mergeOptions(componentId, input);
64
   }
65
   }
65
 
66
 
66
   public updateProps(componentId: string, props: object) {
67
   public updateProps(componentId: string, props: object) {
67
-    const input = _.cloneDeep(props);
68
+    const input = cloneDeep(props);
68
     this.store.updateProps(componentId, input);
69
     this.store.updateProps(componentId, input);
69
     this.commandsObserver.notify('updateProps', { componentId, props });
70
     this.commandsObserver.notify('updateProps', { componentId, props });
70
   }
71
   }
71
 
72
 
72
   public showModal(layout: Layout) {
73
   public showModal(layout: Layout) {
73
-    const layoutCloned = _.cloneDeep(layout);
74
+    const layoutCloned = cloneDeep(layout);
74
     const layoutNode = this.layoutTreeParser.parse(layoutCloned);
75
     const layoutNode = this.layoutTreeParser.parse(layoutCloned);
75
 
76
 
76
     const commandId = this.uniqueIdProvider.generate('showModal');
77
     const commandId = this.uniqueIdProvider.generate('showModal');
96
   }
97
   }
97
 
98
 
98
   public push(componentId: string, simpleApi: Layout) {
99
   public push(componentId: string, simpleApi: Layout) {
99
-    const input = _.cloneDeep(simpleApi);
100
+    const input = cloneDeep(simpleApi);
100
     const layout = this.layoutTreeParser.parse(input);
101
     const layout = this.layoutTreeParser.parse(input);
101
 
102
 
102
     const commandId = this.uniqueIdProvider.generate('push');
103
     const commandId = this.uniqueIdProvider.generate('push');
129
   }
130
   }
130
 
131
 
131
   public setStackRoot(componentId: string, children: Layout[]) {
132
   public setStackRoot(componentId: string, children: Layout[]) {
132
-    const input = _.map(_.cloneDeep(children), (simpleApi) => {
133
+    const input = map(cloneDeep(children), (simpleApi) => {
133
       const layout = this.layoutTreeParser.parse(simpleApi);
134
       const layout = this.layoutTreeParser.parse(simpleApi);
134
       return layout;
135
       return layout;
135
     });
136
     });
145
   }
146
   }
146
 
147
 
147
   public showOverlay(simpleApi: Layout) {
148
   public showOverlay(simpleApi: Layout) {
148
-    const input = _.cloneDeep(simpleApi);
149
+    const input = cloneDeep(simpleApi);
149
     const layout = this.layoutTreeParser.parse(input);
150
     const layout = this.layoutTreeParser.parse(input);
150
 
151
 
151
     const commandId = this.uniqueIdProvider.generate('showOverlay');
152
     const commandId = this.uniqueIdProvider.generate('showOverlay');

+ 4
- 3
lib/src/commands/LayoutTreeCrawler.ts View File

1
-import * as _ from 'lodash';
1
+import merge from 'lodash/merge'
2
+import isFunction from 'lodash/isFunction'
2
 import { LayoutType } from './LayoutType';
3
 import { LayoutType } from './LayoutType';
3
 import { OptionsProcessor } from './OptionsProcessor';
4
 import { OptionsProcessor } from './OptionsProcessor';
4
 import { Store } from '../components/Store';
5
 import { Store } from '../components/Store';
47
   }
48
   }
48
 
49
 
49
   private applyStaticOptions(node: LayoutNode) {
50
   private applyStaticOptions(node: LayoutNode) {
50
-    node.data.options = _.merge({}, this.staticOptionsIfPossible(node), node.data.options);
51
+    node.data.options = merge({}, this.staticOptionsIfPossible(node), node.data.options);
51
   }
52
   }
52
 
53
 
53
   private staticOptionsIfPossible(node: LayoutNode) {
54
   private staticOptionsIfPossible(node: LayoutNode) {
54
     const foundReactGenerator = this.store.getComponentClassForName(node.data.name!);
55
     const foundReactGenerator = this.store.getComponentClassForName(node.data.name!);
55
     const reactComponent = foundReactGenerator ? foundReactGenerator() : undefined;
56
     const reactComponent = foundReactGenerator ? foundReactGenerator() : undefined;
56
     if (reactComponent && this.isComponentWithOptions(reactComponent)) {
57
     if (reactComponent && this.isComponentWithOptions(reactComponent)) {
57
-      return _.isFunction(reactComponent.options) ? reactComponent.options(node.data.passProps || {}) : reactComponent.options;
58
+      return isFunction(reactComponent.options) ? reactComponent.options(node.data.passProps || {}) : reactComponent.options;
58
     }
59
     }
59
     return {};
60
     return {};
60
   }
61
   }

+ 4
- 4
lib/src/commands/LayoutTreeParser.test.ts View File

1
-import * as _ from 'lodash';
1
+import keys from 'lodash/keys';
2
 import { LayoutTreeParser } from './LayoutTreeParser';
2
 import { LayoutTreeParser } from './LayoutTreeParser';
3
 import { LayoutType } from './LayoutType';
3
 import { LayoutType } from './LayoutType';
4
 import { Options } from '../interfaces/Options';
4
 import { Options } from '../interfaces/Options';
89
 
89
 
90
     it('bottom tabs', () => {
90
     it('bottom tabs', () => {
91
       const result = uut.parse(LayoutExamples.bottomTabs);
91
       const result = uut.parse(LayoutExamples.bottomTabs);
92
-      expect(_.keys(result)).toEqual(['id', 'type', 'data', 'children']);
92
+      expect(keys(result)).toEqual(['id', 'type', 'data', 'children']);
93
       expect(result.id).toEqual('myUniqueId');
93
       expect(result.id).toEqual('myUniqueId');
94
       expect(result.type).toEqual(LayoutType.BottomTabs);
94
       expect(result.type).toEqual(LayoutType.BottomTabs);
95
       expect(result.data).toEqual({});
95
       expect(result.data).toEqual({});
101
 
101
 
102
     it('side menus', () => {
102
     it('side menus', () => {
103
       const result = uut.parse(LayoutExamples.sideMenu);
103
       const result = uut.parse(LayoutExamples.sideMenu);
104
-      expect(_.keys(result)).toEqual(['id', 'type', 'data', 'children']);
104
+      expect(keys(result)).toEqual(['id', 'type', 'data', 'children']);
105
       expect(result.id).toEqual('myUniqueId');
105
       expect(result.id).toEqual('myUniqueId');
106
       expect(result.type).toEqual(LayoutType.SideMenuRoot);
106
       expect(result.type).toEqual(LayoutType.SideMenuRoot);
107
       expect(result.data).toEqual({});
107
       expect(result.data).toEqual({});
119
 
119
 
120
     it('top tabs', () => {
120
     it('top tabs', () => {
121
       const result = uut.parse(LayoutExamples.topTabs);
121
       const result = uut.parse(LayoutExamples.topTabs);
122
-      expect(_.keys(result)).toEqual(['id', 'type', 'data', 'children']);
122
+      expect(keys(result)).toEqual(['id', 'type', 'data', 'children']);
123
       expect(result.id).toEqual('myUniqueId');
123
       expect(result.id).toEqual('myUniqueId');
124
       expect(result.type).toEqual(LayoutType.TopTabs);
124
       expect(result.type).toEqual(LayoutType.TopTabs);
125
       expect(result.data).toEqual({ options: LayoutExamples.options });
125
       expect(result.data).toEqual({ options: LayoutExamples.options });

+ 15
- 11
lib/src/commands/OptionsProcessor.ts View File

1
-import * as _ from 'lodash';
1
+import isEqual from 'lodash/isEqual'
2
+import isObject from 'lodash/isObject'
3
+import isArray from 'lodash/isArray'
4
+import endsWith from 'lodash/endsWith'
5
+import forEach from 'lodash/forEach'
2
 
6
 
3
 import { Store } from '../components/Store';
7
 import { Store } from '../components/Store';
4
 import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
8
 import { UniqueIdProvider } from '../adapters/UniqueIdProvider';
19
   }
23
   }
20
 
24
 
21
   private processObject(objectToProcess: object) {
25
   private processObject(objectToProcess: object) {
22
-    _.forEach(objectToProcess, (value, key) => {
26
+    forEach(objectToProcess, (value, key) => {
23
       this.processColor(key, value, objectToProcess);
27
       this.processColor(key, value, objectToProcess);
24
 
28
 
25
       if (!value) {
29
       if (!value) {
30
       this.processImage(key, value, objectToProcess);
34
       this.processImage(key, value, objectToProcess);
31
       this.processButtonsPassProps(key, value);
35
       this.processButtonsPassProps(key, value);
32
 
36
 
33
-      if (!_.isEqual(key, 'passProps') && (_.isObject(value) || _.isArray(value))) {
37
+      if (!isEqual(key, 'passProps') && (isObject(value) || isArray(value))) {
34
         this.processObject(value);
38
         this.processObject(value);
35
       }
39
       }
36
     });
40
     });
37
   }
41
   }
38
 
42
 
39
   private processColor(key: string, value: any, options: Record<string, any>) {
43
   private processColor(key: string, value: any, options: Record<string, any>) {
40
-    if (_.isEqual(key, 'color') || _.endsWith(key, 'Color')) {
44
+    if (isEqual(key, 'color') || endsWith(key, 'Color')) {
41
       options[key] = value === null ? 'NoColor' : this.colorService.toNativeColor(value);
45
       options[key] = value === null ? 'NoColor' : this.colorService.toNativeColor(value);
42
     }
46
     }
43
   }
47
   }
44
 
48
 
45
   private processImage(key: string, value: any, options: Record<string, any>) {
49
   private processImage(key: string, value: any, options: Record<string, any>) {
46
     if (
50
     if (
47
-      _.isEqual(key, 'icon') ||
48
-      _.isEqual(key, 'image') ||
49
-      _.endsWith(key, 'Icon') ||
50
-      _.endsWith(key, 'Image')
51
+      isEqual(key, 'icon') ||
52
+      isEqual(key, 'image') ||
53
+      endsWith(key, 'Icon') ||
54
+      endsWith(key, 'Image')
51
     ) {
55
     ) {
52
       options[key] = this.assetService.resolveFromRequire(value);
56
       options[key] = this.assetService.resolveFromRequire(value);
53
     }
57
     }
54
   }
58
   }
55
 
59
 
56
   private processButtonsPassProps(key: string, value: any) {
60
   private processButtonsPassProps(key: string, value: any) {
57
-    if (_.endsWith(key, 'Buttons')) {
58
-      _.forEach(value, (button) => {
61
+    if (endsWith(key, 'Buttons')) {
62
+      forEach(value, (button) => {
59
         if (button.passProps && button.id) {
63
         if (button.passProps && button.id) {
60
           this.store.updateProps(button.id, button.passProps);
64
           this.store.updateProps(button.id, button.passProps);
61
           button.passProps = undefined;
65
           button.passProps = undefined;
65
   }
69
   }
66
 
70
 
67
   private processComponent(key: string, value: any, options: Record<string, any>) {
71
   private processComponent(key: string, value: any, options: Record<string, any>) {
68
-    if (_.isEqual(key, 'component')) {
72
+    if (isEqual(key, 'component')) {
69
       value.componentId = value.id ? value.id : this.uniqueIdProvider.generate('CustomComponent');
73
       value.componentId = value.id ? value.id : this.uniqueIdProvider.generate('CustomComponent');
70
       if (value.passProps) {
74
       if (value.passProps) {
71
         this.store.updateProps(value.componentId, value.passProps);
75
         this.store.updateProps(value.componentId, value.passProps);

+ 3
- 3
lib/src/components/ComponentWrapper.tsx View File

1
 import * as React from 'react';
1
 import * as React from 'react';
2
 import { ComponentProvider } from 'react-native';
2
 import { ComponentProvider } from 'react-native';
3
-import * as  _ from 'lodash';
3
+import merge from 'lodash/merge'
4
 import { polyfill } from 'react-lifecycles-compat';
4
 import { polyfill } from 'react-lifecycles-compat';
5
 import hoistNonReactStatics = require('hoist-non-react-statics');
5
 import hoistNonReactStatics = require('hoist-non-react-statics');
6
 
6
 
28
     class WrappedComponent extends React.Component<HocProps, HocState> {
28
     class WrappedComponent extends React.Component<HocProps, HocState> {
29
       static getDerivedStateFromProps(nextProps: any, prevState: HocState) {
29
       static getDerivedStateFromProps(nextProps: any, prevState: HocState) {
30
         return {
30
         return {
31
-          allProps: _.merge({}, nextProps, store.getPropsForId(prevState.componentId))
31
+          allProps: merge({}, nextProps, store.getPropsForId(prevState.componentId))
32
         };
32
         };
33
       }
33
       }
34
 
34
 
43
       }
43
       }
44
 
44
 
45
       public setProps(newProps: any) {
45
       public setProps(newProps: any) {
46
-        this.setState({allProps: newProps});
46
+        this.setState({ allProps: newProps });
47
       }
47
       }
48
 
48
 
49
       componentWillUnmount() {
49
       componentWillUnmount() {

+ 11
- 7
lib/src/events/ComponentEventsObserver.ts View File

1
-import * as _ from 'lodash';
1
+import isString from 'lodash/isString'
2
+import isNil from 'lodash/isNil'
3
+import uniqueId from 'lodash/uniqueId'
4
+import unset from 'lodash/unset'
5
+import forEach from 'lodash/forEach'
2
 import { EventSubscription } from '../interfaces/EventSubscription';
6
 import { EventSubscription } from '../interfaces/EventSubscription';
3
 import {
7
 import {
4
   ComponentDidAppearEvent,
8
   ComponentDidAppearEvent,
47
   public bindComponent(component: React.Component<any>, componentId?: string): EventSubscription {
51
   public bindComponent(component: React.Component<any>, componentId?: string): EventSubscription {
48
     const computedComponentId = componentId || component.props.componentId;
52
     const computedComponentId = componentId || component.props.componentId;
49
 
53
 
50
-    if (!_.isString(computedComponentId)) {
54
+    if (!isString(computedComponentId)) {
51
       throw new Error(`bindComponent expects a component with a componentId in props or a componentId as the second argument`);
55
       throw new Error(`bindComponent expects a component with a componentId in props or a componentId as the second argument`);
52
     }
56
     }
53
-    if (_.isNil(this.listeners[computedComponentId])) {
57
+    if (isNil(this.listeners[computedComponentId])) {
54
       this.listeners[computedComponentId] = {};
58
       this.listeners[computedComponentId] = {};
55
     }
59
     }
56
-    const key = _.uniqueId();
60
+    const key = uniqueId();
57
     this.listeners[computedComponentId][key] = component;
61
     this.listeners[computedComponentId][key] = component;
58
 
62
 
59
-    return { remove: () => _.unset(this.listeners[computedComponentId], key) };
63
+    return { remove: () => unset(this.listeners[computedComponentId], key) };
60
   }
64
   }
61
 
65
 
62
   public unmounted(componentId: string) {
66
   public unmounted(componentId: string) {
63
-    _.unset(this.listeners, componentId);
67
+    unset(this.listeners, componentId);
64
   }
68
   }
65
 
69
 
66
   notifyComponentDidAppear(event: ComponentDidAppearEvent) {
70
   notifyComponentDidAppear(event: ComponentDidAppearEvent) {
93
   }
97
   }
94
 
98
 
95
   private triggerOnAllListenersByComponentId(event: ComponentEvent, method: string) {
99
   private triggerOnAllListenersByComponentId(event: ComponentEvent, method: string) {
96
-    _.forEach(this.listeners[event.componentId], (component) => {
100
+    forEach(this.listeners[event.componentId], (component) => {
97
       if (component && component[method]) {
101
       if (component && component[method]) {
98
         component[method](event);
102
         component[method](event);
99
       }
103
       }

+ 8
- 7
package.json View File

58
   },
58
   },
59
   "devDependencies": {
59
   "devDependencies": {
60
     "@babel/core": "7.6.4",
60
     "@babel/core": "7.6.4",
61
-    "@babel/types": "7.6.x",
62
     "@babel/plugin-proposal-export-default-from": "7.2.0",
61
     "@babel/plugin-proposal-export-default-from": "7.2.0",
63
     "@babel/plugin-proposal-export-namespace-from": "7.2.0",
62
     "@babel/plugin-proposal-export-namespace-from": "7.2.0",
64
-    "@types/hoist-non-react-statics": "^3.0.1",
63
+    "@babel/types": "7.6.x",
65
     "@react-native-community/eslint-config": "0.0.3",
64
     "@react-native-community/eslint-config": "0.0.3",
66
-    "babel-jest": "24.9.x",
65
+    "@types/hoist-non-react-statics": "^3.0.1",
67
     "@types/jest": "24.x.x",
66
     "@types/jest": "24.x.x",
68
-    "@types/lodash": "4.x.x",
67
+    "@types/lodash": "^4.14.149",
69
     "@types/react": "16.x.x",
68
     "@types/react": "16.x.x",
70
     "@types/react-native": "0.57.7",
69
     "@types/react-native": "0.57.7",
71
     "@types/react-test-renderer": "16.x.x",
70
     "@types/react-test-renderer": "16.x.x",
71
+    "babel-jest": "24.9.x",
72
     "detox": "14.x.x",
72
     "detox": "14.x.x",
73
-    "react-native-ui-lib": "3.24.2",
74
     "handlebars": "4.x.x",
73
     "handlebars": "4.x.x",
75
     "jest": "24.9.x",
74
     "jest": "24.9.x",
75
+    "lodash": "^4.17.15",
76
     "metro-react-native-babel-preset": "0.57.x",
76
     "metro-react-native-babel-preset": "0.57.x",
77
     "react": "16.9.0",
77
     "react": "16.9.0",
78
     "react-native": "0.61.4",
78
     "react-native": "0.61.4",
79
+    "react-native-keyboard-tracking-view": "5.x.x",
79
     "react-native-typescript-transformer": "1.2.12",
80
     "react-native-typescript-transformer": "1.2.12",
81
+    "react-native-ui-lib": "3.24.2",
80
     "react-native-view-overflow": "0.0.4",
82
     "react-native-view-overflow": "0.0.4",
81
-    "react-native-keyboard-tracking-view": "5.x.x",
82
     "react-redux": "5.x.x",
83
     "react-redux": "5.x.x",
83
     "react-test-renderer": "16.9.x",
84
     "react-test-renderer": "16.9.x",
84
     "redux": "3.x.x",
85
     "redux": "3.x.x",
160
       }
161
       }
161
     }
162
     }
162
   }
163
   }
163
-}
164
+}

+ 2
- 1
playground/src/commons/Layouts.js View File

1
-const { isString, isArray } = require('lodash');
1
+const isString = require('lodash/isString');
2
+const isArray = require('lodash/isArray');
2
 
3
 
3
 const stack = (rawChildren, id) => {
4
 const stack = (rawChildren, id) => {
4
   const childrenArray = isArray(rawChildren) ? rawChildren : [rawChildren];
5
   const childrenArray = isArray(rawChildren) ? rawChildren : [rawChildren];

+ 4
- 3
playground/src/screens/FullScreenModalScreen.js View File

1
-const _ = require('lodash');
1
+const concat = require('lodash/concat');
2
+const last = require('lodash/last');
2
 const React = require('react');
3
 const React = require('react');
3
 const Root = require('../components/Root');
4
 const Root = require('../components/Root');
4
 const Button = require('../components/Button')
5
 const Button = require('../components/Button')
42
         name: Screens.Modal,
43
         name: Screens.Modal,
43
         passProps: {
44
         passProps: {
44
           modalPosition: this.getModalPosition() + 1,
45
           modalPosition: this.getModalPosition() + 1,
45
-          previousModalIds: _.concat([], this.props.previousModalIds || [], this.props.componentId)
46
+          previousModalIds: concat([], this.props.previousModalIds || [], this.props.componentId)
46
         }
47
         }
47
       }
48
       }
48
     });
49
     });
65
 
66
 
66
   getModalPosition = () => this.props.modalPosition || 1;
67
   getModalPosition = () => this.props.modalPosition || 1;
67
 
68
 
68
-  getPreviousModalId = () => _.last(this.props.previousModalIds);
69
+  getPreviousModalId = () => last(this.props.previousModalIds);
69
 }
70
 }
70
 module.exports = FullScreenModalScreen;
71
 module.exports = FullScreenModalScreen;

+ 8
- 5
playground/src/screens/ModalScreen.js View File

1
-const _ = require('lodash');
1
+const last = require('lodash/last');
2
+const concat = require('lodash/concat');
3
+const forEach = require('lodash/forEach');
4
+const head = require('lodash/head');
2
 const React = require('react');
5
 const React = require('react');
3
 const Root = require('../components/Root');
6
 const Root = require('../components/Root');
4
 const Button = require('../components/Button')
7
 const Button = require('../components/Button')
54
         name: Screens.Modal,
57
         name: Screens.Modal,
55
         passProps: {
58
         passProps: {
56
           modalPosition: this.getModalPosition() + 1,
59
           modalPosition: this.getModalPosition() + 1,
57
-          previousModalIds: _.concat([], this.props.previousModalIds || [], this.props.componentId)
60
+          previousModalIds: concat([], this.props.previousModalIds || [], this.props.componentId)
58
         }
61
         }
59
       }
62
       }
60
     });
63
     });
66
 
69
 
67
   dismissUnknownModal = () => Navigation.dismissModal('unknown');
70
   dismissUnknownModal = () => Navigation.dismissModal('unknown');
68
 
71
 
69
-  dismissAllPreviousModals = () => _.forEach(this.props.previousModalIds, (id) => Navigation.dismissModal(id));
72
+  dismissAllPreviousModals = () => forEach(this.props.previousModalIds, (id) => Navigation.dismissModal(id));
70
 
73
 
71
-  dismissFirstModal = () => Navigation.dismissModal(_.head(this.props.previousModalIds));
74
+  dismissFirstModal = () => Navigation.dismissModal(head(this.props.previousModalIds));
72
 
75
 
73
   dismissAllModals = () => Navigation.dismissAllModals();
76
   dismissAllModals = () => Navigation.dismissAllModals();
74
 
77
 
85
 
88
 
86
   getModalPosition = () => this.props.modalPosition || 1;
89
   getModalPosition = () => this.props.modalPosition || 1;
87
 
90
 
88
-  getPreviousModalId = () => _.last(this.props.previousModalIds);
91
+  getPreviousModalId = () => last(this.props.previousModalIds);
89
 }
92
 }
90
 module.exports = ModalScreen;
93
 module.exports = ModalScreen;

+ 4
- 4
playground/src/screens/PushedScreen.js View File

1
-const _ = require('lodash');
1
+const concat = require('lodash/concat');
2
 const React = require('react');
2
 const React = require('react');
3
 const { BackHandler } = require('react-native');
3
 const { BackHandler } = require('react-native');
4
 const Navigation = require('../services/Navigation');
4
 const Navigation = require('../services/Navigation');
99
         name: Screens.Pushed,
99
         name: Screens.Pushed,
100
         passProps: {
100
         passProps: {
101
           stackPosition: this.getStackPosition() + 1,
101
           stackPosition: this.getStackPosition() + 1,
102
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
102
+          previousScreenIds: concat([], this.props.previousScreenIds || [], this.props.componentId)
103
         },
103
         },
104
         options: {
104
         options: {
105
           animations: {
105
           animations: {
120
         name: Screens.Pushed,
120
         name: Screens.Pushed,
121
         passProps: {
121
         passProps: {
122
           stackPosition: this.getStackPosition() + 1,
122
           stackPosition: this.getStackPosition() + 1,
123
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
123
+          previousScreenIds: concat([], this.props.previousScreenIds || [], this.props.componentId)
124
         },
124
         },
125
         options: {
125
         options: {
126
           animations: {
126
           animations: {
152
   createPassProps = () => {
152
   createPassProps = () => {
153
     return {
153
     return {
154
       stackPosition: this.getStackPosition() + 1,
154
       stackPosition: this.getStackPosition() + 1,
155
-      previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
155
+      previousScreenIds: concat([], this.props.previousScreenIds || [], this.props.componentId)
156
     }
156
     }
157
   };
157
   };
158
   getStackPosition = () => this.props.stackPosition || 1;
158
   getStackPosition = () => this.props.stackPosition || 1;

+ 3
- 1
playground/src/services/Navigation.js View File

1
-const { isString, get } = require('lodash');
1
+const get = require('lodash/get');
2
+const isString= require('lodash/isString');
3
+
2
 const { stack, component } = require('../commons/Layouts');
4
 const { stack, component } = require('../commons/Layouts');
3
 const { Navigation } = require('react-native-navigation');
5
 const { Navigation } = require('react-native-navigation');
4
 
6
 

+ 2
- 2
scripts/gen-docs/MarkdownWriter.ts View File

1
-import * as _ from 'lodash';
1
+import concat from 'lodash/concat'
2
 import * as Handlebars from 'handlebars';
2
 import * as Handlebars from 'handlebars';
3
 import * as fs from 'fs';
3
 import * as fs from 'fs';
4
 import { ClassContext } from './ClassParser';
4
 import { ClassContext } from './ClassParser';
34
     const files2 = interfaceContexts.map(mapper);
34
     const files2 = interfaceContexts.map(mapper);
35
     const files3 = enumContexts.map(mapper);
35
     const files3 = enumContexts.map(mapper);
36
 
36
 
37
-    const menuMarkdown = this.menuFn({ files: _.concat(files, files2, files3) });
37
+    const menuMarkdown = this.menuFn({ files: concat(files, files2, files3) });
38
     fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
38
     fs.writeFileSync(`${this.outputDir}/_sidebar.md`, menuMarkdown, { encoding: 'utf8' });
39
     fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
39
     fs.writeFileSync(`${this.outputDir}/README.md`, menuMarkdown, { encoding: 'utf8' });
40
   }
40
   }

+ 2
- 2
scripts/install-android.js View File

1
-const _ = require('lodash');
1
+const includes = require('lodash/includes')
2
 const exec = require('shell-utils').exec;
2
 const exec = require('shell-utils').exec;
3
 
3
 
4
-const release = _.includes(process.argv, '--release');
4
+const release = includes(process.argv, '--release');
5
 
5
 
6
 run();
6
 run();
7
 
7
 

+ 2
- 2
scripts/release.js View File

2
 const exec = require('shell-utils').exec;
2
 const exec = require('shell-utils').exec;
3
 const semver = require('semver');
3
 const semver = require('semver');
4
 const fs = require('fs');
4
 const fs = require('fs');
5
-const _ = require('lodash');
5
+const includes = require('lodash/includes');
6
 const path = require('path');
6
 const path = require('path');
7
 
7
 
8
 // Workaround JS
8
 // Workaround JS
82
             console.log(`Released ${theCandidate}`);
82
             console.log(`Released ${theCandidate}`);
83
             return;
83
             return;
84
         } catch (err) {
84
         } catch (err) {
85
-            const alreadyPublished = _.includes(err.toString(), 'You cannot publish over the previously published version');
85
+            const alreadyPublished = includes(err.toString(), 'You cannot publish over the previously published version');
86
             if (!alreadyPublished) {
86
             if (!alreadyPublished) {
87
                 throw err;
87
                 throw err;
88
             }
88
             }

+ 7
- 7
scripts/test-e2e.js View File

1
-const _ = require('lodash');
1
+const includes = require('lodash/includes');
2
 const exec = require('shell-utils').exec;
2
 const exec = require('shell-utils').exec;
3
 
3
 
4
-const android = _.includes(process.argv, '--android');
5
-const release = _.includes(process.argv, '--release');
6
-const skipBuild = _.includes(process.argv, '--skipBuild');
7
-const headless = _.includes(process.argv, '--headless');
8
-const multi = _.includes(process.argv, '--multi');
9
-const verbose = _.includes(process.argv, '--verbose');
4
+const android = includes(process.argv, '--android');
5
+const release = includes(process.argv, '--release');
6
+const skipBuild = includes(process.argv, '--skipBuild');
7
+const headless = includes(process.argv, '--headless');
8
+const multi = includes(process.argv, '--multi');
9
+const verbose = includes(process.argv, '--verbose');
10
 
10
 
11
 run();
11
 run();
12
 
12
 

+ 5
- 5
scripts/test-js.js View File

1
 const exec = require('shell-utils').exec;
1
 const exec = require('shell-utils').exec;
2
-const _ = require('lodash');
2
+const { includes, chain, split, filter } = require('lodash');
3
 
3
 
4
-const fix = _.includes(process.argv, '--fix') ? '--fix' : '';
4
+const fix = includes(process.argv, '--fix') ? '--fix' : '';
5
 
5
 
6
 const dirs = [
6
 const dirs = [
7
   'lib/src',
7
   'lib/src',
14
 run();
14
 run();
15
 
15
 
16
 function run() {
16
 function run() {
17
-  const paths = _.chain(dirs).map((d) => d === 'e2e' ? `${d}/**/*.[tj]s` : `${d}/**/*.[tj]sx?`).join(' ').value();
17
+  const paths = chain(dirs).map((d) => d === 'e2e' ? `${d}/**/*.[tj]s` : `${d}/**/*.[tj]sx?`).join(' ').value();
18
   exec.execSync(`tslint ${paths} ${fix} --format verbose`);
18
   exec.execSync(`tslint ${paths} ${fix} --format verbose`);
19
   assertAllTsFilesInSrc();
19
   assertAllTsFilesInSrc();
20
   exec.execSync(`jest --coverage`);
20
   exec.execSync(`jest --coverage`);
22
 
22
 
23
 function assertAllTsFilesInSrc() {
23
 function assertAllTsFilesInSrc() {
24
   const allFiles = exec.execSyncRead('find ./lib/src -type f');
24
   const allFiles = exec.execSyncRead('find ./lib/src -type f');
25
-  const lines = _.split(allFiles, '\n');
26
-  const offenders = _.filter(lines, (f) => !f.endsWith('.ts') && !f.endsWith('.tsx'));
25
+  const lines = split(allFiles, '\n');
26
+  const offenders = filter(lines, (f) => !f.endsWith('.ts') && !f.endsWith('.tsx'));
27
   if (offenders.length) {
27
   if (offenders.length) {
28
     throw new Error(`\n\nOnly ts/tsx files are allowed:\n${offenders.join('\n')}\n\n\n`);
28
     throw new Error(`\n\nOnly ts/tsx files are allowed:\n${offenders.join('\n')}\n\n\n`);
29
   }
29
   }

+ 3
- 3
scripts/test-unit.js View File

1
-const _ = require('lodash');
1
+const includes = require('lodash/includes');
2
 const exec = require('shell-utils').exec;
2
 const exec = require('shell-utils').exec;
3
 
3
 
4
-const android = _.includes(process.argv, '--android');
5
-const release = _.includes(process.argv, '--release');
4
+const android = includes(process.argv, '--android');
5
+const release = includes(process.argv, '--release');
6
 
6
 
7
 function run() {
7
 function run() {
8
   if (android) {
8
   if (android) {

+ 1
- 1
tsconfig-strict.json View File

1
 {
1
 {
2
   "$schema": "http://json.schemastore.org/tsconfig",
2
   "$schema": "http://json.schemastore.org/tsconfig",
3
   "compilerOptions": {
3
   "compilerOptions": {
4
-    "allowSyntheticDefaultImports": false,
4
+    "allowSyntheticDefaultImports": true,
5
     "allowUnreachableCode": false,
5
     "allowUnreachableCode": false,
6
     "allowUnusedLabels": false,
6
     "allowUnusedLabels": false,
7
     "diagnostics": true,
7
     "diagnostics": true,

+ 1
- 0
tsconfig.json View File

7
     "module": "commonjs",
7
     "module": "commonjs",
8
     "jsx": "react-native",
8
     "jsx": "react-native",
9
     "declaration": true,
9
     "declaration": true,
10
+    "esModuleInterop": true,
10
     "skipLibCheck": true,
11
     "skipLibCheck": true,
11
     "types": [
12
     "types": [
12
       "jest",
13
       "jest",