Skip to content

Commit

Permalink
Remove babel from deps before publish
Browse files Browse the repository at this point in the history
@adamdicarlo had a fantastic idea to move the babel dependencies to
devDependencies before publishing. That way, they are still there for
git installs, but npm installs, which are the fast majority, are much
faster.

I tested this by publishing `0.16.3` with the tag `test`, you can test
using `npm install radium@test`. In retrospect the version should have
had `-test` after it too.

Fixes FormidableLabs#530
  • Loading branch information
ianobermiller committed Jan 21, 2016
1 parent d8861be commit 90f353b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
19 changes: 19 additions & 0 deletions npm-scripts/move-babel-to-dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');

const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'));

const dependencyKeys = Object.keys(packageJSON.dependencies);
dependencyKeys.filter(key => key.startsWith('babel')).forEach(key => {
packageJSON.devDependencies[key] = packageJSON.dependencies[key];
});
packageJSON.dependencies = dependencyKeys
.filter(key => !key.startsWith('babel'))
.reduce(
(result, key) => {
result[key] = packageJSON.dependencies[key];
return result;
},
{}
);

fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, ' ') + '\n', 'utf8');
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
"babel": "rimraf lib && babel src/ -d lib/",
"dist": "webpack && webpack --config=webpack.config.minified.js",
"examples": "webpack-dev-server --config examples/webpack.config.js --no-info --content-base examples/",
"deps-fix": "babel-node ./npm-scripts/move-babel-to-dependencies.js",
"deps-restore": "git checkout package.json",
"flow": "node -e \"process.exit(process.platform === 'win32' ? 0 : 1)\" || flow check",
"lib": "npm run babel && rimraf lib/__tests__ lib/__mocks__",
"lint": "eslint src && npm run flow",
"postinstall": "cd lib || npm run lib",
"prepublish": "npm test && npm run lint && npm run lib && npm run dist",
"prepublish": "npm test && npm run lint && npm run lib && npm run dist && npm run deps-fix",
"postpublish": "npm run deps-restore",
"start": "./node_modules/.bin/babel-node examples/server.js",
"test": "karma start",
"test-coverage": "karma start karma.conf.coverage.js",
Expand Down

0 comments on commit 90f353b

Please sign in to comment.