Skip to content

Commit 9a18124

Browse files
authored
Merge pull request #259 from conveyal/dev
Next release
2 parents 3229cbe + 4acc0f1 commit 9a18124

9 files changed

+56
-11
lines changed

bin/mastarm-build

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ commander
1919
.option('-e, --env <environment>', 'Environment to use.')
2020
.option('-F, --flyle', 'Cache and serve tiles.')
2121
.option('-m, --minify', 'Minify built files.')
22+
.option('-i, --instrument', 'Instrument js files')
2223
.option('-O, --outdir <dir>', 'Publish directory', '')
2324
.option('-p, --proxy <address>', 'Proxy calls through to target address.')
2425
.option('-s, --serve', 'Serve with budo. Automatically rebuilds on changes.')
@@ -38,6 +39,7 @@ const opts = {
3839
env: get('env'),
3940
files,
4041
flyle: get('flyle'),
42+
instrument: get('instrument'),
4143
minify: get('minify'),
4244
proxy: get('proxy'),
4345
watch

lib/babel-config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const lodash = require('babel-plugin-lodash')
77
const reactDisplayName = require('@babel/plugin-transform-react-display-name')
88
const classProperties = require('@babel/plugin-proposal-class-properties')
99
const exportFrom = require('@babel/plugin-proposal-export-namespace-from')
10+
const istanbul = require('babel-plugin-istanbul')
1011

1112
const browsers = require('./constants').BROWSER_SUPPORT
1213

13-
module.exports = function (env) {
14+
module.exports = function (env, instrument) {
1415
const plugins = [
1516
addExports,
1617
classProperties,
@@ -20,6 +21,8 @@ module.exports = function (env) {
2021
reactRequire
2122
]
2223

24+
if (instrument) { plugins.push(istanbul) }
25+
2326
return {
2427
plugins,
2528
presets: [

lib/browserify.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = browserifyIt
1010
/**
1111
* Bundle some js together with browserify
1212
*/
13-
function browserifyIt ({ config, entry, env, minify }) {
13+
function browserifyIt ({ config, entry, env, instrument }) {
1414
return browserify(entry, {
1515
basedir: process.cwd(),
1616
cache: {},
@@ -21,7 +21,7 @@ function browserifyIt ({ config, entry, env, minify }) {
2121
path.join(__dirname, '/../node_modules'),
2222
path.join(process.cwd(), '/node_modules')
2323
],
24-
transform: transform({ config, env })
24+
transform: transform({ config, env, instrument })
2525
})
2626
}
2727

lib/budo.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const transformCss = require('./css-transform')
66
const logger = require('./logger')
77
const transformJs = require('./js-transform')
88

9-
module.exports = function ({ config, env, files, flyle, proxy }) {
9+
module.exports = function ({ config, env, files, flyle, instrument, proxy }) {
1010
const budoOpts = {
1111
browserify: {
1212
debug: true,
@@ -16,7 +16,8 @@ module.exports = function ({ config, env, files, flyle, proxy }) {
1616
],
1717
transform: transformJs({
1818
config,
19-
env
19+
env,
20+
instrument
2021
})
2122
},
2223
cors: true,

lib/build.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const buildJs = require('./js-build')
99
* @return [Promise] array of Promises
1010
*/
1111

12-
module.exports = function ({ config, env, files, minify, watch }) {
12+
module.exports = function ({ config, env, files, instrument, minify, watch }) {
1313
return Promise.all(
1414
files.map(
1515
([entry, outfile]) =>
1616
path.extname(entry) === '.css'
1717
? buildCss({ config, entry, minify, outfile, watch })
18-
: buildJs({ config, entry, env, minify, outfile, watch })
18+
: buildJs({ config, entry, env, instrument, minify, outfile, watch })
1919
)
2020
)
2121
}

lib/js-build.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ module.exports = function buildJs ({
1616
config,
1717
entry,
1818
env,
19+
instrument,
1920
minify,
2021
outfile,
2122
watch
2223
}) {
2324
const pipeline = minify
24-
? browserify.minify({ config, entry, env })
25-
: browserify({ config, entry, env })
25+
? browserify.minify({ config, entry, env, instrument })
26+
: browserify({ config, entry, env, instrument })
2627
const bundle = () =>
2728
new Promise((resolve, reject) => {
2829
if (outfile) {

lib/js-transform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const pkg = require('../lib/pkg')
99

1010
const babelConfig = require('./babel-config')
1111

12-
module.exports = function transform ({ config, env }) {
12+
module.exports = function transform ({ config, env, instrument }) {
1313
const envvars = Object.assign(
1414
{},
1515
process.env,
@@ -32,7 +32,7 @@ module.exports = function transform ({ config, env }) {
3232
htmlTransform,
3333
markdown,
3434
yamlTransform,
35-
babelify.configure(babelConfig(env)),
35+
babelify.configure(babelConfig(env, instrument)),
3636
[envify(envvars), { global: true }] // Envify needs to happen last...
3737
]
3838
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"babel-eslint": "^9.0.0",
5959
"babel-jest": "^23.4.2",
6060
"babel-plugin-add-module-exports": "^0.2.1",
61+
"babel-plugin-istanbul": "^5.1.0",
6162
"babel-plugin-lodash": "^3.3.4",
6263
"babel-plugin-react-require": "^3.0.0",
6364
"babelify": "^10.0.0",

yarn.lock

+37
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,15 @@ babel-plugin-istanbul@^4.1.6:
12251225
istanbul-lib-instrument "^1.10.1"
12261226
test-exclude "^4.2.1"
12271227

1228+
babel-plugin-istanbul@^5.1.0:
1229+
version "5.1.0"
1230+
resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.0.tgz#6892f529eff65a3e2d33d87dc5888ffa2ecd4a30"
1231+
integrity sha512-CLoXPRSUWiR8yao8bShqZUIC6qLfZVVY3X1wj+QPNXu0wfmrRRfarh1LYy+dYMVI+bDj0ghy3tuqFFRFZmL1Nw==
1232+
dependencies:
1233+
find-up "^3.0.0"
1234+
istanbul-lib-instrument "^3.0.0"
1235+
test-exclude "^5.0.0"
1236+
12281237
babel-plugin-jest-hoist@^23.2.0:
12291238
version "23.2.0"
12301239
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167"
@@ -4793,6 +4802,11 @@ istanbul-lib-coverage@^1.2.0, istanbul-lib-coverage@^1.2.1:
47934802
version "1.2.1"
47944803
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.1.tgz#ccf7edcd0a0bb9b8f729feeb0930470f9af664f0"
47954804

4805+
istanbul-lib-coverage@^2.0.1:
4806+
version "2.0.1"
4807+
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#2aee0e073ad8c5f6a0b00e0dfbf52b4667472eda"
4808+
integrity sha512-nPvSZsVlbG9aLhZYaC3Oi1gT/tpyo3Yt5fNyf6NmcKIayz4VV/txxJFFKAK/gU4dcNn8ehsanBbVHVl0+amOLA==
4809+
47964810
istanbul-lib-hook@^1.2.2:
47974811
version "1.2.2"
47984812
resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.2.2.tgz#bc6bf07f12a641fbf1c85391d0daa8f0aea6bf86"
@@ -4811,6 +4825,19 @@ istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.10.2:
48114825
istanbul-lib-coverage "^1.2.1"
48124826
semver "^5.3.0"
48134827

4828+
istanbul-lib-instrument@^3.0.0:
4829+
version "3.0.0"
4830+
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.0.0.tgz#b5f066b2a161f75788be17a9d556f40a0cf2afc9"
4831+
integrity sha512-eQY9vN9elYjdgN9Iv6NS/00bptm02EBBk70lRMaVjeA6QYocQgenVrSgC28TJurdnZa80AGO3ASdFN+w/njGiQ==
4832+
dependencies:
4833+
"@babel/generator" "^7.0.0"
4834+
"@babel/parser" "^7.0.0"
4835+
"@babel/template" "^7.0.0"
4836+
"@babel/traverse" "^7.0.0"
4837+
"@babel/types" "^7.0.0"
4838+
istanbul-lib-coverage "^2.0.1"
4839+
semver "^5.5.0"
4840+
48144841
istanbul-lib-report@^1.1.5:
48154842
version "1.1.5"
48164843
resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.5.tgz#f2a657fc6282f96170aaf281eb30a458f7f4170c"
@@ -9081,6 +9108,16 @@ test-exclude@^4.2.1:
90819108
read-pkg-up "^1.0.1"
90829109
require-main-filename "^1.0.1"
90839110

9111+
test-exclude@^5.0.0:
9112+
version "5.0.0"
9113+
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.0.0.tgz#cdce7cece785e0e829cd5c2b27baf18bc583cfb7"
9114+
integrity sha512-bO3Lj5+qFa9YLfYW2ZcXMOV1pmQvw+KS/DpjqhyX6Y6UZ8zstpZJ+mA2ERkXfpOqhxsJlQiLeVXD3Smsrs6oLw==
9115+
dependencies:
9116+
arrify "^1.0.1"
9117+
minimatch "^3.0.4"
9118+
read-pkg-up "^4.0.0"
9119+
require-main-filename "^1.0.1"
9120+
90849121
text-extensions@^1.0.0:
90859122
version "1.7.0"
90869123
resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39"

0 commit comments

Comments
 (0)