@zthun/janitor-build-config 19.0.0 → 19.1.0
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.map +1 -1
- package/dist/typedoc.js.map +1 -1
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/vite-config-builder.d.mts +74 -8
- package/dist/vite/vite-server-builder.d.mts +12 -0
- package/dist/vite/vite-server-builder.spec.d.ts +1 -0
- package/dist/vite/vite-test-builder.d.mts +20 -0
- package/dist/vite.cjs +272 -53
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +273 -55
- package/dist/vite.js.map +1 -1
- package/package.json +14 -10
package/dist/vite.cjs
CHANGED
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const lodashEs = require('lodash-es');
|
|
6
6
|
const swc = require('unplugin-swc');
|
|
7
|
+
const vitePluginChecker = require('vite-plugin-checker');
|
|
7
8
|
const dtsPlugin = require('vite-plugin-dts');
|
|
8
9
|
const vitePluginExternalizeDeps = require('vite-plugin-externalize-deps');
|
|
9
10
|
const tsConfigPaths = require('vite-tsconfig-paths');
|
|
10
11
|
|
|
11
|
-
function _define_property$
|
|
12
|
+
function _define_property$3(obj, key, value) {
|
|
12
13
|
if (key in obj) {
|
|
13
14
|
Object.defineProperty(obj, key, {
|
|
14
15
|
value: value,
|
|
@@ -21,7 +22,7 @@ function _define_property$2(obj, key, value) {
|
|
|
21
22
|
}
|
|
22
23
|
return obj;
|
|
23
24
|
}
|
|
24
|
-
function _object_spread(target) {
|
|
25
|
+
function _object_spread$2(target) {
|
|
25
26
|
for(var i = 1; i < arguments.length; i++){
|
|
26
27
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
27
28
|
var ownKeys = Object.keys(source);
|
|
@@ -31,12 +32,12 @@ function _object_spread(target) {
|
|
|
31
32
|
}));
|
|
32
33
|
}
|
|
33
34
|
ownKeys.forEach(function(key) {
|
|
34
|
-
_define_property$
|
|
35
|
+
_define_property$3(target, key, source[key]);
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
return target;
|
|
38
39
|
}
|
|
39
|
-
function ownKeys(object, enumerableOnly) {
|
|
40
|
+
function ownKeys$2(object, enumerableOnly) {
|
|
40
41
|
var keys = Object.keys(object);
|
|
41
42
|
if (Object.getOwnPropertySymbols) {
|
|
42
43
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
@@ -44,12 +45,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
44
45
|
}
|
|
45
46
|
return keys;
|
|
46
47
|
}
|
|
47
|
-
function _object_spread_props(target, source) {
|
|
48
|
+
function _object_spread_props$2(target, source) {
|
|
48
49
|
source = source != null ? source : {};
|
|
49
50
|
if (Object.getOwnPropertyDescriptors) {
|
|
50
51
|
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
51
52
|
} else {
|
|
52
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
53
|
+
ownKeys$2(Object(source)).forEach(function(key) {
|
|
53
54
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -69,7 +70,7 @@ function _object_spread_props(target, source) {
|
|
|
69
70
|
* @returns
|
|
70
71
|
* This object.
|
|
71
72
|
*/ entry(name, path) {
|
|
72
|
-
this.library.entry = _object_spread_props(_object_spread({}, this.library.entry), {
|
|
73
|
+
this.library.entry = _object_spread_props$2(_object_spread$2({}, this.library.entry), {
|
|
73
74
|
[name]: path
|
|
74
75
|
});
|
|
75
76
|
return this;
|
|
@@ -92,7 +93,7 @@ function _object_spread_props(target, source) {
|
|
|
92
93
|
return lodashEs.cloneDeep(this.library);
|
|
93
94
|
}
|
|
94
95
|
constructor(){
|
|
95
|
-
_define_property$
|
|
96
|
+
_define_property$3(this, "library", {
|
|
96
97
|
entry: {},
|
|
97
98
|
formats: [
|
|
98
99
|
"es",
|
|
@@ -102,7 +103,7 @@ function _object_spread_props(target, source) {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
function _define_property$
|
|
106
|
+
function _define_property$2(obj, key, value) {
|
|
106
107
|
if (key in obj) {
|
|
107
108
|
Object.defineProperty(obj, key, {
|
|
108
109
|
value: value,
|
|
@@ -115,6 +116,40 @@ function _define_property$1(obj, key, value) {
|
|
|
115
116
|
}
|
|
116
117
|
return obj;
|
|
117
118
|
}
|
|
119
|
+
function _object_spread$1(target) {
|
|
120
|
+
for(var i = 1; i < arguments.length; i++){
|
|
121
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
122
|
+
var ownKeys = Object.keys(source);
|
|
123
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
124
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
125
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
ownKeys.forEach(function(key) {
|
|
129
|
+
_define_property$2(target, key, source[key]);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return target;
|
|
133
|
+
}
|
|
134
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
135
|
+
var keys = Object.keys(object);
|
|
136
|
+
if (Object.getOwnPropertySymbols) {
|
|
137
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
138
|
+
keys.push.apply(keys, symbols);
|
|
139
|
+
}
|
|
140
|
+
return keys;
|
|
141
|
+
}
|
|
142
|
+
function _object_spread_props$1(target, source) {
|
|
143
|
+
source = source != null ? source : {};
|
|
144
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
145
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
146
|
+
} else {
|
|
147
|
+
ownKeys$1(Object(source)).forEach(function(key) {
|
|
148
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return target;
|
|
152
|
+
}
|
|
118
153
|
/**
|
|
119
154
|
* A builder for test configurations found in vite's defineConfig test field.
|
|
120
155
|
*/ class ZViteTestBuilder {
|
|
@@ -139,10 +174,36 @@ function _define_property$1(obj, key, value) {
|
|
|
139
174
|
* @returns
|
|
140
175
|
* This object.
|
|
141
176
|
*/ coverage(provider) {
|
|
142
|
-
this.test.coverage
|
|
177
|
+
this.test.coverage = _object_spread_props$1(_object_spread$1({}, this.test.coverage), {
|
|
178
|
+
provider
|
|
179
|
+
});
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Adds to the list of projects.
|
|
184
|
+
*
|
|
185
|
+
* @param project -
|
|
186
|
+
* The list of projects.
|
|
187
|
+
*
|
|
188
|
+
* @returns
|
|
189
|
+
* This object.
|
|
190
|
+
*/ project(project = []) {
|
|
191
|
+
const projects = this.test.projects || [];
|
|
192
|
+
this.test.projects = projects.concat(project);
|
|
143
193
|
return this;
|
|
144
194
|
}
|
|
145
195
|
/**
|
|
196
|
+
* Adds monorepo support to the test builder.
|
|
197
|
+
*
|
|
198
|
+
* @param packages -
|
|
199
|
+
* The path to the package directory.
|
|
200
|
+
*
|
|
201
|
+
* @returns
|
|
202
|
+
* This object.
|
|
203
|
+
*/ monorepo(packages = "packages") {
|
|
204
|
+
return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
146
207
|
* Returns the built test configuration.
|
|
147
208
|
*
|
|
148
209
|
* @returns
|
|
@@ -153,31 +214,31 @@ function _define_property$1(obj, key, value) {
|
|
|
153
214
|
/**
|
|
154
215
|
* Initializes a new instance of this object.
|
|
155
216
|
*/ constructor(){
|
|
156
|
-
_define_property$
|
|
217
|
+
_define_property$2(this, "test", void 0);
|
|
157
218
|
/**
|
|
158
219
|
* Sets the test environment to "node".
|
|
159
220
|
*
|
|
160
221
|
* @returns
|
|
161
222
|
* This object.
|
|
162
|
-
*/ _define_property$
|
|
223
|
+
*/ _define_property$2(this, "node", this.environment.bind(this, "node"));
|
|
163
224
|
/**
|
|
164
225
|
* Sets the test environment to "happy-dom".
|
|
165
226
|
*
|
|
166
227
|
* @returns
|
|
167
228
|
* This object.
|
|
168
|
-
*/ _define_property$
|
|
229
|
+
*/ _define_property$2(this, "browser", this.environment.bind(this, "happy-dom"));
|
|
169
230
|
/**
|
|
170
231
|
* Sets the test coverage provider to "v8".
|
|
171
232
|
*
|
|
172
233
|
* @returns
|
|
173
234
|
* This object.
|
|
174
|
-
*/ _define_property$
|
|
235
|
+
*/ _define_property$2(this, "v8", this.coverage.bind(this, "v8"));
|
|
175
236
|
/**
|
|
176
237
|
* Sets the test coverage provider to "istanbul".
|
|
177
238
|
*
|
|
178
239
|
* @returns
|
|
179
240
|
* This object.
|
|
180
|
-
*/ _define_property$
|
|
241
|
+
*/ _define_property$2(this, "istanbul", this.coverage.bind(this, "istanbul"));
|
|
181
242
|
this.test = {
|
|
182
243
|
environment: "node",
|
|
183
244
|
testTimeout: 30000,
|
|
@@ -189,7 +250,7 @@ function _define_property$1(obj, key, value) {
|
|
|
189
250
|
}
|
|
190
251
|
}
|
|
191
252
|
|
|
192
|
-
function _define_property(obj, key, value) {
|
|
253
|
+
function _define_property$1(obj, key, value) {
|
|
193
254
|
if (key in obj) {
|
|
194
255
|
Object.defineProperty(obj, key, {
|
|
195
256
|
value: value,
|
|
@@ -202,6 +263,40 @@ function _define_property(obj, key, value) {
|
|
|
202
263
|
}
|
|
203
264
|
return obj;
|
|
204
265
|
}
|
|
266
|
+
function _object_spread(target) {
|
|
267
|
+
for(var i = 1; i < arguments.length; i++){
|
|
268
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
269
|
+
var ownKeys = Object.keys(source);
|
|
270
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
271
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
272
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
ownKeys.forEach(function(key) {
|
|
276
|
+
_define_property$1(target, key, source[key]);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return target;
|
|
280
|
+
}
|
|
281
|
+
function ownKeys(object, enumerableOnly) {
|
|
282
|
+
var keys = Object.keys(object);
|
|
283
|
+
if (Object.getOwnPropertySymbols) {
|
|
284
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
285
|
+
keys.push.apply(keys, symbols);
|
|
286
|
+
}
|
|
287
|
+
return keys;
|
|
288
|
+
}
|
|
289
|
+
function _object_spread_props(target, source) {
|
|
290
|
+
source = source != null ? source : {};
|
|
291
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
292
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
293
|
+
} else {
|
|
294
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
295
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return target;
|
|
299
|
+
}
|
|
205
300
|
/**
|
|
206
301
|
* A config builder for the vite build system.
|
|
207
302
|
*
|
|
@@ -243,9 +338,64 @@ function _define_property(obj, key, value) {
|
|
|
243
338
|
* ```
|
|
244
339
|
*/ class ZViteConfigBuilder {
|
|
245
340
|
/**
|
|
246
|
-
* Sets
|
|
341
|
+
* Sets whether to minify the build output.
|
|
342
|
+
*
|
|
343
|
+
* @param minify -
|
|
344
|
+
* The flag as to minify the output.
|
|
345
|
+
*
|
|
346
|
+
* @returns
|
|
347
|
+
* This object.
|
|
348
|
+
*/ minify(minify = true) {
|
|
349
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
350
|
+
minify
|
|
351
|
+
});
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Adds a list of plugins.
|
|
356
|
+
*
|
|
357
|
+
* @param option -
|
|
358
|
+
* The plugins to add.
|
|
359
|
+
*
|
|
360
|
+
* @returns
|
|
361
|
+
* This object.
|
|
362
|
+
*/ plugin(option = []) {
|
|
363
|
+
// See constructor - the config plugins are guaranteed to
|
|
364
|
+
// be set. The swc and paths plugins are automatically added.
|
|
365
|
+
const plugins = this.config.plugins;
|
|
366
|
+
this.config.plugins = plugins.concat(lodashEs.castArray(option));
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Sets whether to generate source maps.
|
|
371
|
+
*
|
|
372
|
+
* @param sourcemap -
|
|
373
|
+
* True to generate a sourcemap, false for faster build.
|
|
374
|
+
*
|
|
375
|
+
* @returns
|
|
376
|
+
* This object.
|
|
377
|
+
*/ sourceMap(sourcemap = true) {
|
|
378
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
379
|
+
sourcemap
|
|
380
|
+
});
|
|
381
|
+
return this;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Assigns the server options.
|
|
247
385
|
*
|
|
248
386
|
* @param options -
|
|
387
|
+
* The server options to assign.
|
|
388
|
+
*
|
|
389
|
+
* @returns
|
|
390
|
+
* This object.
|
|
391
|
+
*/ server(options) {
|
|
392
|
+
this.config.server = lodashEs.cloneDeep(options);
|
|
393
|
+
return this;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Sets vite into library mode.
|
|
397
|
+
*
|
|
398
|
+
* @param lib -
|
|
249
399
|
* The options for the library. You can set this to
|
|
250
400
|
* nothing to use the default library which looks for
|
|
251
401
|
* an entry point at the source directory called index.ts
|
|
@@ -254,31 +404,20 @@ function _define_property(obj, key, value) {
|
|
|
254
404
|
*
|
|
255
405
|
* @returns
|
|
256
406
|
* This object.
|
|
257
|
-
*/ library(
|
|
258
|
-
this.config.build
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
vitePluginExternalizeDeps.externalizeDeps(),
|
|
272
|
-
dtsPlugin({
|
|
273
|
-
compilerOptions: {
|
|
274
|
-
// Always turn off paths when building for production. You want to make
|
|
275
|
-
// sure that your build is building in the correct order and that your
|
|
276
|
-
// actual paths are correct.
|
|
277
|
-
paths: {}
|
|
278
|
-
}
|
|
279
|
-
})
|
|
280
|
-
];
|
|
281
|
-
return this;
|
|
407
|
+
*/ library(lib = new ZViteLibraryBuilder().index().build()) {
|
|
408
|
+
this.config.build = _object_spread_props(_object_spread({}, this.config.build), {
|
|
409
|
+
lib
|
|
410
|
+
});
|
|
411
|
+
const dts = dtsPlugin({
|
|
412
|
+
compilerOptions: {
|
|
413
|
+
// Always turn off paths when building for production. You want to make
|
|
414
|
+
// sure that your build is building in the correct order and that your
|
|
415
|
+
// actual paths are correct.
|
|
416
|
+
paths: {}
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
const external = vitePluginExternalizeDeps.externalizeDeps();
|
|
420
|
+
return this.minify(false).sourceMap().plugin(external).plugin(dts);
|
|
282
421
|
}
|
|
283
422
|
/**
|
|
284
423
|
* Constructs the config to act as if it's compiling a node application.
|
|
@@ -292,15 +431,42 @@ function _define_property(obj, key, value) {
|
|
|
292
431
|
* @returns
|
|
293
432
|
* This object.
|
|
294
433
|
*/ cli() {
|
|
295
|
-
// A cli works similar to a library.
|
|
296
|
-
// to building complex node apps, but for simple cli tools and non
|
|
297
|
-
// framework based servers, you can do it.
|
|
434
|
+
// A cli works similar to a library.
|
|
298
435
|
const library = new ZViteLibraryBuilder().entry("index", "src/index.ts").entry("cli", "src/cli.ts").build();
|
|
299
436
|
return this.library(library);
|
|
300
437
|
}
|
|
301
438
|
/**
|
|
439
|
+
* Constructs the config to act as if it's compiling a nest application.
|
|
440
|
+
*
|
|
441
|
+
* This is just an alias to {@link ZViteConfigBuilder.library} with a single
|
|
442
|
+
* entry point.
|
|
443
|
+
*
|
|
444
|
+
* 1. The file, src/main.mts
|
|
445
|
+
*
|
|
446
|
+
* @returns
|
|
447
|
+
* This object.
|
|
448
|
+
*/ nest() {
|
|
449
|
+
const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
|
|
450
|
+
return this.library(library);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Constructs the config to act as if it's compiling a web application.
|
|
454
|
+
*
|
|
455
|
+
* @returns
|
|
456
|
+
* This object.
|
|
457
|
+
*/ web() {
|
|
458
|
+
return this.minify().sourceMap(false).plugin(vitePluginChecker.checker({
|
|
459
|
+
typescript: true
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
302
463
|
* Constructs the config to be for testing.
|
|
303
|
-
|
|
464
|
+
*
|
|
465
|
+
* @param options -
|
|
466
|
+
* The test config to use. If this is falsy,
|
|
467
|
+
* then a test setup using a monorepo with an
|
|
468
|
+
* istanbul provider in node is used.
|
|
469
|
+
*/ test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
|
|
304
470
|
this.config.test = options;
|
|
305
471
|
return this;
|
|
306
472
|
}
|
|
@@ -314,14 +480,14 @@ function _define_property(obj, key, value) {
|
|
|
314
480
|
}
|
|
315
481
|
/**
|
|
316
482
|
* Initializes a new instance of this object.
|
|
483
|
+
*/ constructor(){
|
|
484
|
+
_define_property$1(this, "config", void 0);
|
|
485
|
+
/**
|
|
486
|
+
* An alias to {@link web}
|
|
317
487
|
*
|
|
318
|
-
* @
|
|
319
|
-
*
|
|
320
|
-
|
|
321
|
-
*/ constructor(_dirname){
|
|
322
|
-
_define_property(this, "_dirname", void 0);
|
|
323
|
-
_define_property(this, "config", void 0);
|
|
324
|
-
this._dirname = _dirname;
|
|
488
|
+
* @returns
|
|
489
|
+
* This object.
|
|
490
|
+
*/ _define_property$1(this, "react", this.web);
|
|
325
491
|
this.config = {
|
|
326
492
|
build: {
|
|
327
493
|
minify: true,
|
|
@@ -335,7 +501,60 @@ function _define_property(obj, key, value) {
|
|
|
335
501
|
}
|
|
336
502
|
}
|
|
337
503
|
|
|
504
|
+
function _define_property(obj, key, value) {
|
|
505
|
+
if (key in obj) {
|
|
506
|
+
Object.defineProperty(obj, key, {
|
|
507
|
+
value: value,
|
|
508
|
+
enumerable: true,
|
|
509
|
+
configurable: true,
|
|
510
|
+
writable: true
|
|
511
|
+
});
|
|
512
|
+
} else {
|
|
513
|
+
obj[key] = value;
|
|
514
|
+
}
|
|
515
|
+
return obj;
|
|
516
|
+
}
|
|
517
|
+
class ZViteServerBuilder {
|
|
518
|
+
allowedHost(name) {
|
|
519
|
+
if (name === true) {
|
|
520
|
+
this.options.allowedHosts = true;
|
|
521
|
+
} else if (this.options.allowedHosts !== true) {
|
|
522
|
+
const hosts = this.options.allowedHosts || [];
|
|
523
|
+
this.options.allowedHosts = hosts.concat(name);
|
|
524
|
+
}
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
denyAllHosts() {
|
|
528
|
+
delete this.options.allowedHosts;
|
|
529
|
+
return this;
|
|
530
|
+
}
|
|
531
|
+
port(port) {
|
|
532
|
+
this.options.port = port;
|
|
533
|
+
return this;
|
|
534
|
+
}
|
|
535
|
+
strictPort() {
|
|
536
|
+
this.options.strictPort = true;
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
host(ip) {
|
|
540
|
+
this.options.host = ip;
|
|
541
|
+
return this;
|
|
542
|
+
}
|
|
543
|
+
dev() {
|
|
544
|
+
return this.strictPort().host("0.0.0.0").allowedHost(true);
|
|
545
|
+
}
|
|
546
|
+
build() {
|
|
547
|
+
const clone = lodashEs.cloneDeep(this.options);
|
|
548
|
+
return lodashEs.omitBy(clone, lodashEs.isUndefined);
|
|
549
|
+
}
|
|
550
|
+
constructor(){
|
|
551
|
+
_define_property(this, "options", {});
|
|
552
|
+
_define_property(this, "localhost", this.host.bind(this, "127.0.0.1"));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
338
556
|
exports.ZViteConfigBuilder = ZViteConfigBuilder;
|
|
339
557
|
exports.ZViteLibraryBuilder = ZViteLibraryBuilder;
|
|
558
|
+
exports.ZViteServerBuilder = ZViteServerBuilder;
|
|
340
559
|
exports.ZViteTestBuilder = ZViteTestBuilder;
|
|
341
560
|
//# sourceMappingURL=vite.cjs.map
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","sources":["../src/vite/vite-library-builder.mts","../src/vite/vite-test-builder.mts","../src/vite/vite-config-builder.mts"],"sourcesContent":["import { cloneDeep } from \"lodash-es\";\nimport { LibraryOptions } from \"vite\";\n\n/**\n * A builder for Vite library configurations.\n */\nexport class ZViteLibraryBuilder {\n private library: LibraryOptions = {\n entry: {},\n formats: [\"es\", \"cjs\"],\n };\n\n /**\n * Adds an entry point to the library.\n *\n * @param name -\n * The name of the entry point.\n * @param path -\n * The path to the entry point file.\n *\n * @returns\n * This object.\n */\n public entry(name: string, path: string) {\n this.library.entry = {\n ...(this.library.entry as Record<string, string>),\n [name]: path,\n };\n return this;\n }\n\n /**\n * A shorthand for adding an entry point\n * named \"index\" that points to \"src/index.ts\"\n *\n * @returns\n * This object.\n */\n public index() {\n return this.entry(\"index\", \"./src/index.ts\");\n }\n\n /**\n * Returns the built library configuration.\n *\n * @returns\n * A deep clone of the library configuration.\n */\n public build() {\n return cloneDeep(this.library);\n }\n}\n","import { cloneDeep } from \"lodash-es\";\nimport { InlineConfig, VitestEnvironment } from \"vitest/node\";\n\n/**\n * A builder for test configurations found in vite's defineConfig test field.\n */\nexport class ZViteTestBuilder {\n private test: InlineConfig;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this.test = {\n environment: \"node\",\n testTimeout: 30000,\n coverage: {\n all: false,\n provider: undefined,\n },\n };\n }\n\n /**\n * Sets the test environment.\n *\n * @param environment -\n * The test environment to use.\n *\n * @returns\n * This object.\n */\n public environment(environment: VitestEnvironment) {\n this.test.environment = environment;\n return this;\n }\n\n /**\n * Sets the test environment to \"node\".\n *\n * @returns\n * This object.\n */\n public node = this.environment.bind(this, \"node\");\n\n /**\n * Sets the test environment to \"happy-dom\".\n *\n * @returns\n * This object.\n */\n public browser = this.environment.bind(this, \"happy-dom\");\n\n /**\n * Sets the test coverage provider.\n *\n * @param provider -\n * The test coverage provider to use.\n *\n * @returns\n * This object.\n */\n public coverage(provider: \"v8\" | \"istanbul\") {\n this.test.coverage.provider = provider;\n return this;\n }\n\n /**\n * Sets the test coverage provider to \"v8\".\n *\n * @returns\n * This object.\n */\n public v8 = this.coverage.bind(this, \"v8\");\n\n /**\n * Sets the test coverage provider to \"istanbul\".\n *\n * @returns\n * This object.\n */\n public istanbul = this.coverage.bind(this, \"istanbul\");\n\n /**\n * Returns the built test configuration.\n *\n * @returns\n * A deep clone of the test configuration.\n */\n public build() {\n return cloneDeep(this.test);\n }\n}\n","import { cloneDeep } from \"lodash-es\";\nimport swc from \"unplugin-swc\";\nimport { LibraryOptions, UserConfig } from \"vite\";\nimport dtsPlugin from \"vite-plugin-dts\";\nimport { externalizeDeps } from \"vite-plugin-externalize-deps\";\nimport tsConfigPaths from \"vite-tsconfig-paths\";\nimport { InlineConfig as TestConfig } from \"vitest/node.js\";\nimport { ZViteLibraryBuilder } from \"./vite-library-builder.mjs\";\nimport { ZViteTestBuilder } from \"./vite-test-builder.mjs\";\n\n/**\n * A config builder for the vite build system.\n *\n * This is helpful when building different types\n * of projects and keeping a standard.\n *\n * @example vite.config.ts\n *\n * ```ts\n * // Before Config Builder\n * export default defineConfig({\n * build: {\n * lib: {\n * entry: {\n * index: \"./src/index.ts\",\n * },\n * formats: [\"cjs\", \"es\"],\n * },\n * },\n * minify: false,\n * sourceMap: true,\n * plugins: [\n * swc.vite(),\n * tsConfigPaths(),\n * externalizeDeps(),\n * dtsPlugin({\n * compilerOptions: {\n * paths: {},\n * },\n * }),\n * ],\n * });\n * ```\n *\n * ```ts\n * // After config builder\n * const config = new ZViteConfigBuilder().library().build();\n * export default defineConfig(config);\n * ```\n */\nexport class ZViteConfigBuilder {\n private config: UserConfig;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param _dirname -\n * The directory that is housing the vite.config\n * file. Pass __dirname to this.\n */\n public constructor(private _dirname: string) {\n this.config = {\n build: {\n minify: true,\n sourcemap: false,\n },\n plugins: [swc.vite(), tsConfigPaths()],\n };\n }\n\n /**\n * Sets vite into library mode.\n *\n * @param options -\n * The options for the library. You can set this to\n * nothing to use the default library which looks for\n * an entry point at the source directory called index.ts\n *\n * @see {@link ZViteLibraryBuilder} for more information.\n *\n * @returns\n * This object.\n */\n public library(\n options: LibraryOptions = new ZViteLibraryBuilder().index().build(),\n ) {\n this.config.build.lib = options;\n\n // There is almost no value to minifying a library unless you\n // are bundling it for importing via html.\n // Thus, just turn off the minify and enable the source map\n // This makes it much easier for other devs to debug problems\n this.config.build.minify = false;\n this.config.build.sourcemap = true;\n\n // When using a library, we also want to make sure we externalize the\n // dependencies automatically -> it blows my mind why vite doesn't\n // do this out of the box. I guess there's some reason or some\n // use case to bundle all the dependencies; I just don't see it.\n this.config.plugins = [\n ...this.config.plugins,\n externalizeDeps(),\n dtsPlugin({\n compilerOptions: {\n // Always turn off paths when building for production. You want to make\n // sure that your build is building in the correct order and that your\n // actual paths are correct.\n paths: {},\n },\n }),\n ];\n\n return this;\n }\n\n /**\n * Constructs the config to act as if it's compiling a node application.\n *\n * This is just an alias to {@link ZViteConfigBuilder.library} with two\n * entry points.\n *\n * 1. The file src/cli.ts is the main entry point of the application.\n * 1. The file, src/index.ts, is the api for importing\n *\n * @returns\n * This object.\n */\n public cli() {\n // A cli works similar to a library. Vite isn't the best when it comes\n // to building complex node apps, but for simple cli tools and non\n // framework based servers, you can do it.\n const library = new ZViteLibraryBuilder()\n .entry(\"index\", \"src/index.ts\")\n .entry(\"cli\", \"src/cli.ts\")\n .build();\n return this.library(library);\n }\n\n /**\n * Constructs the config to be for testing.\n */\n public test(\n options: TestConfig = new ZViteTestBuilder().node().istanbul().build(),\n ) {\n this.config.test = options;\n return this;\n }\n\n /**\n * Returns the currently built config.\n *\n * @returns\n * The currently built config.\n */\n public build() {\n return cloneDeep(this.config);\n }\n}\n"],"names":["ZViteLibraryBuilder","entry","name","path","library","cloneDeep","_define_property","formats","ZViteTestBuilder","environment","test","coverage","provider","node","bind","browser","v8","istanbul","testTimeout","all","undefined","ZViteConfigBuilder","options","index","build","config","lib","minify","sourcemap","plugins","externalizeDeps","dtsPlugin","compilerOptions","paths","_dirname","swc","vite","tsConfigPaths"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAEC,IACM,MAAMA,mBAAAA,CAAAA;AAMX;;;;;;;;;;AAUC,MACD,KAAOC,CAAMC,IAAY,EAAEC,IAAY,EAAE;QACvC,IAAI,CAACC,OAAO,CAACH,KAAK,GAAG,wCACf,IAAI,CAACG,OAAO,CAACH,KAAK,CAAA,EAAA;AACtB,YAAA,CAACC,OAAOC;;AAEV,QAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMC,MACD,KAAe,GAAA;AACb,QAAA,OAAO,IAAI,CAACF,KAAK,CAAC,OAAS,EAAA,gBAAA,CAAA;AAC7B;AAEA;;;;;AAKC,MACD,KAAe,GAAA;QACb,OAAOI,kBAAAA,CAAU,IAAI,CAACD,OAAO,CAAA;AAC/B;;AA3CA,QAAAE,kBAAA,CAAA,IAAA,EAAQF,SAA0B,EAAA;AAChCH,YAAAA,KAAAA,EAAO,EAAC;YACRM,OAAS,EAAA;AAAC,gBAAA,IAAA;AAAM,gBAAA;AAAM;AACxB,SAAA,CAAA;;AAyCF;;;;;;;;;;;;;;;AChDA;;AAEC,IACM,MAAMC,gBAAAA,CAAAA;AAiBX;;;;;;;;MASOC,WAAYA,CAAAA,WAA8B,EAAE;AACjD,QAAA,IAAI,CAACC,IAAI,CAACD,WA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A,IAAA;gBACRC,SAAW,EAAA;AACb,aAAA;YACAC,OAAS,EAAA;AAACM,gBAAAA,GAAAA,CAAIC,IAAI,EAAA;AAAIC,gBAAAA,aAAAA;AAAgB;AACxC,SAAA;AACF;AAyFF;;;;;;"}
|
|
1
|
+
{"version":3,"file":"vite.cjs","sources":["../src/vite/vite-library-builder.mts","../src/vite/vite-test-builder.mts","../src/vite/vite-config-builder.mts","../src/vite/vite-server-builder.mts"],"sourcesContent":["import { cloneDeep } from \"lodash-es\";\nimport type { LibraryOptions } from \"vite\";\n\n/**\n * A builder for Vite library configurations.\n */\nexport class ZViteLibraryBuilder {\n private library: LibraryOptions = {\n entry: {},\n formats: [\"es\", \"cjs\"],\n };\n\n /**\n * Adds an entry point to the library.\n *\n * @param name -\n * The name of the entry point.\n * @param path -\n * The path to the entry point file.\n *\n * @returns\n * This object.\n */\n public entry(name: string, path: string) {\n this.library.entry = {\n ...(this.library.entry as Record<string, string>),\n [name]: path,\n };\n return this;\n }\n\n /**\n * A shorthand for adding an entry point\n * named \"index\" that points to \"src/index.ts\"\n *\n * @returns\n * This object.\n */\n public index() {\n return this.entry(\"index\", \"./src/index.ts\");\n }\n\n /**\n * Returns the built library configuration.\n *\n * @returns\n * A deep clone of the library configuration.\n */\n public build() {\n return cloneDeep(this.library);\n }\n}\n","import { cloneDeep } from \"lodash-es\";\nimport type { InlineConfig, VitestEnvironment } from \"vitest/node\";\n\n/**\n * A builder for test configurations found in vite's defineConfig test field.\n */\nexport class ZViteTestBuilder {\n private test: InlineConfig;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this.test = {\n environment: \"node\",\n testTimeout: 30000,\n coverage: {\n all: false,\n provider: undefined,\n },\n };\n }\n\n /**\n * Sets the test environment.\n *\n * @param environment -\n * The test environment to use.\n *\n * @returns\n * This object.\n */\n public environment(environment: VitestEnvironment) {\n this.test.environment = environment;\n return this;\n }\n\n /**\n * Sets the test environment to \"node\".\n *\n * @returns\n * This object.\n */\n public node = this.environment.bind(this, \"node\");\n\n /**\n * Sets the test environment to \"happy-dom\".\n *\n * @returns\n * This object.\n */\n public browser = this.environment.bind(this, \"happy-dom\");\n\n /**\n * Sets the test coverage provider.\n *\n * @param provider -\n * The test coverage provider to use.\n *\n * @returns\n * This object.\n */\n public coverage(provider: \"v8\" | \"istanbul\") {\n this.test.coverage = { ...this.test.coverage, provider };\n return this;\n }\n\n /**\n * Sets the test coverage provider to \"v8\".\n *\n * @returns\n * This object.\n */\n public v8 = this.coverage.bind(this, \"v8\");\n\n /**\n * Sets the test coverage provider to \"istanbul\".\n *\n * @returns\n * This object.\n */\n public istanbul = this.coverage.bind(this, \"istanbul\");\n\n /**\n * Adds to the list of projects.\n *\n * @param project -\n * The list of projects.\n *\n * @returns\n * This object.\n */\n public project(project: string | string[] = []) {\n const projects = this.test.projects || [];\n this.test.projects = projects.concat(project);\n return this;\n }\n\n /**\n * Adds monorepo support to the test builder.\n *\n * @param packages -\n * The path to the package directory.\n *\n * @returns\n * This object.\n */\n public monorepo(packages = \"packages\") {\n return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);\n }\n\n /**\n * Returns the built test configuration.\n *\n * @returns\n * A deep clone of the test configuration.\n */\n public build() {\n return cloneDeep(this.test);\n }\n}\n","import { castArray, cloneDeep } from \"lodash-es\";\nimport swc from \"unplugin-swc\";\nimport type {\n LibraryOptions,\n PluginOption,\n ServerOptions,\n UserConfig,\n} from \"vite\";\nimport { checker } from \"vite-plugin-checker\";\nimport dtsPlugin from \"vite-plugin-dts\";\nimport { externalizeDeps } from \"vite-plugin-externalize-deps\";\nimport tsConfigPaths from \"vite-tsconfig-paths\";\nimport type { InlineConfig as TestConfig } from \"vitest/node.js\";\nimport { ZViteLibraryBuilder } from \"./vite-library-builder.mjs\";\nimport { ZViteTestBuilder } from \"./vite-test-builder.mjs\";\n\n/**\n * A config builder for the vite build system.\n *\n * This is helpful when building different types\n * of projects and keeping a standard.\n *\n * @example vite.config.ts\n *\n * ```ts\n * // Before Config Builder\n * export default defineConfig({\n * build: {\n * lib: {\n * entry: {\n * index: \"./src/index.ts\",\n * },\n * formats: [\"cjs\", \"es\"],\n * },\n * },\n * minify: false,\n * sourceMap: true,\n * plugins: [\n * swc.vite(),\n * tsConfigPaths(),\n * externalizeDeps(),\n * dtsPlugin({\n * compilerOptions: {\n * paths: {},\n * },\n * }),\n * ],\n * });\n * ```\n *\n * ```ts\n * // After config builder\n * const config = new ZViteConfigBuilder().library().build();\n * export default defineConfig(config);\n * ```\n */\nexport class ZViteConfigBuilder {\n private config: UserConfig;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this.config = {\n build: {\n minify: true,\n sourcemap: false,\n },\n plugins: [swc.vite(), tsConfigPaths()],\n };\n }\n\n /**\n * Sets whether to minify the build output.\n *\n * @param minify -\n * The flag as to minify the output.\n *\n * @returns\n * This object.\n */\n public minify(minify = true) {\n this.config.build = { ...this.config.build, minify };\n return this;\n }\n\n /**\n * Adds a list of plugins.\n *\n * @param option -\n * The plugins to add.\n *\n * @returns\n * This object.\n */\n public plugin(option: PluginOption | PluginOption[] = []) {\n // See constructor - the config plugins are guaranteed to\n // be set. The swc and paths plugins are automatically added.\n const plugins = this.config.plugins!;\n this.config.plugins = plugins.concat(castArray(option));\n return this;\n }\n\n /**\n * Sets whether to generate source maps.\n *\n * @param sourcemap -\n * True to generate a sourcemap, false for faster build.\n *\n * @returns\n * This object.\n */\n public sourceMap(sourcemap = true) {\n this.config.build = { ...this.config.build, sourcemap };\n return this;\n }\n\n /**\n * Assigns the server options.\n *\n * @param options -\n * The server options to assign.\n *\n * @returns\n * This object.\n */\n public server(options: ServerOptions) {\n this.config.server = cloneDeep(options);\n return this;\n }\n\n /**\n * Sets vite into library mode.\n *\n * @param lib -\n * The options for the library. You can set this to\n * nothing to use the default library which looks for\n * an entry point at the source directory called index.ts\n *\n * @see {@link ZViteLibraryBuilder} for more information.\n *\n * @returns\n * This object.\n */\n public library(\n lib: LibraryOptions = new ZViteLibraryBuilder().index().build(),\n ) {\n this.config.build = { ...this.config.build, lib };\n\n const dts = dtsPlugin({\n compilerOptions: {\n // Always turn off paths when building for production. You want to make\n // sure that your build is building in the correct order and that your\n // actual paths are correct.\n paths: {},\n },\n });\n const external = externalizeDeps();\n\n return this.minify(false).sourceMap().plugin(external).plugin(dts);\n }\n\n /**\n * Constructs the config to act as if it's compiling a node application.\n *\n * This is just an alias to {@link ZViteConfigBuilder.library} with two\n * entry points.\n *\n * 1. The file src/cli.ts is the main entry point of the application.\n * 1. The file, src/index.ts, is the api for importing\n *\n * @returns\n * This object.\n */\n public cli() {\n // A cli works similar to a library.\n const library = new ZViteLibraryBuilder()\n .entry(\"index\", \"src/index.ts\")\n .entry(\"cli\", \"src/cli.ts\")\n .build();\n return this.library(library);\n }\n\n /**\n * Constructs the config to act as if it's compiling a nest application.\n *\n * This is just an alias to {@link ZViteConfigBuilder.library} with a single\n * entry point.\n *\n * 1. The file, src/main.mts\n *\n * @returns\n * This object.\n */\n public nest() {\n const library = new ZViteLibraryBuilder()\n .entry(\"main\", \"src/main.mts\")\n .build();\n return this.library(library);\n }\n\n /**\n * Constructs the config to act as if it's compiling a web application.\n *\n * @returns\n * This object.\n */\n public web() {\n return this.minify()\n .sourceMap(false)\n .plugin(checker({ typescript: true }));\n }\n\n /**\n * An alias to {@link web}\n *\n * @returns\n * This object.\n */\n public react = this.web;\n\n /**\n * Constructs the config to be for testing.\n *\n * @param options -\n * The test config to use. If this is falsy,\n * then a test setup using a monorepo with an\n * istanbul provider in node is used.\n */\n public test(\n options: TestConfig = new ZViteTestBuilder()\n .node()\n .istanbul()\n .monorepo()\n .build(),\n ) {\n this.config.test = options;\n return this;\n }\n\n /**\n * Returns the currently built config.\n *\n * @returns\n * The currently built config.\n */\n public build() {\n return cloneDeep(this.config);\n }\n}\n","import { cloneDeep, isUndefined, omitBy } from \"lodash-es\";\nimport type { ServerOptions } from \"vite\";\n\nexport class ZViteServerBuilder {\n private options: ServerOptions = {};\n\n public allowedHost(name: string | string[] | true) {\n if (name === true) {\n this.options.allowedHosts = true;\n } else if (this.options.allowedHosts !== true) {\n const hosts = this.options.allowedHosts || [];\n this.options.allowedHosts = hosts.concat(name);\n }\n\n return this;\n }\n\n public denyAllHosts() {\n delete this.options.allowedHosts;\n return this;\n }\n\n public port(port?: number) {\n this.options.port = port;\n return this;\n }\n\n public strictPort() {\n this.options.strictPort = true;\n return this;\n }\n\n public host(ip: string) {\n this.options.host = ip;\n return this;\n }\n\n public localhost = this.host.bind(this, \"127.0.0.1\");\n\n public dev() {\n return this.strictPort().host(\"0.0.0.0\").allowedHost(true);\n }\n\n public build() {\n const clone = cloneDeep(this.options);\n return omitBy<ServerOptions>(clone, isUndefined) as ServerOptions;\n }\n}\n"],"names":["ZViteLibraryBuilder","entry","name","path","library","_object_spread_props","cloneDeep","_define_property","formats","ZViteTestBuilder","environment","test","coverage","provider","project","projects","concat","monorepo","packages","node","bind","browser","v8","istanbul","testTimeout","all","undefined","ZViteConfigBuilder","minify","config","build","plugin","option","plugins","castArray","sourceMap","sourcemap","server","options","lib","index","dts","dtsPlugin","compilerOptions","paths","external","externalizeDeps","checker","typescript","react","web","swc","vite","tsConfigPaths","ZViteServerBuilder","allowedHost","allowedHosts","hosts","denyAllHosts","port","strictPort","host","ip","dev","clone","omitBy","isUndefined","localhost"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAEC,IACM,MAAMA,mBAAAA,CAAAA;AAMX;;;;;;;;;;AAUC,MACD,KAAOC,CAAMC,IAAY,EAAEC,IAAY,EAAE;QACvC,IAAI,CAACC,OAAO,CAACH,KAAK,GAAGI,4CACf,IAAI,CAACD,OAAO,CAACH,KAAK,CAAA,EAAA;AACtB,YAAA,CAACC,OAAOC;;AAEV,QAAA,OAAO,IAAI;AACb;AAEA;;;;;;AAMC,MACD,KAAe,GAAA;AACb,QAAA,OAAO,IAAI,CAACF,KAAK,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