@serenity-is/tsbuild 6.2.8 → 6.4.3

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.
Files changed (3) hide show
  1. package/LICENSE.md +20 -0
  2. package/dist/index.js +30 -11
  3. package/package.json +2 -5
package/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Volkan Ceylan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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: !process.argv.slice(2).some(x => x == "--nosplit"),
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 (!outputFiles.has(join(build.initialOptions.outdir, file).replace(/\\/g, '/')))
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}`);
package/package.json CHANGED
@@ -1,14 +1,11 @@
1
1
  {
2
2
  "name": "@serenity-is/tsbuild",
3
- "version": "6.2.8",
3
+ "version": "6.4.3",
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.15.11"
9
- },
10
- "optionalDependencies": {
11
- "fsevents": "2.3.2"
8
+ "esbuild": "0.16.14"
12
9
  },
13
10
  "exports": {
14
11
  ".": {