@serenity-is/tsbuild 8.7.4 → 8.8.4
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/dist/index.js +32 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
2
|
import { existsSync, readdirSync, statSync, mkdirSync, writeFileSync, rmSync, readFileSync } from "fs";
|
|
3
|
-
import { join, relative, resolve } from "path";
|
|
4
|
-
import { exit } from "process";
|
|
3
|
+
import { dirname, join, relative, resolve } from "path";
|
|
5
4
|
import { globSync } from "glob";
|
|
6
5
|
|
|
7
6
|
export const defaultEntryPointGlobs = ['Modules/**/*Page.ts', 'Modules/**/*Page.tsx', 'Modules/**/ScriptInit.ts'];
|
|
8
7
|
|
|
9
|
-
export function checkIfTrigger() {
|
|
10
|
-
if (process.argv.slice(2).some(x => x == "--trigger")) {
|
|
11
|
-
if (existsSync('typings/serenity.corelib/_trigger.ts'))
|
|
12
|
-
rmSync('typings/serenity.corelib/_trigger.ts')
|
|
13
|
-
else {
|
|
14
|
-
if (!existsSync('typings/serenity.corelib/'))
|
|
15
|
-
mkdirSync('typings/serenity.corelib/');
|
|
16
|
-
writeFileSync('typings/serenity.corelib/_trigger.ts', '// for triggering build');
|
|
17
|
-
}
|
|
18
|
-
exit(0);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
8
|
export const importAsGlobalsMapping = {
|
|
23
9
|
"@serenity-is/base": "Serenity",
|
|
24
10
|
"@serenity-is/corelib": "Serenity",
|
|
@@ -107,8 +93,14 @@ export const esbuildOptions = (opt) => {
|
|
|
107
93
|
plugins.push(importAsGlobalsPlugin(opt.importAsGlobals ?? importAsGlobalsMapping));
|
|
108
94
|
}
|
|
109
95
|
|
|
96
|
+
if (opt.write === undefined && opt.writeIfChanged === undefined || opt.writeIfChanged) {
|
|
97
|
+
plugins.push(writeIfChanged());
|
|
98
|
+
opt.write = false;
|
|
99
|
+
}
|
|
100
|
+
|
|
110
101
|
delete opt.clean;
|
|
111
102
|
delete opt.importAsGlobals;
|
|
103
|
+
delete opt.writeIfChanged;
|
|
112
104
|
|
|
113
105
|
return Object.assign({
|
|
114
106
|
absWorkingDir: resolve('./'),
|
|
@@ -208,4 +200,29 @@ export function cleanPlugin() {
|
|
|
208
200
|
});
|
|
209
201
|
}
|
|
210
202
|
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function checkIfTrigger() {
|
|
206
|
+
// nop
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function writeIfChanged() {
|
|
210
|
+
return {
|
|
211
|
+
name: "write-if-changed",
|
|
212
|
+
setup(build) {
|
|
213
|
+
build.onEnd(result => {
|
|
214
|
+
result.outputFiles?.forEach(file => {
|
|
215
|
+
if (existsSync(file.path)) {
|
|
216
|
+
const old = readFileSync(file.path);
|
|
217
|
+
if (old.equals(file.contents))
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
mkdirSync(dirname(file.path), { recursive: true });
|
|
222
|
+
}
|
|
223
|
+
writeFileSync(file.path, file.text);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
};
|
|
211
228
|
}
|