From bd7329f80751562dc4b42c975a0040b18da6912d Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Thu, 16 May 2019 22:58:56 -0700 Subject: [PATCH] chore: validator use less bundle size (#61) --- .gitignore | 2 +- package.json | 3 +++ src/webui/utils/url.js | 7 ++++--- yarn.lock | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 1e7a4cd..6922247 100755 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ __tests__ # Compiled script static/* coverage/ - +stats.json diff --git a/package.json b/package.json index 0fd4d41..eefe8f8 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "verdaccio-memory": "2.0.0", "webpack": "4.20.2", "webpack-bundle-analyzer": "3.0.4", + "webpack-bundle-size-analyzer": "3.0.0", "webpack-cli": "3.2.3", "webpack-dev-server": "3.2.1", "webpack-merge": "4.2.1", @@ -121,6 +122,8 @@ "dev:web": "cross-env BABEL_ENV=ui babel-node tools/dev.server.js", "verdaccio:server": "node tools/verdaccio.js", "build": "npm run pre:webpack && cross-env BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js", + "build:stats": "cross-env BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js --json > stats.json", + "build:size": "cross-env BABEL_ENV=ui webpack --config tools/webpack.prod.config.babel.js --json | webpack-bundle-size-analyzer", "dev": "concurrently --kill-others \"npm run dev:web\" \"npm run verdaccio:server\"" }, "engines": { diff --git a/src/webui/utils/url.js b/src/webui/utils/url.js index fc0685d..5f31a29 100644 --- a/src/webui/utils/url.js +++ b/src/webui/utils/url.js @@ -1,14 +1,15 @@ -import validator from 'validator'; +import isURLValidator from 'validator/lib/isURL'; +import isEmailValidator from 'validator/lib/isEmail'; export function isURL(url) { - return validator.isURL(url || '', { + return isURLValidator(url || '', { protocols: ['http', 'https', 'git+https'], require_protocol: true, }); } export function isEmail(email) { - return validator.isEmail(email || ''); + return isEmailValidator(email || ''); } export function getRegistryURL() { diff --git a/yarn.lock b/yarn.lock index 25f3925..c4662d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6519,6 +6519,11 @@ https-proxy-agent@^2.2.1: agent-base "^4.1.0" debug "^3.1.0" +humanize@0.0.9: + version "0.0.9" + resolved "https://registry.verdaccio.org/humanize/-/humanize-0.0.9.tgz#1994ffaecdfe9c441ed2bdac7452b7bb4c9e41a4" + integrity sha1-GZT/rs3+nEQe0r2sdFK3u0yeQaQ= + husky@0.15.0-rc.8: version "0.15.0-rc.8" resolved "https://registry.npmjs.org/husky/-/husky-0.15.0-rc.8.tgz#b658c597a8f9bbcd00a5c039709e7c61e61238e7" @@ -13391,6 +13396,15 @@ webpack-bundle-analyzer@3.0.4: opener "^1.5.1" ws "^6.0.0" +webpack-bundle-size-analyzer@3.0.0: + version "3.0.0" + resolved "https://registry.verdaccio.org/webpack-bundle-size-analyzer/-/webpack-bundle-size-analyzer-3.0.0.tgz#c0657e9787cf644a0b91d891ae15553ba61bbc71" + integrity sha512-GfQ/Mch1o2MGonGPIMawwlxXOmYp/F8EXiT9txDO6qASo7G5hODngWMNW1KkJxeYRvgMUuPgbSsmdsXEsBNEeg== + dependencies: + commander "^2.19.0" + filesize "^3.6.1" + humanize "0.0.9" + webpack-cli@3.2.3: version "3.2.3" resolved "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.2.3.tgz#13653549adfd8ccd920ad7be1ef868bacc22e346"