Skip to content

Commit 62b258e

Browse files
committed
Add size control and reduce library size
1 parent cee48f4 commit 62b258e

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ npm-debug.log
66

77
coverage/
88
docs/
9+
10+
*.gz
11+
bundle-report.html

Diff for: .npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ coverage/
1212
docs/
1313
.jsdocrc
1414
.yaspellerrc
15+
16+
*.gz
17+
bundle-report.html

Diff for: client.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var BrowserConnection = require('logux-sync/browser-connection')
22
var createTimer = require('logux-core/create-timer')
33
var ClientSync = require('logux-sync/client-sync')
44
var Reconnect = require('logux-sync/reconnect')
5-
var shortUUID = require('short-uuid')
5+
var shortid = require('shortid')
66
var Log = require('logux-core/log')
77

88
var isQuotaExceeded = require('./is-quota-exceeded')
@@ -67,8 +67,7 @@ function Client (options) {
6767
this.options.prefix = 'logux'
6868
}
6969
if (typeof this.options.nodeId === 'undefined') {
70-
var shortId = shortUUID()
71-
this.options.nodeId = shortId.fromUUID(shortId.uuid())
70+
this.options.nodeId = shortid.generate()
7271
}
7372

7473
var timer = this.options.timer || createTimer(this.options.nodeId)

Diff for: package.json

+12-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"dependencies": {
1313
"logux-core": "logux/logux-core",
1414
"logux-sync": "logux/logux-sync",
15-
"short-uuid": "^2.1.1"
15+
"shortid": "^2.2.6"
1616
},
1717
"devDependencies": {
1818
"docdash": "^0.4.0",
@@ -23,30 +23,35 @@
2323
"eslint-plugin-standard": "^2.0.1",
2424
"jest": "^17.0.0",
2525
"jsdoc": "^3.4.3",
26+
"json-loader": "^0.5.4",
2627
"lint-staged": "^3.2.1",
2728
"mock-local-storage": "^1.0.2",
2829
"pre-commit": "^1.1.3",
2930
"rimraf": "^2.5.4",
31+
"uglifyjs": "^2.4.10",
32+
"webpack": "^2.1.0-beta.27",
33+
"webpack-bundle-analyzer": "^1.5.3",
3034
"yaspeller": "^3.0.0"
3135
},
3236
"scripts": {
3337
"lint-staged": "lint-staged",
3438
"spellcheck": "npm run cleandocs && yaspeller *.md docs/*.html",
3539
"cleandocs": "npm run docs && rimraf docs/*.js.html",
36-
"clean": "rimraf docs/ coverage/",
40+
"clean": "rimraf docs/ coverage/ bundle-report.html",
3741
"lint": "eslint *.js test/*.js",
3842
"docs": "jsdoc --configure .jsdocrc *.js",
39-
"test": "jest --coverage && npm run lint && npm run spellcheck"
43+
"test": "jest --coverage && npm run lint && npm run spellcheck",
44+
"pack": "webpack client.js all.js",
45+
"compress": "uglifyjs all.js -o all.js && gzip -9 -f all.js",
46+
"show": "ls -lh *.gz | awk '{print \"Size:\", $5\"B\"}'",
47+
"size": "npm run pack && npm run compress && npm run show && rm *.gz"
4048
},
4149
"jest": {
4250
"coverageThreshold": {
4351
"global": {
4452
"statements": 100
4553
}
46-
},
47-
"setupFiles": [
48-
"test/crypto.setup.js"
49-
]
54+
}
5055
},
5156
"eslintConfig": {
5257
"extends": "eslint-config-logux"

Diff for: test/crypto.setup.js

-8
This file was deleted.

Diff for: webpack.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var Analyzer = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
2+
3+
module.exports = {
4+
module: {
5+
loaders: [
6+
{ test: /\.json$/, loader: 'json-loader' }
7+
]
8+
},
9+
plugins: [new Analyzer({
10+
analyzerMode: 'static',
11+
reportFilename: 'bundle-report.html',
12+
openAnalyzer: false
13+
})]
14+
}

0 commit comments

Comments
 (0)