Skip to content

Commit d229779

Browse files
authored
Import RxJS and Lodash modules individually (#316)
* frint: import RxJS modules individually. * import RxJS modules individually. * make: command for quickly listing all `rxjs/*` imports in source across all packages. * import lodash functions individually. * frint-config: initial commit. * frint-config: list in docs. * internally use `frint-config` for generating dists. * eslint: fail the build for any full import of `rxjs` or `lodash`. * frint-store: update docs about epics not providing all RxJS operators by default. * eslint: do not allow extending RxJS modules on the fly.
1 parent 4eab4e0 commit d229779

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+457
-199
lines changed

.eslintrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
],
55
"parser": "babel-eslint",
66
"rules": {
7-
"no-underscore-dangle": 0
7+
"no-underscore-dangle": 0,
8+
"no-restricted-imports": ["error", {
9+
"paths": [
10+
"lodash",
11+
"rxjs",
12+
"rxjs/add/*"
13+
]
14+
}]
815
}
916
}

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ site-publish-only:
9494
(cd ./_site && git add .)
9595
(cd ./_site && git commit -am 'update site')
9696
(cd ./_site && git push [email protected]:Travix-International/frint gh-pages --force)
97+
98+
##
99+
# Usage stats
100+
#
101+
define list_usage_in_source
102+
find ./packages -iname "*.js" | grep "/src/" | grep -v -e ".spec.js" -e "/node_modules/" | xargs cat | grep $(1) | sort -u
103+
endef
104+
105+
list-usage-rxjs:
106+
@$(call list_usage_in_source,'rxjs/')
107+
108+
list-usage-lodash:
109+
@$(call list_usage_in_source,'lodash/')

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The framework is a collection of these packages, which can be composed together
4848
| [frint-store] | [![frint-store-status]][frint-store-package] | State management with reactive stores |
4949
| [frint-data] | [![frint-data-status]][frint-data-package] | Reactive data modelling |
5050
| [frint-react] | [![frint-react-status]][frint-react-package] | React.js integration |
51-
| [frint-react-server] | [![frint-react-server-status]][frint-react-server-package] | Server-rendering of Apps |
51+
| [frint-react-server] | [![frint-react-server-status]][frint-react-server-package] | Server-side rendering of Apps |
5252
| [frint-router] | [![frint-router-status]][frint-router-package] | Router services for building Single Page Applications |
5353
| [frint-router-react] | [![frint-router-react-status]][frint-router-react-package] | React components for building SPAs |
5454
| [frint-cli] | [![frint-cli-status]][frint-cli-package] | CLI runner |
@@ -57,6 +57,7 @@ The framework is a collection of these packages, which can be composed together
5757
| [frint-component-utils] | [![frint-component-utils-status]][frint-component-utils-package] | Utils for reactive Components |
5858
| [frint-component-handlers] | [![frint-component-handlers-status]][frint-component-handlers-package] | Handlers for integrating with other rendering libraries |
5959
| [frint-test-utils] | [![frint-test-utils-status]][frint-test-utils-package] | Internally used test utilities |
60+
| [frint-config] | [![frint-config-status]][frint-config-package] | Common config for your Apps |
6061

6162
[frint]: https://frint.js.org/docs/packages/frint
6263
[frint-store]: https://frint.js.org/docs/packages/frint-store
@@ -71,6 +72,7 @@ The framework is a collection of these packages, which can be composed together
7172
[frint-component-utils]: https://frint.js.org/docs/packages/frint-component-utils
7273
[frint-component-handlers]: https://frint.js.org/docs/packages/frint-component-handlers
7374
[frint-test-utils]: https://frint.js.org/docs/packages/frint-test-utils
75+
[frint-config]: https://frint.js.org/docs/packages/frint-config
7476

7577
[frint-status]: https://img.shields.io/npm/v/frint.svg
7678
[frint-store-status]: https://img.shields.io/npm/v/frint-store.svg
@@ -85,6 +87,7 @@ The framework is a collection of these packages, which can be composed together
8587
[frint-component-utils-status]: https://img.shields.io/npm/v/frint-component-utils.svg
8688
[frint-component-handlers-status]: https://img.shields.io/npm/v/frint-component-handlers.svg
8789
[frint-test-utils-status]: https://img.shields.io/npm/v/frint-test-utils.svg
90+
[frint-config-status]: https://img.shields.io/npm/v/frint-config.svg
8891

