-
Notifications
You must be signed in to change notification settings - Fork 0
/
Herebyfile.mjs
83 lines (73 loc) · 1.83 KB
/
Herebyfile.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: 2023 Lynn Kirby
import esbuild from "esbuild";
import { execa } from "execa";
import { task } from "hereby";
//=============================================================================
// Build.
export const buildDTS = task({
name: "build-dts",
description: "Build type definitions",
async run() {
await execa("tsc", ["-p", "src/tsconfig.json"], { preferLocal: true });
// TODO: Bundle with api-extractor.
},
});
export const buildJS = task({
name: "build-js",
description: "Build code bundle",
async run() {
// TODO: Remove asserts.
await esbuild.build({
entryPoints: ["src/index.ts"],
outfile: "dist/charconv.js",
bundle: true,
platform: "neutral",
target: "es2022",
format: "esm",
sourcemap: true,
});
},
});
export const build = task({
name: "build",
description: "Build package",
dependencies: [buildDTS, buildJS],
});
//=============================================================================
// Testing.
// TODO:
// - Watch mode (`--watch`)
// - Select variant
const variant = "bundle";
export const testNode = task({
name: "test-node",
description: "Run tests with Node.js",
async run() {
await execa("vitest", ["run"], {
env: {
...process.env,
CHARCONV_VARIANT: variant,
},
preferLocal: true,
stdout: "inherit",
stderr: "inherit",
});
},
});
export const testChrome = task({
name: "test-chrome",
description: "Run tests on Chrome",
async run() {
const args = ["run", "--browser.name=chrome", "--browser.headless"];
await execa("vitest", args, {
env: {
...process.env,
CHARCONV_VARIANT: variant,
},
preferLocal: true,
stdout: "inherit",
stderr: "inherit",
});
},
});