@serenity-is/tsbuild 6.2.8 → 6.2.9
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 +30 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,7 +26,9 @@ export const importAsGlobalsMapping = {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const esbuildOptions = (opt) => {
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
opt = Object.assign({}, opt);
|
|
31
|
+
|
|
30
32
|
var entryPointsRegEx = /(Page|ScriptInit)\.ts$/;
|
|
31
33
|
if (opt.entryPointsRegEx !== undefined) {
|
|
32
34
|
entryPointsRegEx = opt.entryPointsRegEx;
|
|
@@ -42,12 +44,28 @@ export const esbuildOptions = (opt) => {
|
|
|
42
44
|
var entryPoints = opt.entryPoints;
|
|
43
45
|
if (entryPoints === undefined) {
|
|
44
46
|
entryPoints = [];
|
|
45
|
-
entryPointRoots.forEach(root =>
|
|
47
|
+
entryPointRoots.forEach(root =>
|
|
46
48
|
scanDir(root)
|
|
47
49
|
.filter(p => p.match(entryPointsRegEx))
|
|
48
50
|
.forEach(p => entryPoints.push(root + '/' + p)));
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
|
|
53
|
+
var splitting = opt.splitting;
|
|
54
|
+
if (splitting === undefined)
|
|
55
|
+
splitting = !process.argv.slice(2).some(x => x == "--nosplit");
|
|
56
|
+
|
|
57
|
+
var plugins = opt.plugins;
|
|
58
|
+
if (plugins === undefined) {
|
|
59
|
+
plugins = [];
|
|
60
|
+
if ((opt.clean === undefined && splitting) || opt.clean)
|
|
61
|
+
plugins.push(cleanPlugin());
|
|
62
|
+
if (opt.importAsGlobals === undefined || opt.importAsGlobals)
|
|
63
|
+
plugins.push(importAsGlobalsPlugin(opt.importAsGlobals ?? importAsGlobalsMapping));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
delete opt.clean;
|
|
67
|
+
delete opt.importAsGlobals;
|
|
68
|
+
|
|
51
69
|
return Object.assign({
|
|
52
70
|
absWorkingDir: resolve('./'),
|
|
53
71
|
bundle: true,
|
|
@@ -61,14 +79,11 @@ export const esbuildOptions = (opt) => {
|
|
|
61
79
|
minify: true,
|
|
62
80
|
outbase: "./",
|
|
63
81
|
outdir: 'wwwroot/esm',
|
|
82
|
+
plugins,
|
|
64
83
|
sourcemap: true,
|
|
65
|
-
splitting:
|
|
84
|
+
splitting: splitting,
|
|
66
85
|
target: 'es6',
|
|
67
86
|
watch: process.argv.slice(2).some(x => x == "--watch"),
|
|
68
|
-
plugins: [
|
|
69
|
-
cleanPlugin(),
|
|
70
|
-
importAsGlobalsPlugin(opt.importAsGlobalsMapping ?? importAsGlobalsMapping)
|
|
71
|
-
]
|
|
72
87
|
}, opt);
|
|
73
88
|
}
|
|
74
89
|
|
|
@@ -82,7 +97,7 @@ export const build = async (opt) => {
|
|
|
82
97
|
process.stdout.write("");
|
|
83
98
|
}, 5000);
|
|
84
99
|
}
|
|
85
|
-
|
|
100
|
+
|
|
86
101
|
await esbuild.build(esbuildOptions(opt));
|
|
87
102
|
};
|
|
88
103
|
|
|
@@ -105,7 +120,7 @@ export function importAsGlobalsPlugin(mapping) {
|
|
|
105
120
|
name: "global-imports",
|
|
106
121
|
setup(build) {
|
|
107
122
|
build.onResolve({ filter }, (args) => {
|
|
108
|
-
if (!mapping[args.path])
|
|
123
|
+
if (!mapping[args.path])
|
|
109
124
|
throw new Error("Unknown global: " + args.path);
|
|
110
125
|
return { path: args.path, namespace: "external-global" };
|
|
111
126
|
});
|
|
@@ -131,8 +146,12 @@ export function cleanPlugin() {
|
|
|
131
146
|
|
|
132
147
|
const outputFiles = new Set(Object.keys(outputs));
|
|
133
148
|
scanDir(build.initialOptions.outdir).forEach(file => {
|
|
134
|
-
if (!
|
|
149
|
+
if (!file.endsWith('.js') && !file.endsWith('.js.map'))
|
|
150
|
+
return;
|
|
151
|
+
if (!outputFiles.has(join(build.initialOptions.outdir, file).replace(/\\/g, '/'))) {
|
|
152
|
+
console.log('esbuild clean: deleting extra file ' + file);
|
|
135
153
|
rmSync(join(build.initialOptions.outdir, file));
|
|
154
|
+
}
|
|
136
155
|
});
|
|
137
156
|
} catch (e) {
|
|
138
157
|
console.error(`esbuild clean: ${e}`);
|