Skip to content

Commit

Permalink
Add size control and reduce library size
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Nov 21, 2016
1 parent cee48f4 commit 62b258e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ npm-debug.log

coverage/
docs/

*.gz
bundle-report.html
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ coverage/
docs/
.jsdocrc
.yaspellerrc

*.gz
bundle-report.html
5 changes: 2 additions & 3 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var BrowserConnection = require('logux-sync/browser-connection')
var createTimer = require('logux-core/create-timer')
var ClientSync = require('logux-sync/client-sync')
var Reconnect = require('logux-sync/reconnect')
var shortUUID = require('short-uuid')
var shortid = require('shortid')
var Log = require('logux-core/log')

var isQuotaExceeded = require('./is-quota-exceeded')
Expand Down Expand Up @@ -67,8 +67,7 @@ function Client (options) {
this.options.prefix = 'logux'
}
if (typeof this.options.nodeId === 'undefined') {
var shortId = shortUUID()
this.options.nodeId = shortId.fromUUID(shortId.uuid())
this.options.nodeId = shortid.generate()
}

var timer = this.options.timer || createTimer(this.options.nodeId)
Expand Down
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"logux-core": "logux/logux-core",
"logux-sync": "logux/logux-sync",
"short-uuid": "^2.1.1"
"shortid": "^2.2.6"
},
"devDependencies": {
"docdash": "^0.4.0",
Expand All @@ -23,30 +23,35 @@
"eslint-plugin-standard": "^2.0.1",
"jest": "^17.0.0",
"jsdoc": "^3.4.3",
"json-loader": "^0.5.4",
"lint-staged": "^3.2.1",
"mock-local-storage": "^1.0.2",
"pre-commit": "^1.1.3",
"rimraf": "^2.5.4",
"uglifyjs": "^2.4.10",
"webpack": "^2.1.0-beta.27",
"webpack-bundle-analyzer": "^1.5.3",
"yaspeller": "^3.0.0"
},
"scripts": {
"lint-staged": "lint-staged",
"spellcheck": "npm run cleandocs && yaspeller *.md docs/*.html",
"cleandocs": "npm run docs && rimraf docs/*.js.html",
"clean": "rimraf docs/ coverage/",
"clean": "rimraf docs/ coverage/ bundle-report.html",
"lint": "eslint *.js test/*.js",
"docs": "jsdoc --configure .jsdocrc *.js",
"test": "jest --coverage && npm run lint && npm run spellcheck"
"test": "jest --coverage && npm run lint && npm run spellcheck",
"pack": "webpack client.js all.js",
"compress": "uglifyjs all.js -o all.js && gzip -9 -f all.js",
"show": "ls -lh *.gz | awk '{print \"Size:\", $5\"B\"}'",
"size": "npm run pack && npm run compress && npm run show && rm *.gz"
},
"jest": {
"coverageThreshold": {
"global": {
"statements": 100
}
},
"setupFiles": [
"test/crypto.setup.js"
]
}
},
"eslintConfig": {
"extends": "eslint-config-logux"
Expand Down
8 changes: 0 additions & 8 deletions test/crypto.setup.js

This file was deleted.

14 changes: 14 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var Analyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

module.exports = {
module: {
loaders: [
{ test: /\.json$/, loader: 'json-loader' }
]
},
plugins: [new Analyzer({
analyzerMode: 'static',
reportFilename: 'bundle-report.html',
openAnalyzer: false
})]
}

0 comments on commit 62b258e

Please sign in to comment.