Remove lodash to reduce final size (#251)

This commit is contained in:
David Duarte
2018-05-21 19:50:29 +02:00
committed by Guillaume Chau
parent 937094cfcc
commit fccb313293
9 changed files with 6806 additions and 4679 deletions
+180 -2328
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+180 -2328
View File
File diff suppressed because it is too large Load Diff
+6428
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -36,9 +36,7 @@
"apollo-client": "^2.0.0"
},
"dependencies": {
"lodash.debounce": "^4.0.8",
"lodash.omit": "^4.5.0",
"lodash.throttle": "^4.1.1"
"throttle-debounce": "^1.0.1"
},
"devDependencies": {
"@types/graphql": "^0.12.3",
+1 -2
View File
@@ -1,6 +1,5 @@
import omit from 'lodash.omit'
import { VUE_APOLLO_QUERY_KEYWORDS } from './consts'
import { getMergedDefinition } from './utils'
import { getMergedDefinition, omit } from './utils'
export class ApolloProvider {
constructor (options) {
+3 -4
View File
@@ -1,10 +1,9 @@
import omit from 'lodash.omit'
import { DollarApollo } from './dollar-apollo'
import { ApolloProvider as apolloProvider } from './apollo-provider'
import CApolloQuery from './components/ApolloQuery'
import CApolloSubscribeToMore from './components/ApolloSubscribeToMore'
import CApolloMutation from './components/ApolloMutation'
import { Globals } from './utils'
import { Globals, omit } from './utils'
const keywords = [
'$subscribe',
@@ -52,8 +51,8 @@ const launch = function launch () {
for (let key in apollo) {
if (key.charAt(0) !== '$') {
let options = apollo[key]
if(apollo.$query) {
options = Object.assign({}, apollo.$query, options)
if (apollo.$query) {
options = Object.assign({}, apollo.$query, options)
}
if (!hasProperty(this, key) && !hasProperty(this.$props, key) && !hasProperty(this.$data, key)) {
Object.defineProperty(this, key, {
+1 -2
View File
@@ -1,5 +1,4 @@
import omit from 'lodash.omit'
import { throttle, debounce } from './utils'
import { throttle, debounce, omit } from './utils'
export default class SmartApollo {
type = null
+11 -11
View File
@@ -1,21 +1,15 @@
import loThrottle from 'lodash.throttle'
import loDebounce from 'lodash.debounce'
import oThrottle from 'throttle-debounce/throttle'
import oDebounce from 'throttle-debounce/debounce'
export const Globals = {}
function factory (action) {
return (cb, options) => {
if (typeof options === 'number') {
return action(cb, options)
} else {
return action(cb, options.wait, options)
}
}
return (cb, time) => action(time. cb)
}
export const throttle = factory(loThrottle)
export const throttle = factory(oThrottle)
export const debounce = factory(loDebounce)
export const debounce = factory(oDebounce)
export function getMergedDefinition (def) {
return Globals.Vue.util.mergeOptions({}, def)
@@ -27,3 +21,9 @@ export function reapply (options, context) {
}
return options
}
export function omit(obj, properties) {
return Object.entries(obj)
.filter(([key]) => !properties.includes(key))
.reduce((c, [key, val]) => (c[key] = val, c), {})
}