Skip to content

Commit

Permalink
Embed release version in built package
Browse files Browse the repository at this point in the history
Rather than relying on the release version being passed in as config,
build the current release version (as read from `package.json`) into the
bundle.

We use browserify-versionify for this, rather than simply requiring
`package.json`, as our current build toolchain does not support any kind
of tree-shaking, so `require('package.json')` would pull the whole of
the `package.json` file into the bundle.
  • Loading branch information
nickstenning committed Aug 2, 2016
1 parent c928e4f commit f0206c6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion h/static/scripts/directive/help-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function () {
// @ngInject
controller: function ($scope, $window, settings, crossframe) {
this.userAgent = $window.navigator.userAgent;
this.version = settings.release;
this.version = '__VERSION__'; // replaced by versionify
this.dateTime = new Date();
this.serviceUrl = settings.serviceUrl;

Expand Down
2 changes: 1 addition & 1 deletion h/static/scripts/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function translateSourceURLs(data) {

function init(config) {
Raven.config(config.dsn, {
release: config.release,
release: '__VERSION__', // replaced by versionify
dataCallback: translateSourceURLs,
}).install();
installUnhandledPromiseErrorHandler();
Expand Down
17 changes: 17 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"browserify": "^13.0.0",
"browserify-ngannotate": "^1.0.1",
"browserify-shim": "^3.8.12",
"browserify-versionify": "^1.0.6",
"chai": "^3.5.0",
"check-dependencies": "^0.12.0",
"classnames": "^2.2.4",
Expand Down Expand Up @@ -95,6 +96,7 @@
"transform": [
"browserify-ngannotate",
"browserify-shim",
"browserify-versionify",
[
"stringify",
{
Expand Down

0 comments on commit f0206c6

Please sign in to comment.