-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance HTML tracer to visualize prune order (#103)
* wip * wip * finish up * rm gitignored
- Loading branch information
1 parent
fbeb910
commit 69277e7
Showing
20 changed files
with
1,135 additions
and
958 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,3 +131,5 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
src/base/htmlTracerSrc.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as assert from 'assert'; | ||
import * as chokidar from 'chokidar'; | ||
import * as esbuild from 'esbuild'; | ||
import { writeFileSync } from 'fs'; | ||
|
||
const watch = process.argv.includes("--watch"); | ||
const minify = watch ? process.argv.includes("--minify") : !process.argv.includes("--no-minify"); | ||
|
||
const ctx = esbuild.context({ | ||
entryPoints: [ | ||
"src/tracer/index.tsx", | ||
], | ||
tsconfig: "src/tracer/tsconfig.json", | ||
bundle: true, | ||
sourcemap: minify ? false : 'inline', | ||
minify, | ||
platform: "browser", | ||
outdir: "out", | ||
write: false, | ||
}); | ||
|
||
function build() { | ||
return ctx.then(ctx => ctx.rebuild()) | ||
.then(bundle => { | ||
assert.strictEqual(bundle.outputFiles.length, 2, 'expected to have 2 output files'); | ||
|
||
const css = bundle.outputFiles.find(o => o.path.endsWith('.css')); | ||
assert.ok(css, 'expected to have css'); | ||
const js = bundle.outputFiles.find(o => o.path.endsWith('.js')); | ||
assert.ok(js, 'expected to have js'); | ||
writeFileSync("src/base/htmlTracerSrc.ts", `export const tracerSrc = ${JSON.stringify(js.text)};\nexport const tracerCss = ${JSON.stringify(css.text)};`); | ||
}) | ||
.catch(err => { | ||
if (err.errors) { | ||
console.error(err.errors.join('\n')); | ||
} else { | ||
console.error(err); | ||
} | ||
}); | ||
} | ||
|
||
if (watch) { | ||
let timeout: NodeJS.Timeout | null = null; | ||
chokidar.watch("src/tracer/**/*.{tsx,ts,css}", {}).on('all', () => { | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
} | ||
timeout = setTimeout(build, 600); | ||
}) | ||
} else { | ||
build().then(() => { | ||
process.exit(0); | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.