Skip to content

Commit

Permalink
Bundle CLI into single file for faster startup
Browse files Browse the repository at this point in the history
Category: fix
  • Loading branch information
vweevers committed Apr 6, 2024
1 parent 08bcd0e commit c66553d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cli-dist.js

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
"description": "Markdown Style Guide, with linter and automatic fixer",
"author": "Vincent Weevers",
"license": "GPL-3.0",
"bin": "cli.js",
"bin": "cli-dist.js",
"type": "module",
"exports": "./index.js",
"scripts": {
"test": "standard && depcheck --ignores subarg && node cli.js && tape test/*.js",
"hallmark": "node cli.js fix"
"test": "standard && depcheck --ignores subarg && node cli-dist.js && tape test/*.js",
"hallmark": "node cli-dist.js fix",
"pack": "rollup -c"
},
"files": [
"CHANGELOG.md",
"cli.js",
"cli-dist.js",
"index.js",
"lint.js",
"USAGE"
Expand Down Expand Up @@ -62,12 +63,20 @@
"vfile-reporter-shiny": "^1.0.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"depcheck": "^1.4.2",
"git-pull-or-clone": "^2.0.2",
"rollup": "^4.14.0",
"standard": "^17.0.0",
"tape": "^5.5.3",
"tempy": "^3.0.0"
},
"standard": {
"ignore": ["cli-dist.js"]
},
"repository": {
"type": "git",
"url": "https://github.com/vweevers/hallmark.git"
Expand Down
27 changes: 27 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import terser from '@rollup/plugin-terser'

export default {
input: 'cli.js',
output: {
file: 'cli-dist.js',
format: 'es'
},
plugins: [
commonjs(),
nodeResolve({
browser: false,
preferBuiltins: true,
exportConditions: ['node']
}),
json(),
terser({
module: true,
format: {
comments: false
}
})
]
}
2 changes: 1 addition & 1 deletion test/dependents.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ for (const repo of dependents) {

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

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

0 comments on commit c66553d

Please sign in to comment.