-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We're not quite ready to switch to `bun` for the entire project yet. In particular, we still rely on `npm` and `package-lock.json` for dependency installation. For remaining blockers, see: #294
- Loading branch information
Showing
29 changed files
with
987 additions
and
31 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
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
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,23 @@ | ||
import { build } from "esbuild"; | ||
|
||
await build({ | ||
entryPoints: ["src/bin/*.ts"], | ||
outdir: "dist/bin/", | ||
chunkNames: "chunks/[name]-[hash]", | ||
format: "esm", | ||
target: "es2022", | ||
bundle: true, | ||
logLevel: "info", | ||
sourcemap: true, | ||
splitting: true, | ||
packages: "external", | ||
external: ["cubing/*"], | ||
supported: { | ||
"top-level-await": true, | ||
}, | ||
banner: { | ||
js: "#!/usr/bin/env node", | ||
}, | ||
}); | ||
|
||
// Note: the output entry files are `chmod`ded by the `Makefile`. |
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,34 @@ | ||
import { join } from "node:path"; | ||
import type { BuildOptions } from "esbuild"; | ||
import type { IterableElement } from "../../lib/vendor/type-fest"; | ||
|
||
export const packageNames = [ | ||
"alg", | ||
"bluetooth", | ||
"kpuzzle", | ||
"notation", | ||
"protocol", | ||
"puzzle-geometry", | ||
"puzzles", | ||
"scramble", | ||
"stream", | ||
"search", | ||
"twisty", | ||
]; | ||
|
||
export const packageEntryPoints: string[] = packageNames.map((p) => | ||
join("src/cubing/", p, "/index.ts"), | ||
); | ||
|
||
export const searchWorkerEsbuildWorkaroundEntry: IterableElement< | ||
BuildOptions["entryPoints"] | ||
> = { | ||
in: "src/cubing/search/worker-workarounds/search-worker-entry.js", | ||
// esbuild automatically adds `.js` | ||
// https://esbuild.github.io/api/#entry-points | ||
out: "chunks/search-worker-entry", | ||
}; | ||
|
||
export const packageEntryPointsWithSearchWorkerEntry: BuildOptions["entryPoints"] = | ||
// @ts-ignore: TypeScript can't seem to reconcile the types, no matter how much we annotate. | ||
packageEntryPoints.concat([searchWorkerEsbuildWorkaroundEntry]); |
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,31 @@ | ||
import { build, type BuildOptions } from "esbuild"; | ||
import { mkdir, writeFile } from "node:fs/promises"; | ||
import { packageEntryPointsWithSearchWorkerEntry } from "../common/package-info"; | ||
|
||
// In theory we could set `packages: "external"` here and rely on `make | ||
// test-src-import-restrictions`, but this is safer. | ||
export const external = ["three", "comlink", "random-uint-below"]; | ||
|
||
export const esmOptions: BuildOptions = { | ||
// TODO: construct entry points based on `exports` and add tests. | ||
entryPoints: packageEntryPointsWithSearchWorkerEntry, | ||
outdir: "dist/lib/cubing", | ||
chunkNames: "chunks/[name]-[hash]", | ||
format: "esm", | ||
target: "es2022", | ||
bundle: true, | ||
splitting: true, | ||
logLevel: "info", | ||
sourcemap: true, | ||
// | ||
external: external, | ||
metafile: true, | ||
}; | ||
|
||
const result = await build(esmOptions); | ||
|
||
await mkdir("./.temp", { recursive: true }); | ||
await writeFile( | ||
"./.temp/esbuild-metafile.json", | ||
JSON.stringify(result.metafile), | ||
); |
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,15 @@ | ||
import { spawnPromise } from "../../lib/execPromise"; | ||
import { packageEntryPoints } from "../common/package-info"; | ||
|
||
console.warn(` | ||
⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳ | ||
Note: The \`types\` target is slow. Expect several seconds. | ||
⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳⏳ | ||
`); | ||
await spawnPromise("npx", [ | ||
"tsup", | ||
...packageEntryPoints, | ||
"--dts-only", | ||
"--out-dir", | ||
"dist/lib/cubing", | ||
]); |
Oops, something went wrong.