Skip to content

Commit

Permalink
Webpack would inject process/browser.js (-4KB)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Dec 25, 2017
1 parent a9d9e7d commit 44d98c4
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bower_components/

coverage/
lib
report.html
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"multer": "^1.3.0",
"puppeteer": "^0.12.0",
"system-sleep": "^1.3.6",
"webpack": "^3.5.3"
"webpack": "^3.5.3",
"webpack-bundle-analyzer": "^2.9.1"
},
"files": [
"lib",
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export function isFormData(value) {

export function isNode() {
return !!(
typeof process !== 'undefined' &&
process.versions &&
process.versions.node
typeof global.process !== 'undefined' &&
global.process.versions &&
global.process.versions.node
);
}

Expand Down
10 changes: 10 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const pkg = require('./package.json');

const config = {
Expand Down Expand Up @@ -53,6 +55,14 @@ ${pkg.homepage}`

if (process.env.NODE_ENV === 'production') {
config.plugins.push(new CleanWebpackPlugin(['lib']));
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'static',
reportFilename: path.join(__dirname, 'report.html'),
openAnalyzer: false,
generateStatsFile: false
})
);
}

if (process.env.NODE_ENV === 'test') {
Expand Down
48 changes: 47 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,10 @@ domain-browser@^1.1.1:
version "1.1.7"
resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc"

duplexer@^0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"

ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
Expand All @@ -1738,6 +1742,10 @@ ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"

ejs@^2.5.6:
version "2.5.7"
resolved "https://registry.npmjs.org/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a"

electron-to-chromium@^1.3.24:
version "1.3.26"
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.26.tgz#996427294861a74d9c7c82b9260ea301e8c02d66"
Expand Down Expand Up @@ -2095,7 +2103,7 @@ expand-range@^1.8.1:
dependencies:
fill-range "^2.1.0"

express@>=4.4.2:
express@>=4.4.2, express@^4.15.2:
version "4.16.2"
resolved "https://registry.npmjs.org/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c"
dependencies:
Expand Down Expand Up @@ -2211,6 +2219,10 @@ fileset@^2.0.2:
glob "^7.0.3"
minimatch "^3.0.3"

filesize@^3.5.9:
version "3.5.11"
resolved "https://registry.npmjs.org/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee"

fill-range@^2.1.0:
version "2.2.3"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723"
Expand Down Expand Up @@ -2451,6 +2463,12 @@ growl@1.9.2:
version "1.9.2"
resolved "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f"

gzip-size@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520"
dependencies:
duplexer "^0.1.1"

handlebars@^4.0.3:
version "4.0.10"
resolved "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f"
Expand Down Expand Up @@ -3608,6 +3626,10 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"

opener@^1.4.3:
version "1.4.3"
resolved "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8"

optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
Expand Down Expand Up @@ -4747,6 +4769,22 @@ watchpack@^1.4.0:
chokidar "^1.7.0"
graceful-fs "^4.1.2"

webpack-bundle-analyzer@^2.9.1:
version "2.9.1"
resolved "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.1.tgz#c2c8e03e8e5768ed288b39ae9e27a8b8d7b9d476"
dependencies:
acorn "^5.1.1"
chalk "^1.1.3"
commander "^2.9.0"
ejs "^2.5.6"
express "^4.15.2"
filesize "^3.5.9"
gzip-size "^3.0.0"
lodash "^4.17.4"
mkdirp "^0.5.1"
opener "^1.4.3"
ws "^3.3.1"

webpack-dev-middleware@^1.0.11:
version "1.12.0"
resolved "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.0.tgz#d34efefb2edda7e1d3b5dbe07289513219651709"
Expand Down Expand Up @@ -4859,6 +4897,14 @@ ws@^3.0.0:
safe-buffer "~5.1.0"
ultron "~1.1.0"

ws@^3.3.1:
version "3.3.3"
resolved "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2"
dependencies:
async-limiter "~1.0.0"
safe-buffer "~5.1.0"
ultron "~1.1.0"

wtf-8@1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a"
Expand Down

0 comments on commit 44d98c4

Please sign in to comment.