@zthun/janitor-build-config 19.2.0 → 19.2.2
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/typedoc.cjs +107 -80
- package/dist/typedoc.cjs.map +1 -1
- package/dist/typedoc.js +104 -81
- package/dist/typedoc.js.map +1 -1
- package/dist/vite/vite-config-builder.d.mts +1 -8
- package/dist/vite.cjs +449 -223
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +446 -227
- package/dist/vite.js.map +1 -1
- package/package.json +5 -5
package/dist/vite.cjs
CHANGED
|
@@ -1,20 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const react = require('@vitejs/plugin-react');
|
|
6
|
+
const lodashEs = require('lodash-es');
|
|
7
|
+
const swc = require('unplugin-swc');
|
|
8
|
+
const vitePluginChecker = require('vite-plugin-checker');
|
|
9
|
+
const dtsPlugin = require('vite-plugin-dts');
|
|
10
|
+
const vitePluginExternalizeDeps = require('vite-plugin-externalize-deps');
|
|
11
|
+
const tsConfigPaths = require('vite-tsconfig-paths');
|
|
12
|
+
|
|
13
|
+
function _define_property$3(obj, key, value) {
|
|
14
|
+
if (key in obj) {
|
|
15
|
+
Object.defineProperty(obj, key, {
|
|
16
|
+
value: value,
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
obj[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function _object_spread$2(target) {
|
|
27
|
+
for(var i = 1; i < arguments.length; i++){
|
|
28
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
29
|
+
var ownKeys = Object.keys(source);
|
|
30
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
31
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
32
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
ownKeys.forEach(function(key) {
|
|
36
|
+
_define_property$3(target, key, source[key]);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return target;
|
|
40
|
+
}
|
|
41
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
42
|
+
var keys = Object.keys(object);
|
|
43
|
+
if (Object.getOwnPropertySymbols) {
|
|
44
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
45
|
+
keys.push.apply(keys, symbols);
|
|
46
|
+
}
|
|
47
|
+
return keys;
|
|
48
|
+
}
|
|
49
|
+
function _object_spread_props$2(target, source) {
|
|
50
|
+
source = source != null ? source : {};
|
|
51
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
52
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
53
|
+
} else {
|
|
54
|
+
ownKeys$2(Object(source)).forEach(function(key) {
|
|
55
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A builder for Vite library configurations.
|
|
62
|
+
*/ class ZViteLibraryBuilder {
|
|
63
|
+
/**
|
|
18
64
|
* Adds an entry point to the library.
|
|
19
65
|
*
|
|
20
66
|
* @param name -
|
|
@@ -24,53 +70,91 @@ class ZViteLibraryBuilder {
|
|
|
24
70
|
*
|
|
25
71
|
* @returns
|
|
26
72
|
* This object.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
73
|
+
*/ entry(name, path) {
|
|
74
|
+
this.library.entry = _object_spread_props$2(_object_spread$2({}, this.library.entry), {
|
|
75
|
+
[name]: path
|
|
76
|
+
});
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
36
80
|
* A shorthand for adding an entry point
|
|
37
81
|
* named "index" that points to "src/index.ts"
|
|
38
82
|
*
|
|
39
83
|
* @returns
|
|
40
84
|
* This object.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
85
|
+
*/ index() {
|
|
86
|
+
return this.entry("index", "./src/index.mts");
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
46
89
|
* Returns the built library configuration.
|
|
47
90
|
*
|
|
48
91
|
* @returns
|
|
49
92
|
* A deep clone of the library configuration.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
93
|
+
*/ build() {
|
|
94
|
+
return lodashEs.cloneDeep(this.library);
|
|
95
|
+
}
|
|
96
|
+
constructor(){
|
|
97
|
+
_define_property$3(this, "library", {
|
|
98
|
+
entry: {},
|
|
99
|
+
formats: [
|
|
100
|
+
"es",
|
|
101
|
+
"cjs"
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
54
105
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
106
|
+
|
|
107
|
+
function _define_property$2(obj, key, value) {
|
|
108
|
+
if (key in obj) {
|
|
109
|
+
Object.defineProperty(obj, key, {
|
|
110
|
+
value: value,
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
obj[key] = value;
|
|
117
|
+
}
|
|
118
|
+
return obj;
|
|
119
|
+
}
|
|
120
|
+
function _object_spread$1(target) {
|
|
121
|
+
for(var i = 1; i < arguments.length; i++){
|
|
122
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
123
|
+
var ownKeys = Object.keys(source);
|
|
124
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
125
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
126
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
ownKeys.forEach(function(key) {
|
|
130
|
+
_define_property$2(target, key, source[key]);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return target;
|
|
134
|
+
}
|
|
135
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
136
|
+
var keys = Object.keys(object);
|
|
137
|
+
if (Object.getOwnPropertySymbols) {
|
|
138
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
139
|
+
keys.push.apply(keys, symbols);
|
|
140
|
+
}
|
|
141
|
+
return keys;
|
|
142
|
+
}
|
|
143
|
+
function _object_spread_props$1(target, source) {
|
|
144
|
+
source = source != null ? source : {};
|
|
145
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
146
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
147
|
+
} else {
|
|
148
|
+
ownKeys$1(Object(source)).forEach(function(key) {
|
|
149
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return target;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A builder for test configurations found in vite's defineConfig test field.
|
|
156
|
+
*/ class ZViteTestBuilder {
|
|
157
|
+
/**
|
|
74
158
|
* Sets the test environment.
|
|
75
159
|
*
|
|
76
160
|
* @param environment -
|
|
@@ -78,12 +162,11 @@ class ZViteTestBuilder {
|
|
|
78
162
|
*
|
|
79
163
|
* @returns
|
|
80
164
|
* This object.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/**
|
|
165
|
+
*/ environment(environment) {
|
|
166
|
+
this.test.environment = environment;
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
87
170
|
* Sets the test coverage provider.
|
|
88
171
|
*
|
|
89
172
|
* @param provider -
|
|
@@ -91,12 +174,13 @@ class ZViteTestBuilder {
|
|
|
91
174
|
*
|
|
92
175
|
* @returns
|
|
93
176
|
* This object.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
177
|
+
*/ coverage(provider) {
|
|
178
|
+
this.test.coverage = _object_spread_props$1(_object_spread$1({}, this.test.coverage), {
|
|
179
|
+
provider
|
|
180
|
+
});
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
100
184
|
* Adds to the list of projects.
|
|
101
185
|
*
|
|
102
186
|
* @param project -
|
|
@@ -104,13 +188,12 @@ class ZViteTestBuilder {
|
|
|
104
188
|
*
|
|
105
189
|
* @returns
|
|
106
190
|
* This object.
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/**
|
|
191
|
+
*/ project(project = []) {
|
|
192
|
+
const projects = this.test.projects || [];
|
|
193
|
+
this.test.projects = projects.concat(project);
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
114
197
|
* Adds monorepo support to the test builder.
|
|
115
198
|
*
|
|
116
199
|
* @param packages -
|
|
@@ -118,35 +201,144 @@ class ZViteTestBuilder {
|
|
|
118
201
|
*
|
|
119
202
|
* @returns
|
|
120
203
|
* This object.
|
|
121
|
-
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/**
|
|
204
|
+
*/ monorepo(packages = "packages") {
|
|
205
|
+
return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
126
208
|
* Returns the built test configuration.
|
|
127
209
|
*
|
|
128
210
|
* @returns
|
|
129
211
|
* A deep clone of the test configuration.
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
class ZViteConfigBuilder {
|
|
136
|
-
/**
|
|
212
|
+
*/ build() {
|
|
213
|
+
return lodashEs.cloneDeep(this.test);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
137
216
|
* Initializes a new instance of this object.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
217
|
+
*/ constructor(){
|
|
218
|
+
_define_property$2(this, "test", void 0);
|
|
219
|
+
/**
|
|
220
|
+
* Sets the test environment to "node".
|
|
221
|
+
*
|
|
222
|
+
* @returns
|
|
223
|
+
* This object.
|
|
224
|
+
*/ _define_property$2(this, "node", this.environment.bind(this, "node"));
|
|
225
|
+
/**
|
|
226
|
+
* Sets the test environment to "happy-dom".
|
|
227
|
+
*
|
|
228
|
+
* @returns
|
|
229
|
+
* This object.
|
|
230
|
+
*/ _define_property$2(this, "browser", this.environment.bind(this, "happy-dom"));
|
|
231
|
+
/**
|
|
232
|
+
* Sets the test coverage provider to "v8".
|
|
233
|
+
*
|
|
234
|
+
* @returns
|
|
235
|
+
* This object.
|
|
236
|
+
*/ _define_property$2(this, "v8", this.coverage.bind(this, "v8"));
|
|
237
|
+
/**
|
|
238
|
+
* Sets the test coverage provider to "istanbul".
|
|
239
|
+
*
|
|
240
|
+
* @returns
|
|
241
|
+
* This object.
|
|
242
|
+
*/ _define_property$2(this, "istanbul", this.coverage.bind(this, "istanbul"));
|
|
243
|
+
this.test = {
|
|
244
|
+
environment: "node",
|
|
245
|
+
testTimeout: 30000,
|
|
246
|
+
coverage: {
|
|
247
|
+
all: false,
|
|
248
|
+
provider: undefined
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function _define_property$1(obj, key, value) {
|
|
255
|
+
if (key in obj) {
|
|
256
|
+
Object.defineProperty(obj, key, {
|
|
257
|
+
value: value,
|
|
258
|
+
enumerable: true,
|
|
259
|
+
configurable: true,
|
|
260
|
+
writable: true
|
|
261
|
+
});
|
|
262
|
+
} else {
|
|
263
|
+
obj[key] = value;
|
|
264
|
+
}
|
|
265
|
+
return obj;
|
|
266
|
+
}
|
|
267
|
+
function _object_spread(target) {
|
|
268
|
+
for(var i = 1; i < arguments.length; i++){
|
|
269
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
270
|
+
var ownKeys = Object.keys(source);
|
|
271
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
272
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
273
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
ownKeys.forEach(function(key) {
|
|
277
|
+
_define_property$1(target, key, source[key]);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return target;
|
|
281
|
+
}
|
|
282
|
+
function ownKeys(object, enumerableOnly) {
|
|
283
|
+
var keys = Object.keys(object);
|
|
284
|
+
if (Object.getOwnPropertySymbols) {
|
|
285
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
286
|
+
keys.push.apply(keys, symbols);
|
|
287
|
+
}
|
|
288
|
+
return keys;
|
|
289
|
+
}
|
|
290
|
+
function _object_spread_props(target, source) {
|
|
291
|
+
source = source != null ? source : {};
|
|
292
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
293
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
294
|
+
} else {
|
|
295
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
296
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
return target;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* A config builder for the vite build system.
|
|
303
|
+
*
|
|
304
|
+
* This is helpful when building different types
|
|
305
|
+
* of projects and keeping a standard.
|
|
306
|
+
*
|
|
307
|
+
* @example vite.config.ts
|
|
308
|
+
*
|
|
309
|
+
* ```ts
|
|
310
|
+
* // Before Config Builder
|
|
311
|
+
* export default defineConfig({
|
|
312
|
+
* build: {
|
|
313
|
+
* lib: {
|
|
314
|
+
* entry: {
|
|
315
|
+
* index: "./src/index.ts",
|
|
316
|
+
* },
|
|
317
|
+
* formats: ["cjs", "es"],
|
|
318
|
+
* },
|
|
319
|
+
* },
|
|
320
|
+
* minify: false,
|
|
321
|
+
* sourceMap: true,
|
|
322
|
+
* plugins: [
|
|
323
|
+
* swc.vite(),
|
|
324
|
+
* tsConfigPaths(),
|
|
325
|
+
* externalizeDeps(),
|
|
326
|
+
* dtsPlugin({
|
|
327
|
+
* compilerOptions: {
|
|
328
|
+
* paths: {},
|
|
329
|
+
* },
|
|
330
|
+
* }),
|
|
331
|
+
* ],
|
|
332
|
+
* });
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* ```ts
|
|
336
|
+
* // After config builder
|
|
337
|
+
* const config = new ZViteConfigBuilder().library().build();
|
|
338
|
+
* export default defineConfig(config);
|
|
339
|
+
* ```
|
|
340
|
+
*/ class ZViteConfigBuilder {
|
|
341
|
+
/**
|
|
150
342
|
* Sets whether to minify the build output.
|
|
151
343
|
*
|
|
152
344
|
* @param minify -
|
|
@@ -154,12 +346,13 @@ class ZViteConfigBuilder {
|
|
|
154
346
|
*
|
|
155
347
|
* @returns
|
|
156
348
|
* This object.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
349
|
+
*/ minify(minify = true) {
|
|
350
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
351
|
+
minify
|
|
352
|
+
});
|
|
353
|
+
return this;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
163
356
|
* Adds a list of plugins.
|
|
164
357
|
*
|
|
165
358
|
* @param option -
|
|
@@ -167,22 +360,14 @@ class ZViteConfigBuilder {
|
|
|
167
360
|
*
|
|
168
361
|
* @returns
|
|
169
362
|
* This object.
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
*
|
|
179
|
-
* This is mostly for nest projects as nest requires
|
|
180
|
-
* swc to support decorators.
|
|
181
|
-
*/
|
|
182
|
-
swc() {
|
|
183
|
-
return this.plugin(swc.vite());
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
363
|
+
*/ plugin(option = []) {
|
|
364
|
+
// See constructor - the config plugins are guaranteed to
|
|
365
|
+
// be set. The swc and paths plugins are automatically added.
|
|
366
|
+
const plugins = this.config.plugins;
|
|
367
|
+
this.config.plugins = plugins.concat(lodashEs.castArray(option));
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
186
371
|
* Sets whether to generate source maps.
|
|
187
372
|
*
|
|
188
373
|
* @param sourcemap -
|
|
@@ -190,12 +375,13 @@ class ZViteConfigBuilder {
|
|
|
190
375
|
*
|
|
191
376
|
* @returns
|
|
192
377
|
* This object.
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
378
|
+
*/ sourceMap(sourcemap = true) {
|
|
379
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
380
|
+
sourcemap
|
|
381
|
+
});
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
199
385
|
* Adds an alias to the resolution options.
|
|
200
386
|
*
|
|
201
387
|
* @param key -
|
|
@@ -205,14 +391,13 @@ class ZViteConfigBuilder {
|
|
|
205
391
|
*
|
|
206
392
|
* @returns
|
|
207
393
|
* This object.
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/**
|
|
394
|
+
*/ alias(key, value) {
|
|
395
|
+
this.config.resolve = this.config.resolve || {};
|
|
396
|
+
this.config.resolve.alias = this.config.resolve.alias || {};
|
|
397
|
+
this.config.resolve.alias[key] = value;
|
|
398
|
+
return this;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
216
401
|
* Assigns the server options.
|
|
217
402
|
*
|
|
218
403
|
* @param options -
|
|
@@ -220,12 +405,11 @@ class ZViteConfigBuilder {
|
|
|
220
405
|
*
|
|
221
406
|
* @returns
|
|
222
407
|
* This object.
|
|
223
|
-
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
/**
|
|
408
|
+
*/ server(options) {
|
|
409
|
+
this.config.server = lodashEs.cloneDeep(options);
|
|
410
|
+
return this;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
229
413
|
* Sets vite into library mode.
|
|
230
414
|
*
|
|
231
415
|
* @param lib -
|
|
@@ -237,37 +421,38 @@ class ZViteConfigBuilder {
|
|
|
237
421
|
*
|
|
238
422
|
* @returns
|
|
239
423
|
* This object.
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
424
|
+
*/ library(lib = new ZViteLibraryBuilder().index().build()) {
|
|
425
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
426
|
+
lib
|
|
427
|
+
});
|
|
428
|
+
const dts = dtsPlugin({
|
|
429
|
+
compilerOptions: {
|
|
430
|
+
// Always turn off paths when building for production. You want to make
|
|
431
|
+
// sure that your build is building in the correct order and that your
|
|
432
|
+
// actual paths are correct.
|
|
433
|
+
paths: {}
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
const external = vitePluginExternalizeDeps.externalizeDeps();
|
|
437
|
+
return this.minify(false).sourceMap().plugin(external).plugin(dts);
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
255
440
|
* Constructs the config to act as if it's compiling a node application.
|
|
256
441
|
*
|
|
257
442
|
* This is just an alias to {@link ZViteConfigBuilder.library} with two
|
|
258
443
|
* entry points.
|
|
259
444
|
*
|
|
260
445
|
* 1. The file src/cli.ts is the main entry point of the application.
|
|
261
|
-
* 1. The file, src/index.ts, is the api for importing
|
|
446
|
+
* 1. The file, src/index.ts, is the api for importing and using it as an api.
|
|
262
447
|
*
|
|
263
448
|
* @returns
|
|
264
449
|
* This object.
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
450
|
+
*/ cli() {
|
|
451
|
+
// A cli works similar to a library.
|
|
452
|
+
const library = new ZViteLibraryBuilder().entry("index", "src/index.mts").entry("cli", "src/cli.mts").build();
|
|
453
|
+
return this.library(library);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
271
456
|
* Constructs the config to act as if it's compiling a nest application.
|
|
272
457
|
*
|
|
273
458
|
* This is just an alias to {@link ZViteConfigBuilder.library} with a single
|
|
@@ -277,89 +462,130 @@ class ZViteConfigBuilder {
|
|
|
277
462
|
*
|
|
278
463
|
* @returns
|
|
279
464
|
* This object.
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
/**
|
|
465
|
+
*/ nest() {
|
|
466
|
+
const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
|
|
467
|
+
return this.library(library);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
286
470
|
* Constructs the config to act as if it's compiling a web application.
|
|
287
471
|
*
|
|
288
472
|
* @returns
|
|
289
473
|
* This object.
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
474
|
+
*/ web() {
|
|
475
|
+
return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({
|
|
476
|
+
typescript: true
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
295
480
|
* Constructs the config to compile a react application.
|
|
296
481
|
*
|
|
297
482
|
* @returns
|
|
298
483
|
* This object.
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
/**
|
|
484
|
+
*/ react() {
|
|
485
|
+
return this.web().plugin(react());
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
304
488
|
* Constructs the config to be for testing.
|
|
305
489
|
*
|
|
306
490
|
* @param options -
|
|
307
491
|
* The test config to use. If this is falsy,
|
|
308
492
|
* then a test setup using a monorepo with an
|
|
309
493
|
* istanbul provider in node is used.
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
/**
|
|
494
|
+
*/ test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
|
|
495
|
+
this.config.test = options;
|
|
496
|
+
return this;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
316
499
|
* Returns the currently built config.
|
|
317
500
|
*
|
|
318
501
|
* @returns
|
|
319
502
|
* The currently built config.
|
|
320
|
-
*/
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
503
|
+
*/ build() {
|
|
504
|
+
return lodashEs.cloneDeep(this.config);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Initializes a new instance of this object.
|
|
508
|
+
*/ constructor(){
|
|
509
|
+
_define_property$1(this, "config", void 0);
|
|
510
|
+
/**
|
|
511
|
+
* Adds an alias for lodash to lodash-es.
|
|
512
|
+
*
|
|
513
|
+
* @returns
|
|
514
|
+
* This object.
|
|
515
|
+
*/ _define_property$1(this, "lodash", this.alias.bind(this, "lodash", "lodash-es"));
|
|
516
|
+
this.config = {
|
|
517
|
+
build: {
|
|
518
|
+
minify: true,
|
|
519
|
+
sourcemap: false
|
|
520
|
+
},
|
|
521
|
+
plugins: [
|
|
522
|
+
swc.vite({
|
|
523
|
+
jsc: {
|
|
524
|
+
transform: {
|
|
525
|
+
react: {
|
|
526
|
+
runtime: "automatic"
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}),
|
|
531
|
+
tsConfigPaths()
|
|
532
|
+
]
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function _define_property(obj, key, value) {
|
|
538
|
+
if (key in obj) {
|
|
539
|
+
Object.defineProperty(obj, key, {
|
|
540
|
+
value: value,
|
|
541
|
+
enumerable: true,
|
|
542
|
+
configurable: true,
|
|
543
|
+
writable: true
|
|
544
|
+
});
|
|
545
|
+
} else {
|
|
546
|
+
obj[key] = value;
|
|
547
|
+
}
|
|
548
|
+
return obj;
|
|
324
549
|
}
|
|
325
550
|
class ZViteServerBuilder {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
551
|
+
allowedHost(name) {
|
|
552
|
+
if (name === true) {
|
|
553
|
+
this.options.allowedHosts = true;
|
|
554
|
+
} else if (this.options.allowedHosts !== true) {
|
|
555
|
+
const hosts = this.options.allowedHosts || [];
|
|
556
|
+
this.options.allowedHosts = hosts.concat(name);
|
|
557
|
+
}
|
|
558
|
+
return this;
|
|
559
|
+
}
|
|
560
|
+
denyAllHosts() {
|
|
561
|
+
delete this.options.allowedHosts;
|
|
562
|
+
return this;
|
|
563
|
+
}
|
|
564
|
+
port(port) {
|
|
565
|
+
this.options.port = port;
|
|
566
|
+
return this;
|
|
567
|
+
}
|
|
568
|
+
strictPort() {
|
|
569
|
+
this.options.strictPort = true;
|
|
570
|
+
return this;
|
|
571
|
+
}
|
|
572
|
+
host(ip) {
|
|
573
|
+
this.options.host = ip;
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
dev() {
|
|
577
|
+
return this.strictPort().host("0.0.0.0").allowedHost(true);
|
|
578
|
+
}
|
|
579
|
+
build() {
|
|
580
|
+
const clone = lodashEs.cloneDeep(this.options);
|
|
581
|
+
return lodashEs.omitBy(clone, lodashEs.isUndefined);
|
|
582
|
+
}
|
|
583
|
+
constructor(){
|
|
584
|
+
_define_property(this, "options", {});
|
|
585
|
+
_define_property(this, "localhost", this.host.bind(this, "127.0.0.1"));
|
|
586
|
+
}
|
|
362
587
|
}
|
|
588
|
+
|
|
363
589
|
exports.ZViteConfigBuilder = ZViteConfigBuilder;
|
|
364
590
|
exports.ZViteLibraryBuilder = ZViteLibraryBuilder;
|
|
365
591
|
exports.ZViteServerBuilder = ZViteServerBuilder;
|