Skip to content

Commit

Permalink
Fix: Make npm package not include devDependencies
Browse files Browse the repository at this point in the history
Up until now the package added `devDependencies` increasing not only
the size of the package but also triggering some `postinstall` scripts
that are not needed and break in Windows machines.
  • Loading branch information
Anton Molleda authored and alrra committed Sep 12, 2017
1 parent b342cf6 commit fcafcc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@
"lint:js": "eslint --ext md --ext ts --ignore-pattern dist .",
"lint:md": "markdownlint docs",
"preparecommitmsg": "node scripts/prepare-commit-message.js",
"prepublishOnly": "npm i && npm run build",
"release": "npm run test && node dist/scripts/release.js",
"release": "npm i && npm run test && node dist/scripts/release.js",
"site": "node dist/src/bin/sonar",
"test": "npm run lint && npm run commitmsg && npm run build && nyc ava",
"test-on-travis": "npm run lint && npm run commitmsg && npm run build && nyc ava \"dist/tests/**/*.js\" --concurrency=2 --timeout=2m",
Expand Down
9 changes: 7 additions & 2 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ const main = async () => {
// Create new release.
await createRelease(version, releaseNotes);

// Remove devDependencies, this will update `package-lock.json`.
// Need to do so they aren't published on the `npm` package.
exec('Remove devDependencies', 'npm prune --production');

// Create shrinkwrap file.
// (This is done because `npm` doesn't
// publish the `package-lock` file)
Expand All @@ -340,8 +344,9 @@ const main = async () => {
// Publish on `npm`.
exec('Publish on `npm`.', 'npm publish');

// Restore the package lock file.
shell.mv(SHRINKWRAP_FILE, PACKAGE_LOCK_FILE);
// Restore the package lock file and delete shrinkwrap
shell.rm(SHRINKWRAP_FILE);
exec(`Restore ${PACKAGE_LOCK_FILE}`, `git checkout ${PACKAGE_LOCK_FILE}`);
};

main();

1 comment on commit fcafcc9

@alrra
Copy link
Contributor

@alrra alrra commented on fcafcc9 Sep 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change the size of our package went from 224,8 MB down to 71,2 MB (68.33% reduction). 🎉

Please sign in to comment.