Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Commit

Permalink
Stop Babel requiring entire package.json just to get core version num…
Browse files Browse the repository at this point in the history
…ber. Reduces build size by ~3 KB
  • Loading branch information
Daniel15 committed Nov 20, 2016
1 parent 2a1bb0f commit d6c4660
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,18 @@ function webpackBuild(filename, libraryName, version) {
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
BABEL_VERSION: JSON.stringify(require('babel-core/package.json').version),
VERSION: JSON.stringify(version),
}),
// Use browser version of visionmedia-debug
new webpack.NormalModuleReplacementPlugin(
/debug\/node/,
'debug/browser'
),
new webpack.NormalModuleReplacementPlugin(
/..\/..\/package/,
'../../../../src/babel-package-shim'
),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin()
]
Expand Down
5 changes: 5 additions & 0 deletions src/babel-package-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* A shim that replaces Babel's require('package.json') statement.
* Babel requires the entire package.json file just to get the version number.
*/
export const version = BABEL_VERSION;

0 comments on commit d6c4660

Please sign in to comment.