From 449494fee92c7f8173a40017270c1ff927debef4 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Jan 2018 19:23:11 -0500 Subject: [PATCH 1/2] cleanup client build setup --- .babelrc | 3 + .eslintignore | 1 + .gitignore | 4 +- {client => client-src/default}/index.js | 0 {client => client-src/default}/overlay.js | 0 {client => client-src/default}/socket.js | 0 client-src/default/webpack.config.js | 22 ++ client/live.js => client-src/live/index.js | 2 +- {client => client-src/live}/live.html | 0 {client => client-src/live}/page.pug | 0 {client => client-src/live}/style.css | 0 .../live}/web_modules/jquery/index.js | 0 .../live}/web_modules/jquery/jquery-1.8.1.js | 0 {client => client-src/live}/webpack.config.js | 13 +- .../sockjs.js => client-src/sockjs/index.js | 0 .../sockjs/webpack.config.js | 0 package-lock.json | 229 ++++++++++++++++++ package.json | 13 +- 18 files changed, 273 insertions(+), 14 deletions(-) create mode 100644 .babelrc rename {client => client-src/default}/index.js (100%) rename {client => client-src/default}/overlay.js (100%) rename {client => client-src/default}/socket.js (100%) create mode 100644 client-src/default/webpack.config.js rename client/live.js => client-src/live/index.js (98%) rename {client => client-src/live}/live.html (100%) rename {client => client-src/live}/page.pug (100%) rename {client => client-src/live}/style.css (100%) rename {client => client-src/live}/web_modules/jquery/index.js (100%) rename {client => client-src/live}/web_modules/jquery/jquery-1.8.1.js (100%) rename {client => client-src/live}/webpack.config.js (63%) rename client/sockjs.js => client-src/sockjs/index.js (100%) rename client/webpack.sockjs.config.js => client-src/sockjs/webpack.config.js (100%) diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000000..002b4aa0d5 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["env"] +} diff --git a/.eslintignore b/.eslintignore index e69de29bb2..d05df27c6b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -0,0 +1 @@ +web_modules diff --git a/.gitignore b/.gitignore index 9825648f8b..e3c2c15428 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,6 @@ npm-debug.log node_modules -/client/live.bundle.js -/client/index.bundle.js -/client/sockjs.bundle.js +/client /coverage /ssl/*.pem .idea/ diff --git a/client/index.js b/client-src/default/index.js similarity index 100% rename from client/index.js rename to client-src/default/index.js diff --git a/client/overlay.js b/client-src/default/overlay.js similarity index 100% rename from client/overlay.js rename to client-src/default/overlay.js diff --git a/client/socket.js b/client-src/default/socket.js similarity index 100% rename from client/socket.js rename to client-src/default/socket.js diff --git a/client-src/default/webpack.config.js b/client-src/default/webpack.config.js new file mode 100644 index 0000000000..6dc5e238e7 --- /dev/null +++ b/client-src/default/webpack.config.js @@ -0,0 +1,22 @@ +'use strict'; + +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); + +module.exports = { + module: { + rules: [ + { + test: /\.js$/, + exclude: /node_modules|web_modules/, + use: [ + { + loader: 'babel-loader' + } + ] + } + ] + }, + plugins: [ + new UglifyJSPlugin() + ] +}; diff --git a/client/live.js b/client-src/live/index.js similarity index 98% rename from client/live.js rename to client-src/live/index.js index 75aeafc3e1..a9d27c4076 100644 --- a/client/live.js +++ b/client-src/live/index.js @@ -4,7 +4,7 @@ const $ = require('jquery'); const stripAnsi = require('strip-ansi'); -const socket = require('./socket'); +const socket = require('../default/socket'); require('./style.css'); let hot = false; diff --git a/client/live.html b/client-src/live/live.html similarity index 100% rename from client/live.html rename to client-src/live/live.html diff --git a/client/page.pug b/client-src/live/page.pug similarity index 100% rename from client/page.pug rename to client-src/live/page.pug diff --git a/client/style.css b/client-src/live/style.css similarity index 100% rename from client/style.css rename to client-src/live/style.css diff --git a/client/web_modules/jquery/index.js b/client-src/live/web_modules/jquery/index.js similarity index 100% rename from client/web_modules/jquery/index.js rename to client-src/live/web_modules/jquery/index.js diff --git a/client/web_modules/jquery/jquery-1.8.1.js b/client-src/live/web_modules/jquery/jquery-1.8.1.js similarity index 100% rename from client/web_modules/jquery/jquery-1.8.1.js rename to client-src/live/web_modules/jquery/jquery-1.8.1.js diff --git a/client/webpack.config.js b/client-src/live/webpack.config.js similarity index 63% rename from client/webpack.config.js rename to client-src/live/webpack.config.js index 7627fc05a5..087c166306 100644 --- a/client/webpack.config.js +++ b/client-src/live/webpack.config.js @@ -1,6 +1,8 @@ 'use strict'; +const path = require('path'); const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const CopyPlugin = require('copy-webpack-plugin'); module.exports = { module: { @@ -10,10 +12,7 @@ module.exports = { exclude: /node_modules|web_modules/, use: [ { - loader: 'babel-loader', - options: { - presets: ['env'] - } + loader: 'babel-loader' } ] }, @@ -33,6 +32,10 @@ module.exports = { ] }, plugins: [ - new UglifyJSPlugin() + new UglifyJSPlugin(), + new CopyPlugin([{ + from: path.resolve(__dirname, 'live.html'), + to: path.resolve(__dirname, '../../client/live.html') + }]) ] }; diff --git a/client/sockjs.js b/client-src/sockjs/index.js similarity index 100% rename from client/sockjs.js rename to client-src/sockjs/index.js diff --git a/client/webpack.sockjs.config.js b/client-src/sockjs/webpack.config.js similarity index 100% rename from client/webpack.sockjs.config.js rename to client-src/sockjs/webpack.config.js diff --git a/package-lock.json b/package-lock.json index 0397e07f11..b269e66308 100644 --- a/package-lock.json +++ b/package-lock.json @@ -513,6 +513,60 @@ "dev": true, "optional": true }, + "babel-cli": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-cli/-/babel-cli-6.26.0.tgz", + "integrity": "sha1-UCq1SHTX24itALiHoGODzgPQAvE=", + "dev": true, + "requires": { + "babel-core": "6.26.0", + "babel-polyfill": "6.26.0", + "babel-register": "6.26.0", + "babel-runtime": "6.26.0", + "chokidar": "1.7.0", + "commander": "2.12.2", + "convert-source-map": "1.5.1", + "fs-readdir-recursive": "1.1.0", + "glob": "7.1.2", + "lodash": "4.17.4", + "output-file-sync": "1.1.2", + "path-is-absolute": "1.0.1", + "slash": "1.0.0", + "source-map": "0.5.7", + "v8flags": "2.1.1" + }, + "dependencies": { + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "dev": true, + "optional": true, + "requires": { + "micromatch": "2.3.11", + "normalize-path": "2.1.1" + } + }, + "chokidar": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", + "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", + "dev": true, + "optional": true, + "requires": { + "anymatch": "1.3.2", + "async-each": "1.0.1", + "fsevents": "1.1.3", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" + } + } + } + }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -1058,6 +1112,25 @@ "babel-types": "6.26.0" } }, + "babel-polyfill": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", + "integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "core-js": "2.5.3", + "regenerator-runtime": "0.10.5" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", + "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=", + "dev": true + } + } + }, "babel-preset-env": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", @@ -2098,6 +2171,12 @@ "delayed-stream": "0.0.5" } }, + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "dev": true + }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -2252,6 +2331,97 @@ "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, + "copy-webpack-plugin": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-4.3.1.tgz", + "integrity": "sha512-xlcFiW/U7KrpS6dFuWq3r8Wb7koJx7QVc7LDFCosqkikaVSxkaYOnwDLwilbjrszZ0LYZXThDAJKcQCSrvdShQ==", + "dev": true, + "requires": { + "cacache": "10.0.2", + "find-cache-dir": "1.0.0", + "globby": "7.1.1", + "is-glob": "4.0.0", + "loader-utils": "0.2.17", + "lodash": "4.17.4", + "minimatch": "3.0.4", + "p-limit": "1.1.0", + "pify": "3.0.0", + "serialize-javascript": "1.4.0" + }, + "dependencies": { + "cacache": { + "version": "10.0.2", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.2.tgz", + "integrity": "sha512-dljb7dk1jqO5ogE+dRpoR9tpHYv5xz9vPSNunh1+0wRuNdYxmzp9WmsyokgW/DUF1FDRVA/TMsmxt027R8djbQ==", + "dev": true, + "requires": { + "bluebird": "3.5.0", + "chownr": "1.0.1", + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "lru-cache": "4.1.1", + "mississippi": "1.3.0", + "mkdirp": "0.5.1", + "move-concurrently": "1.0.1", + "promise-inflight": "1.0.1", + "rimraf": "2.6.2", + "ssri": "5.0.0", + "unique-filename": "1.1.0", + "y18n": "3.2.1" + } + }, + "globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha1-+yzP+UAfhgCUXfral0QMypcrhoA=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "dir-glob": "2.0.0", + "glob": "7.1.2", + "ignore": "3.3.5", + "pify": "3.0.0", + "slash": "1.0.0" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-glob": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", + "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "dev": true, + "requires": { + "is-extglob": "2.1.1" + } + }, + "loader-utils": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", + "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", + "dev": true, + "requires": { + "big.js": "3.1.3", + "emojis-list": "2.1.0", + "json5": "0.5.1", + "object-assign": "4.1.1" + } + }, + "ssri": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.0.0.tgz", + "integrity": "sha512-728D4yoQcQm1ooZvSbywLkV1RjfITZXh0oWrhM/lnsx3nAHx7LsRGJWB/YyvoceAYRq98xqbstiN4JBv1/wNHg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, "core-js": { "version": "2.5.3", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", @@ -2638,6 +2808,27 @@ "randombytes": "2.0.5" } }, + "dir-glob": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.0.0.tgz", + "integrity": "sha512-37qirFDz8cA5fimp9feo43fSuRo2gHwaIn6dXL8Ber1dGwUosDrGZeCCXq57WnIqE4aQ+u3eQZzsk1yOzhdwag==", + "dev": true, + "requires": { + "arrify": "1.0.1", + "path-type": "3.0.0" + }, + "dependencies": { + "path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "requires": { + "pify": "3.0.0" + } + } + } + }, "dns-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", @@ -3731,6 +3922,12 @@ "readable-stream": "2.3.3" } }, + "fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true + }, "fs-write-stream-atomic": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", @@ -7231,6 +7428,17 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, + "output-file-sync": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-1.1.2.tgz", + "integrity": "sha1-0KM+7+YaIF+suQCS6CZZjVJFznY=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "mkdirp": "0.5.1", + "object-assign": "4.1.1" + } + }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -8942,6 +9150,12 @@ } } }, + "serialize-javascript": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz", + "integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=", + "dev": true + }, "serve-index": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.0.tgz", @@ -10485,6 +10699,12 @@ } } }, + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "dev": true + }, "util": { "version": "0.10.3", "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", @@ -10518,6 +10738,15 @@ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, + "v8flags": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/v8flags/-/v8flags-2.1.1.tgz", + "integrity": "sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ=", + "dev": true, + "requires": { + "user-home": "1.1.1" + } + }, "validate-npm-package-license": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", diff --git a/package.json b/package.json index f0afe98c4e..525b96caf6 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,14 @@ "beautify": "npm run lint -- --fix", "ci": "npm run cover -- --report lcovonly && npm run test", "cover": "istanbul cover node_modules/mocha/bin/_mocha", - "lint": "eslint bin lib test examples client/{index,live,socket,sockjs,overlay,webpack.config}.js", + "lint": "eslint bin lib test examples client-src", "mocha": "mocha --full-trace --check-leaks", - "prepublish": "(rm ssl/*.pem || true) && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs", + "prepare": "(rm ssl/*.pem || true) && npm run -s transpile:index && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs", "test": "npm run lint && npm run mocha", - "build:live": "webpack ./client/live.js client/live.bundle.js --color --config client/webpack.config.js", - "build:index": "webpack ./client/index.js client/index.bundle.js --color --config client/webpack.config.js", - "build:sockjs": "webpack ./client/sockjs.js client/sockjs.bundle.js --color --config client/webpack.sockjs.config.js", + "transpile:index": "babel client-src/default --out-dir client --ignore *.config.js", + "build:index": "webpack ./client-src/default/index.js client/index.bundle.js --color --config client-src/default/webpack.config.js", + "build:live": "webpack ./client-src/live/index.js client/live.bundle.js --color --config client-src/live/webpack.config.js", + "build:sockjs": "webpack ./client-src/sockjs/index.js client/sockjs.bundle.js --color --config client-src/sockjs/webpack.config.js", "webpack-dev-server": "cd $INIT_CWD && node ../../../bin/webpack-dev-server.js" }, "files": [ @@ -70,10 +71,12 @@ "yargs": "6.6.0" }, "devDependencies": { + "babel-cli": "^6.26.0", "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-env": "^1.6.1", "codecov.io": "^0.1.6", + "copy-webpack-plugin": "^4.3.1", "css-loader": "^0.28.5", "eslint": "^4.5.0", "eslint-config-webpack": "^1.2.5", From 676d5906c0f74d9335f640912c4f9fa58578b94b Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 9 Jan 2018 19:45:42 -0500 Subject: [PATCH 2/2] revert to prepublish (fix ci) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 525b96caf6..04e91e6d0f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "cover": "istanbul cover node_modules/mocha/bin/_mocha", "lint": "eslint bin lib test examples client-src", "mocha": "mocha --full-trace --check-leaks", - "prepare": "(rm ssl/*.pem || true) && npm run -s transpile:index && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs", + "prepublish": "(rm ssl/*.pem || true) && npm run -s transpile:index && npm run -s build:live && npm run -s build:index && npm run -s build:sockjs", "test": "npm run lint && npm run mocha", "transpile:index": "babel client-src/default --out-dir client --ignore *.config.js", "build:index": "webpack ./client-src/default/index.js client/index.bundle.js --color --config client-src/default/webpack.config.js",