@hpcc-js/esbuild-plugins 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -45
- package/dist/index.js +7 -206
- package/dist/index.js.map +4 -4
- package/dist/sfx-wrapper.js +5 -5
- package/dist/sfx-wrapper.js.map +4 -4
- package/package.json +62 -63
- package/src/build.ts +143 -140
- package/src/exclude-sourcemap.ts +20 -20
- package/src/index.ts +5 -5
- package/src/problem-matcher.ts +24 -22
- package/src/rebuild-logger.ts +24 -22
- package/src/sfx-wrapper.ts +108 -108
- package/types/build.d.ts +27 -12
package/package.json
CHANGED
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hpcc-js/esbuild-plugins",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Various esbuild plugins",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"types": "./types/index.d.ts",
|
|
9
|
-
"default": "./dist/index.js"
|
|
10
|
-
},
|
|
11
|
-
"./sfx-wrapper": {
|
|
12
|
-
"types": "./types/sfx-wrapper.d.ts",
|
|
13
|
-
"default": "./dist/sfx-wrapper.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"main": "./dist/index.js",
|
|
17
|
-
"types": "./types/index.d.ts",
|
|
18
|
-
"files": [
|
|
19
|
-
"dist/**/*",
|
|
20
|
-
"src/**/*",
|
|
21
|
-
"types/**/*"
|
|
22
|
-
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"clean": "rimraf ./dist ./types",
|
|
25
|
-
"build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
|
|
26
|
-
"build-types-watch": "npm run build-types -- --watch",
|
|
27
|
-
"build-ts-dev": "esbuild ./src/index.ts --platform=node --format=esm --bundle --sourcemap --outfile=./dist/index.js",
|
|
28
|
-
"build-ts": "npm run build-ts-dev -- --minify",
|
|
29
|
-
"build-ts-watch": "npm run build-ts-dev -- --watch",
|
|
30
|
-
"build-dev": "run-p build-types build-ts-dev",
|
|
31
|
-
"build-sfx-wrapper-dev": "esbuild ./src/sfx-wrapper.ts --platform=node --format=esm --bundle --sourcemap --outfile=./dist/sfx-wrapper.js",
|
|
32
|
-
"build-sfx-wrapper": "npm run build-sfx-wrapper-dev -- --minify",
|
|
33
|
-
"build": "run-p build-types build-ts build-sfx-wrapper",
|
|
34
|
-
"lint-skypack": "npx -y @skypack/package-check",
|
|
35
|
-
"lint-eslint": "eslint src/**/*.ts",
|
|
36
|
-
"lint": "run-p lint-eslint lint-skypack",
|
|
37
|
-
"test-cli": "npx . -v",
|
|
38
|
-
"test-cli-help": "npx .",
|
|
39
|
-
"test-node": "npx . -v",
|
|
40
|
-
"update": "npx --yes npm-check-updates -u -t minor"
|
|
41
|
-
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"license": "Apache-2.0"
|
|
1
|
+
{
|
|
2
|
+
"name": "@hpcc-js/esbuild-plugins",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Various esbuild plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./sfx-wrapper": {
|
|
12
|
+
"types": "./types/sfx-wrapper.d.ts",
|
|
13
|
+
"default": "./dist/sfx-wrapper.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./types/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**/*",
|
|
20
|
+
"src/**/*",
|
|
21
|
+
"types/**/*"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rimraf ./dist ./types",
|
|
25
|
+
"build-types": "tsc --project tsconfig.json --emitDeclarationOnly",
|
|
26
|
+
"build-types-watch": "npm run build-types -- --watch",
|
|
27
|
+
"build-ts-dev": "esbuild ./src/index.ts --platform=node --format=esm --bundle --packages=external --sourcemap --outfile=./dist/index.js",
|
|
28
|
+
"build-ts": "npm run build-ts-dev -- --minify",
|
|
29
|
+
"build-ts-watch": "npm run build-ts-dev -- --watch",
|
|
30
|
+
"build-dev": "run-p build-types build-ts-dev",
|
|
31
|
+
"build-sfx-wrapper-dev": "esbuild ./src/sfx-wrapper.ts --platform=node --format=esm --bundle --packages=external --sourcemap --outfile=./dist/sfx-wrapper.js",
|
|
32
|
+
"build-sfx-wrapper": "npm run build-sfx-wrapper-dev -- --minify",
|
|
33
|
+
"build": "run-p build-types build-ts build-sfx-wrapper",
|
|
34
|
+
"lint-skypack": "npx -y @skypack/package-check",
|
|
35
|
+
"lint-eslint": "eslint src/**/*.ts",
|
|
36
|
+
"lint": "run-p lint-eslint lint-skypack",
|
|
37
|
+
"test-cli": "npx . -v",
|
|
38
|
+
"test-cli-help": "npx .",
|
|
39
|
+
"test-node": "npx . -v",
|
|
40
|
+
"update": "npx --yes npm-check-updates -u -t minor"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@hpcc-js/wasm-base91": "1.0.1",
|
|
44
|
+
"@hpcc-js/wasm-zstd": "1.0.1",
|
|
45
|
+
"yargs": "17.7.2",
|
|
46
|
+
"fzstd": "0.1.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"esbuild",
|
|
51
|
+
"plugins",
|
|
52
|
+
"WebAssembly",
|
|
53
|
+
"wasm",
|
|
54
|
+
"sfx"
|
|
55
|
+
],
|
|
56
|
+
"author": "hpcc-systems",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/hpcc-systems/hpcc-js-wasm.git"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://hpcc-systems.github.io/hpcc-js-wasm/",
|
|
62
|
+
"license": "Apache-2.0"
|
|
64
63
|
}
|
package/src/build.ts
CHANGED
|
@@ -1,140 +1,143 @@
|
|
|
1
|
-
import * as process from "process";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import * as esbuild from "esbuild";
|
|
5
|
-
import type { BuildOptions, Format } from "esbuild";
|
|
6
|
-
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
|
|
7
|
-
import yargs from "yargs";
|
|
8
|
-
import { hideBin } from "yargs/helpers";
|
|
9
|
-
import { rebuildLogger } from "./rebuild-logger.ts";
|
|
10
|
-
import { sfxWasm } from "./sfx-wrapper.ts";
|
|
11
|
-
|
|
12
|
-
const
|
|
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
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
import * as process from "process";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import * as esbuild from "esbuild";
|
|
5
|
+
import type { BuildOptions, Format } from "esbuild";
|
|
6
|
+
import { umdWrapper } from "esbuild-plugin-umd-wrapper";
|
|
7
|
+
import yargs from "yargs";
|
|
8
|
+
import { hideBin } from "yargs/helpers";
|
|
9
|
+
import { rebuildLogger } from "./rebuild-logger.ts";
|
|
10
|
+
import { sfxWasm } from "./sfx-wrapper.ts";
|
|
11
|
+
|
|
12
|
+
const myYargs = yargs(hideBin(process.argv));
|
|
13
|
+
myYargs
|
|
14
|
+
.usage("Usage: node esbuild.mjs [options]")
|
|
15
|
+
.demandCommand(0, 0)
|
|
16
|
+
.example("node esbuild.mjs --watch", "Bundle and watch for changes")
|
|
17
|
+
.option("mode", {
|
|
18
|
+
alias: "m",
|
|
19
|
+
describe: "Build mode",
|
|
20
|
+
choices: ["development", "production"],
|
|
21
|
+
default: "production"
|
|
22
|
+
})
|
|
23
|
+
.option("w", {
|
|
24
|
+
alias: "watch",
|
|
25
|
+
describe: "Watch for changes",
|
|
26
|
+
type: "boolean"
|
|
27
|
+
})
|
|
28
|
+
.help("h")
|
|
29
|
+
.alias("h", "help")
|
|
30
|
+
.epilog("https://github.com/hpcc-systems/hpcc-js-wasm")
|
|
31
|
+
;
|
|
32
|
+
|
|
33
|
+
export const pkg = JSON.parse(readFileSync(path.join(process.cwd(), "./package.json"), "utf8"));
|
|
34
|
+
export const NODE_MJS = pkg.type === "module" ? "js" : "mjs";
|
|
35
|
+
export const NODE_CJS = pkg.type === "module" ? "cjs" : "js";
|
|
36
|
+
|
|
37
|
+
export const argv = await myYargs.argv;
|
|
38
|
+
export const isDevelopment = argv.mode === "development";
|
|
39
|
+
export const isProduction = !isDevelopment;
|
|
40
|
+
export const isWatch = argv.watch;
|
|
41
|
+
|
|
42
|
+
export function build(config: BuildOptions) {
|
|
43
|
+
if (isDevelopment && Array.isArray(config.entryPoints)) {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.log("Start: ", config.entryPoints[0], config.outfile);
|
|
46
|
+
}
|
|
47
|
+
return esbuild.build({
|
|
48
|
+
sourcemap: "linked",
|
|
49
|
+
...config,
|
|
50
|
+
plugins: [
|
|
51
|
+
...(config.plugins ?? []),
|
|
52
|
+
sfxWasm()
|
|
53
|
+
]
|
|
54
|
+
}).finally(() => {
|
|
55
|
+
if (isDevelopment && Array.isArray(config.entryPoints)) {
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.log("Stop: ", config.entryPoints[0], config.outfile);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function watch(config: BuildOptions) {
|
|
63
|
+
await build(config);
|
|
64
|
+
return esbuild.context({
|
|
65
|
+
sourcemap: "external",
|
|
66
|
+
...config,
|
|
67
|
+
plugins: [
|
|
68
|
+
...(config.plugins ?? []),
|
|
69
|
+
rebuildLogger(config),
|
|
70
|
+
sfxWasm()
|
|
71
|
+
]
|
|
72
|
+
}).then(ctx => {
|
|
73
|
+
return ctx.watch();
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function buildWatch(config: BuildOptions) {
|
|
78
|
+
return isWatch ? watch(config) : build(config);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function browserTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, external: string[] = []) {
|
|
82
|
+
return buildWatch({
|
|
83
|
+
entryPoints: [input],
|
|
84
|
+
outfile: `${output}.${format === "esm" ? "js" : "umd.js"}`,
|
|
85
|
+
platform: "browser",
|
|
86
|
+
target: "es2022",
|
|
87
|
+
format: format as Format,
|
|
88
|
+
globalName,
|
|
89
|
+
bundle: true,
|
|
90
|
+
minify: isProduction,
|
|
91
|
+
external,
|
|
92
|
+
plugins: format === "umd" ? [umdWrapper({ libraryName: globalName })] : []
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function browserBoth(input: string, output: string, globalName?: string, external: string[] = []) {
|
|
97
|
+
return Promise.all([
|
|
98
|
+
browserTpl(input, output, "esm", globalName, external),
|
|
99
|
+
browserTpl(input, output, "umd", globalName, external)
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function nodeTpl(input: string, output: string, format: Format | "umd" = "esm", external: string[] = []) {
|
|
104
|
+
return buildWatch({
|
|
105
|
+
entryPoints: [input],
|
|
106
|
+
outfile: `${output}.${format === "esm" ? NODE_MJS : NODE_CJS}`,
|
|
107
|
+
platform: "node",
|
|
108
|
+
target: "node20",
|
|
109
|
+
format: format as Format,
|
|
110
|
+
bundle: true,
|
|
111
|
+
minify: isProduction,
|
|
112
|
+
external
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function neutralTpl(input: string, output: string, format: Format | "umd" = "esm", globalName?: string, external: string[] = []) {
|
|
117
|
+
return buildWatch({
|
|
118
|
+
entryPoints: [input],
|
|
119
|
+
outfile: `${output}.${format === "esm" ? "js" : "umd.js"}`,
|
|
120
|
+
platform: "neutral",
|
|
121
|
+
target: "es2022",
|
|
122
|
+
format: format as Format,
|
|
123
|
+
globalName,
|
|
124
|
+
bundle: true,
|
|
125
|
+
minify: isProduction,
|
|
126
|
+
external,
|
|
127
|
+
plugins: format === "umd" ? [umdWrapper()] : []
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function nodeBoth(input: string, output: string, external: string[] = []) {
|
|
132
|
+
return Promise.all([
|
|
133
|
+
nodeTpl(input, output, "esm", external),
|
|
134
|
+
nodeTpl(input, output, "cjs", external)
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function bothTpl(input: string, output: string, globalName?: string, external: string[] = []) {
|
|
139
|
+
return Promise.all([
|
|
140
|
+
browserBoth(input, output, globalName, external),
|
|
141
|
+
nodeTpl(input, output, "cjs", external)
|
|
142
|
+
]);
|
|
143
|
+
}
|
package/src/exclude-sourcemap.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { readFile } from "fs/promises";
|
|
2
|
-
import type { PluginBuild, Plugin } from "esbuild";
|
|
3
|
-
|
|
4
|
-
export interface ExcludeSourcemapOptions {
|
|
5
|
-
filter: RegExp;
|
|
6
|
-
}
|
|
7
|
-
export function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {
|
|
8
|
-
return {
|
|
9
|
-
name: "exclude-sourcemap",
|
|
10
|
-
|
|
11
|
-
setup(build: PluginBuild) {
|
|
12
|
-
build.onLoad({ filter: opts.filter }, async args => {
|
|
13
|
-
return {
|
|
14
|
-
contents: await readFile(args.path, "utf8") + "\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==",
|
|
15
|
-
loader: "default",
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import type { PluginBuild, Plugin } from "esbuild";
|
|
3
|
+
|
|
4
|
+
export interface ExcludeSourcemapOptions {
|
|
5
|
+
filter: RegExp;
|
|
6
|
+
}
|
|
7
|
+
export function excludeSourcemap(opts: ExcludeSourcemapOptions): Plugin {
|
|
8
|
+
return {
|
|
9
|
+
name: "exclude-sourcemap",
|
|
10
|
+
|
|
11
|
+
setup(build: PluginBuild) {
|
|
12
|
+
build.onLoad({ filter: opts.filter }, async args => {
|
|
13
|
+
return {
|
|
14
|
+
contents: await readFile(args.path, "utf8") + "\n//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==",
|
|
15
|
+
loader: "default",
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./build.ts";
|
|
2
|
-
export * from "./exclude-sourcemap.ts";
|
|
3
|
-
export * from "./problem-matcher.ts";
|
|
4
|
-
export * from "./rebuild-logger.ts";
|
|
5
|
-
export * from "./sfx-wrapper.ts";
|
|
1
|
+
export * from "./build.ts";
|
|
2
|
+
export * from "./exclude-sourcemap.ts";
|
|
3
|
+
export * from "./problem-matcher.ts";
|
|
4
|
+
export * from "./rebuild-logger.ts";
|
|
5
|
+
export * from "./sfx-wrapper.ts";
|
package/src/problem-matcher.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import type { PluginBuild, Plugin } from "esbuild";
|
|
2
|
-
|
|
3
|
-
export function problemMatcher(): Plugin {
|
|
4
|
-
return {
|
|
5
|
-
name: "problem-matcher",
|
|
6
|
-
|
|
7
|
-
setup(build: PluginBuild) {
|
|
8
|
-
|
|
9
|
-
build.onStart(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
console.error(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
import type { PluginBuild, Plugin } from "esbuild";
|
|
2
|
+
|
|
3
|
+
export function problemMatcher(): Plugin {
|
|
4
|
+
return {
|
|
5
|
+
name: "problem-matcher",
|
|
6
|
+
|
|
7
|
+
setup(build: PluginBuild) {
|
|
8
|
+
|
|
9
|
+
build.onStart(() => {
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.log("[watch] build started");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
build.onEnd((result) => {
|
|
15
|
+
result.errors.forEach(({ text, location }) => {
|
|
16
|
+
console.error(`✘ [ERROR] ${text}`);
|
|
17
|
+
console.error(` ${location?.file}:${location?.line}:${location?.column}:`);
|
|
18
|
+
});
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log("[watch] build finished");
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
package/src/rebuild-logger.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import type { PluginBuild, Plugin } from "esbuild";
|
|
2
|
-
|
|
3
|
-
export interface RebuildLoggerOptions {
|
|
4
|
-
outfile?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function rebuildLogger(opts: RebuildLoggerOptions): Plugin {
|
|
8
|
-
return {
|
|
9
|
-
name: "rebuild-logger",
|
|
10
|
-
|
|
11
|
-
setup(build: PluginBuild) {
|
|
12
|
-
|
|
13
|
-
build.onStart(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
import type { PluginBuild, Plugin } from "esbuild";
|
|
2
|
+
|
|
3
|
+
export interface RebuildLoggerOptions {
|
|
4
|
+
outfile?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function rebuildLogger(opts: RebuildLoggerOptions): Plugin {
|
|
8
|
+
return {
|
|
9
|
+
name: "rebuild-logger",
|
|
10
|
+
|
|
11
|
+
setup(build: PluginBuild) {
|
|
12
|
+
|
|
13
|
+
build.onStart(() => {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.log("[watch] build started");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
build.onEnd(() => {
|
|
19
|
+
// eslint-disable-next-line no-console
|
|
20
|
+
console.log(`Rebuilt ${opts.outfile ?? "Unknown"}`);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|