Skip to content

Commit 156d334

Browse files
committed
Bundle CLI into single file for faster startup
Category: fix
1 parent d15721f commit 156d334

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

cli-dist.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
"description": "Markdown Style Guide, with linter and automatic fixer",
55
"author": "Vincent Weevers",
66
"license": "GPL-3.0",
7-
"bin": "cli.js",
7+
"bin": "cli-dist.js",
88
"type": "module",
99
"exports": "./index.js",
1010
"scripts": {
11-
"test": "standard && depcheck --ignores subarg && node cli.js && tape test/*.js",
12-
"hallmark": "node cli.js fix"
11+
"test": "standard && depcheck --ignores subarg && node cli-dist.js && tape test/*.js",
12+
"hallmark": "node cli-dist.js fix",
13+
"pack": "rollup -c"
1314
},
1415
"files": [
1516
"CHANGELOG.md",
16-
"cli.js",
17+
"cli-dist.js",
1718
"index.js",
1819
"lint.js",
1920
"USAGE"
@@ -62,12 +63,20 @@
6263
"vfile-reporter-shiny": "^1.0.1"
6364
},
6465
"devDependencies": {
66+
"@rollup/plugin-commonjs": "^25.0.7",
67+
"@rollup/plugin-json": "^6.1.0",
68+
"@rollup/plugin-node-resolve": "^15.2.3",
69+
"@rollup/plugin-terser": "^0.4.4",
6570
"depcheck": "^1.4.2",
6671
"git-pull-or-clone": "^2.0.2",
72+
"rollup": "^4.14.0",
6773
"standard": "^17.0.0",
6874
"tape": "^5.5.3",
6975
"tempy": "^3.0.0"
7076
},
77+
"standard": {
78+
"ignore": ["cli-dist.js"]
79+
},
7180
"repository": {
7281
"type": "git",
7382
"url": "https://github.com/vweevers/hallmark.git"

rollup.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { nodeResolve } from '@rollup/plugin-node-resolve'
2+
import commonjs from '@rollup/plugin-commonjs'
3+
import json from '@rollup/plugin-json'
4+
import terser from '@rollup/plugin-terser'
5+
6+
export default {
7+
input: 'cli.js',
8+
output: {
9+
file: 'cli-dist.js',
10+
format: 'es'
11+
},
12+
plugins: [
13+
commonjs(),
14+
nodeResolve({
15+
browser: false,
16+
preferBuiltins: true,
17+
exportConditions: ['node']
18+
}),
19+
json(),
20+
terser({
21+
module: true,
22+
format: {
23+
comments: false
24+
}
25+
})
26+
]
27+
}

test/dependents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for (const repo of dependents) {
3434

3535
// Pipe stdout to stderr because our stdout is for TAP
3636
const stdio = ['ignore', process.stderr, process.stderr, 'ipc']
37-
const cli = path.resolve(__dirname, '..', 'cli.js')
37+
const cli = path.resolve(__dirname, '..', 'cli-dist.js')
3838

3939
cp.fork(cli, { cwd, stdio }).on('exit', function (code) {
4040
t.is(code, 0, 'hallmark linter exited with code 0')

0 commit comments

Comments
 (0)