Skip to content

Commit

Permalink
Merge pull request #103 from ai/size-limit
Browse files Browse the repository at this point in the history
Add package size profiling tools
  • Loading branch information
EtienneLem committed Aug 17, 2017
2 parents 2becc5a + 6d60239 commit 191f970
Show file tree
Hide file tree
Showing 5 changed files with 2,124 additions and 74 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/report.html
scripts/
.*
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = function(config) {

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
singleRun: true,

// Concurrency level
// how many browser should be started simultaneous
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
"react": "^15.5.4",
"react-dom": "^15.5.4",
"rimraf": "2.5.2",
"size-limit": "^0.10.0",
"svg-jsx-loader": "^0.0.16",
"webpack": "1.12.14"
"webpack": "1.12.14",
"webpack-bundle-analyzer": "^2.9.0"
},
"scripts": {
"clean": "rimraf data/ dist/",
Expand All @@ -61,7 +63,13 @@
"react:clean": "rimraf node_modules/{react,react-dom,react-addons-test-utils}",
"react:14": "npm run react:clean && npm i react@^0.14 react-dom@^0.14 react-addons-test-utils@^0.14 --save-dev",
"react:15": "npm run react:clean && npm i react@^15 react-dom@^15 react-addons-test-utils@^15 --save-dev",
"test": "NODE_ENV=test ./node_modules/karma/bin/karma start",
"test": "NODE_ENV=test karma start && size-limit",
"prepublish": "npm run clean && npm run build"
}
},
"size-limit": [
{
"path": "dist/emoji-mart.js",
"limit": "110 KB"
}
]
}
31 changes: 22 additions & 9 deletions src/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
var path = require('path')
var pack = require('../package.json')
var webpack = require('webpack')
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

var PROD = process.env.NODE_ENV === 'production';
var TEST = process.env.NODE_ENV === 'test';

module.exports = {
var config = {
entry: path.resolve('src/index.js'),
output: {
path: path.resolve('dist'),
Expand All @@ -14,14 +15,7 @@ module.exports = {
libraryTarget: 'umd',
},

externals: !TEST && [{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
}],
externals: [],

module: {
loaders: [
Expand Down Expand Up @@ -56,3 +50,22 @@ module.exports = {

bail: true,
}

if (!TEST) {
config.externals = config.externals.concat([
{
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
},
},
])

config.plugins = config.plugins.concat([
new BundleAnalyzerPlugin({ analyzerMode: 'static', openAnalyzer: false }),
])
}

module.exports = config

0 comments on commit 191f970

Please sign in to comment.