@serenity-is/tsbuild 8.8.6 → 8.8.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/dist/index.d.ts +2 -1
- package/dist/index.js +60 -3
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -58,4 +58,5 @@ export interface TSBuildOptions {
|
|
|
58
58
|
export const esbuildOptions: (opt: TSBuildOptions) => any;
|
|
59
59
|
export const build: (opt: TSBuildOptions) => Promise<void>;
|
|
60
60
|
export function importAsGlobalsPlugin(mapping: Record<string, string>): any;
|
|
61
|
-
export function cleanPlugin(): any;
|
|
61
|
+
export function cleanPlugin(): any;
|
|
62
|
+
export function npmCopy(paths: string[], outdir?: string): void;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, readdirSync, statSync, mkdirSync, writeFileSync, rmSync, re
|
|
|
3
3
|
import { dirname, join, relative, resolve } from "path";
|
|
4
4
|
import { globSync } from "glob";
|
|
5
5
|
|
|
6
|
-
export const defaultEntryPointGlobs = ['Modules/**/*Page.ts', 'Modules/**/*Page.tsx', 'Modules/**/ScriptInit.ts'];
|
|
6
|
+
export const defaultEntryPointGlobs = ['Modules/**/*Page.ts', 'Modules/**/*Page.tsx', 'Modules/**/ScriptInit.ts', 'Modules/**/*.mts'];
|
|
7
7
|
|
|
8
8
|
export const importAsGlobalsMapping = {
|
|
9
9
|
"@serenity-is/base": "Serenity",
|
|
@@ -39,8 +39,11 @@ export const esbuildOptions = (opt) => {
|
|
|
39
39
|
var json = readFileSync('sergen.json', 'utf8').trim();
|
|
40
40
|
var cfg = JSON.parse(json || {});
|
|
41
41
|
globs = cfg?.TSBuild?.EntryPoints;
|
|
42
|
+
if (globs != null && globs[0] === '+') {
|
|
43
|
+
globs = [...defaultEntryPointGlobs, ...globs.slice(1)];
|
|
44
|
+
}
|
|
42
45
|
if (globs === void 0 &&
|
|
43
|
-
cfg.Extends &&
|
|
46
|
+
typeof cfg.Extends == "string" &&
|
|
44
47
|
existsSync(cfg.Extends)) {
|
|
45
48
|
json = readFileSync(cfg.Extends, 'utf8').trim();
|
|
46
49
|
cfg = JSON.parse(json || {});
|
|
@@ -79,7 +82,7 @@ export const esbuildOptions = (opt) => {
|
|
|
79
82
|
.forEach(p => entryPoints.push(root + '/' + p)));
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
|
|
85
|
+
|
|
83
86
|
var splitting = opt.splitting;
|
|
84
87
|
if (splitting === undefined)
|
|
85
88
|
splitting = !process.argv.slice(2).some(x => x == "--nosplit");
|
|
@@ -124,6 +127,21 @@ export const esbuildOptions = (opt) => {
|
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
export const build = async (opt) => {
|
|
130
|
+
if (opt?.npmCopy !== false &&
|
|
131
|
+
existsSync('appsettings.bundles.json')) {
|
|
132
|
+
const bundlesJson = readFileSync('appsettings.bundles.json', 'utf8').trim();
|
|
133
|
+
const bundlesCfg = JSON.parse(bundlesJson || {});
|
|
134
|
+
const bundles = Object.values(bundlesCfg?.CssBundling?.Bundles || {}).concat(Object.values(bundlesCfg?.ScriptBundling?.Bundles || {}));
|
|
135
|
+
let paths = [];
|
|
136
|
+
Object.values(bundles).filter(x => x?.length).forEach(bundle => {
|
|
137
|
+
paths.push(...bundle.filter(f => f?.startsWith('~/npm/')).map(f => f.substring(5)));
|
|
138
|
+
});
|
|
139
|
+
paths = paths.filter((v, i, a) => a.indexOf(v) === i); // unique
|
|
140
|
+
if (paths.length) {
|
|
141
|
+
npmCopy(paths);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
127
145
|
opt = esbuildOptions(opt);
|
|
128
146
|
|
|
129
147
|
if (opt.watch) {
|
|
@@ -225,4 +243,43 @@ export function writeIfChanged() {
|
|
|
225
243
|
});
|
|
226
244
|
}
|
|
227
245
|
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function npmCopy(paths) {
|
|
249
|
+
paths.forEach(path => {
|
|
250
|
+
const srcFile = join("node_modules", path);
|
|
251
|
+
const dstfile = join("wwwroot/npm", path);
|
|
252
|
+
if (!existsSync(srcFile)) {
|
|
253
|
+
console.warn(`Source file not found: ${srcFile}`);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
(function() {
|
|
258
|
+
const srcContent = readFileSync(srcFile);
|
|
259
|
+
if (existsSync(dstfile)) {
|
|
260
|
+
if (readFileSync(dstfile).equals(srcContent))
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
mkdirSync(dirname(dstfile), { recursive: true });
|
|
265
|
+
}
|
|
266
|
+
console.log(`Copying ${srcFile} to ${dstfile}`);
|
|
267
|
+
writeFileSync(dstfile, srcContent);
|
|
268
|
+
})();
|
|
269
|
+
|
|
270
|
+
const js = path.endsWith(".js");
|
|
271
|
+
if ((js && !path.endsWith(".min.js")) ||
|
|
272
|
+
(path.endsWith(".css") && !path.endsWith(".min.css"))) {
|
|
273
|
+
const ext = js ? ".min.js" : ".min.css";
|
|
274
|
+
const srcMinFile = srcFile.substring(0, srcFile.length - (js ? 3 : 4)) + ext;
|
|
275
|
+
const dstMinFile = dstfile.substring(0, dstfile.length - (js ? 3 : 4)) + ext;
|
|
276
|
+
if (existsSync(srcMinFile)) {
|
|
277
|
+
const srcMinContent = readFileSync(srcMinFile);
|
|
278
|
+
if (existsSync(dstMinFile) && readFileSync(dstMinFile).equals(srcMinContent))
|
|
279
|
+
return;
|
|
280
|
+
console.log(`Copying ${srcMinFile} to ${dstMinFile}`);
|
|
281
|
+
writeFileSync(dstMinFile, srcMinContent);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
228
285
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serenity-is/tsbuild",
|
|
3
|
-
"version": "8.8.
|
|
3
|
+
"version": "8.8.8",
|
|
4
4
|
"author": "Serenity (https://serenity.is)",
|
|
5
5
|
"bugs": "https://github.com/serenity-is/serenity/issues",
|
|
6
6
|
"description": "Serenity ESBuild functions",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"esbuild": "0.25.
|
|
9
|
-
"glob": "11.0.
|
|
8
|
+
"esbuild": "0.25.9",
|
|
9
|
+
"glob": "11.0.3"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|