Skip to content

Commit

Permalink
Move dependencies to external
Browse files Browse the repository at this point in the history
I undid this recently in the hope that bundling everyhting together will
somehow help the perf (perhaps by better minification), but it had the
opposite effect, likely because we were bundling all of shiki's
languages and themes that need to be parsed as well.

Before
```sh
$ hyperfine --warmup 3 "git --no-pager log -p -n3 | node build/index.mjs"
Benchmark 1: git --no-pager log -p -n3 | node build/index.mjs
  Time (mean ± σ):     350.0 ms ±   8.1 ms    [User: 634.5 ms, System: 31.8 ms]
  Range (min … max):   341.0 ms … 369.5 ms    10 runs
```

After
```sh
$ hyperfine --warmup 3 "git --no-pager log -p -n3 | node build/index.mjs"
Benchmark 1: git --no-pager log -p -n3 | node build/index.mjs
  Time (mean ± σ):     308.0 ms ±   2.3 ms    [User: 602.9 ms, System: 25.2 ms]
  Range (min … max):   303.7 ms … 310.4 ms    10 runs
```
  • Loading branch information
banga committed Jan 5, 2024
1 parent df31766 commit 2cd2eb4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as esbuild from 'esbuild';
import fs from 'fs';

/** @type {esbuild.BuildOptions} */
const commonOptions = {
Expand All @@ -7,7 +8,12 @@ const commonOptions = {
platform: 'node',
target: 'node18',
format: 'esm',
external: ['benchmark'],
external: [
'benchmark',
...Object.keys(
JSON.parse(fs.readFileSync('package.json', 'utf-8')).dependencies
),
],
banner: { js: '#!/usr/bin/env node' },
outExtension: { '.js': '.mjs' },
sourcemap: false,
Expand Down

0 comments on commit 2cd2eb4

Please sign in to comment.