8992
[frint-package]: https://npmjs.com/package/frint
9093
[frint-store-package]: https://npmjs.com/package/frint-store
@@ -99,6 +102,7 @@ The framework is a collection of these packages, which can be composed together
99102
[frint-component-utils-package]: https://npmjs.com/package/frint-component-utils
100103
[frint-component-handlers-package]: https://npmjs.com/package/frint-component-handlers
101104
[frint-test-utils-package]: https://npmjs.com/package/frint-test-utils
105+
[frint-config-package]: https://npmjs.com/package/frint-config
102106

103107
## Community projects
104108

packages/frint-cli/commands/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = createApp({
5353

5454
deps.console.log('Initializing...');
5555

56-
mkdirp(dir, function (error) {
56+
mkdirp(dir, function mkdirpCallback(error) {
5757
if (error) {
5858
deps.console.error(error);
5959
return;

packages/frint-cli/root/providers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
const _ = require('lodash');
4+
const clone = require('lodash/clone');
55
const argv = require('yargs').argv;
66

77
module.exports = [
@@ -29,7 +29,7 @@ module.exports = [
2929
{
3030
name: 'params',
3131
useFactory: function useFactory() {
32-
const clonedArgv = _.clone(argv);
32+
const clonedArgv = clone(argv);
3333
clonedArgv._.shift();
3434

3535
return clonedArgv;

packages/frint-compat/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
],
3030
"dependencies": {},
3131
"devDependencies": {
32-
"cross-env": "^5.0.5"
32+
"cross-env": "^5.0.5",
33+
"frint-config": "^2.8.1"
3334
},
3435
"bugs": {
3536
"url": "https://github.com/Travix-International/frint/issues"

packages/frint-compat/webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var webpack = require('webpack');
2+
var externals = require('frint-config').externals;
23

34
var minify = process.env.DIST_MIN;
45
var plugins = !minify
@@ -23,7 +24,7 @@ module.exports = {
2324
libraryTarget: 'this',
2425
library: 'FrintCompat'
2526
},
26-
externals: {
27+
externals: Object.assign({}, {
2728
'frint': 'Frint',
2829
'frint-model': 'FrintModel',
2930
'frint-react': 'FrintReact',
@@ -33,7 +34,7 @@ module.exports = {
3334
'react': 'React',
3435
'react-dom': 'ReactDOM',
3536
'rxjs': 'Rx',
36-
},
37+
}, externals),
3738
target: 'web',
3839
plugins: plugins,
3940
module: {

packages/frint-component-handlers/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"devDependencies": {
3535
"cross-env": "^5.0.5",
3636
"frint": "^2.8.1",
37-
"frint-component-utils": "^2.8.1"
37+
"frint-component-utils": "^2.8.1",
38+
"frint-config": "^2.8.1"
3839
},
3940
"bugs": {
4041
"url": "https://github.com/Travix-International/frint/issues"

packages/frint-component-handlers/src/ObserveHandler.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable import/no-extraneous-dependencies, func-names */
22
/* global describe, it */
33
import { expect } from 'chai';
4-
import { Observable } from 'rxjs';
4+
import { of as of$ } from 'rxjs/observable/of';
55

66
import { composeHandlers } from 'frint-component-utils';
77
import ObserveHandler from './ObserveHandler';
@@ -31,7 +31,7 @@ describe('frint-component-handlers › ObserveHandler', function () {
3131
ObserveHandler,
3232
{
3333
getProps$: function (a) {
34-
return Observable.of({
34+
return of$({
3535
appName: a.getName(),
3636
});
3737
},

packages/frint-component-handlers/src/RegionHandler.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* global window */
22
/* eslint-disable no-console */
3-
import _ from 'lodash';
3+
import isEqual from 'lodash/isEqual';
4+
import zipWith from 'lodash/zipWith';
45

56
export default {
67
getInitialData() {
@@ -95,13 +96,13 @@ export default {
9596
});
9697
},
9798
shouldUpdate(nextProps, nextData) {
98-
let shouldUpdate = !_.isEqual(this.getProps(), nextProps);
99+
let shouldUpdate = !isEqual(this.getProps(), nextProps);
99100

100101
if (!shouldUpdate) {
101102
const { listForRendering } = nextData;
102103
shouldUpdate = shouldUpdate || this.getData('listForRendering').length !== listForRendering.length;
103104
shouldUpdate = shouldUpdate ||
104-
_.zipWith(this.getData('listForRendering'), listForRendering, (a, b) => a.name === b.name)
105+
zipWith(this.getData('listForRendering'), listForRendering, (a, b) => a.name === b.name)
105106
.some(value => !value);
106107
}
107108

0 commit comments

Comments
 (0)