@zthun/janitor-build-config 19.0.0 → 19.1.1
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 +80 -107
- package/dist/typedoc.cjs.map +1 -1
- package/dist/typedoc.js +81 -104
- package/dist/typedoc.js.map +1 -1
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/vite-config-builder.d.mts +81 -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 +268 -260
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.js +271 -257
- package/dist/vite.js.map +1 -1
- package/package.json +15 -10
package/dist/vite.js
CHANGED
|
@@ -1,60 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
obj[key] = value;
|
|
17
|
-
}
|
|
18
|
-
return obj;
|
|
19
|
-
}
|
|
20
|
-
function _object_spread(target) {
|
|
21
|
-
for(var i = 1; i < arguments.length; i++){
|
|
22
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
23
|
-
var ownKeys = Object.keys(source);
|
|
24
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
25
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
26
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
ownKeys.forEach(function(key) {
|
|
30
|
-
_define_property$2(target, key, source[key]);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
}
|
|
35
|
-
function ownKeys(object, enumerableOnly) {
|
|
36
|
-
var keys = Object.keys(object);
|
|
37
|
-
if (Object.getOwnPropertySymbols) {
|
|
38
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
39
|
-
keys.push.apply(keys, symbols);
|
|
40
|
-
}
|
|
41
|
-
return keys;
|
|
42
|
-
}
|
|
43
|
-
function _object_spread_props(target, source) {
|
|
44
|
-
source = source != null ? source : {};
|
|
45
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
46
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
47
|
-
} else {
|
|
48
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
49
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return target;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* A builder for Vite library configurations.
|
|
56
|
-
*/ class ZViteLibraryBuilder {
|
|
57
|
-
/**
|
|
1
|
+
import react from "@vitejs/plugin-react";
|
|
2
|
+
import { cloneDeep, castArray, omitBy, isUndefined } from "lodash-es";
|
|
3
|
+
import swc from "unplugin-swc";
|
|
4
|
+
import { checker } from "vite-plugin-checker";
|
|
5
|
+
import dtsPlugin from "vite-plugin-dts";
|
|
6
|
+
import { externalizeDeps } from "vite-plugin-externalize-deps";
|
|
7
|
+
import tsConfigPaths from "vite-tsconfig-paths";
|
|
8
|
+
class ZViteLibraryBuilder {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.library = {
|
|
11
|
+
entry: {},
|
|
12
|
+
formats: ["es", "cjs"]
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
58
16
|
* Adds an entry point to the library.
|
|
59
17
|
*
|
|
60
18
|
* @param name -
|
|
@@ -64,57 +22,53 @@ function _object_spread_props(target, source) {
|
|
|
64
22
|
*
|
|
65
23
|
* @returns
|
|
66
24
|
* This object.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
25
|
+
*/
|
|
26
|
+
entry(name, path) {
|
|
27
|
+
this.library.entry = {
|
|
28
|
+
...this.library.entry,
|
|
29
|
+
[name]: path
|
|
30
|
+
};
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
74
34
|
* A shorthand for adding an entry point
|
|
75
35
|
* named "index" that points to "src/index.ts"
|
|
76
36
|
*
|
|
77
37
|
* @returns
|
|
78
38
|
* This object.
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
39
|
+
*/
|
|
40
|
+
index() {
|
|
41
|
+
return this.entry("index", "./src/index.ts");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
83
44
|
* Returns the built library configuration.
|
|
84
45
|
*
|
|
85
46
|
* @returns
|
|
86
47
|
* A deep clone of the library configuration.
|
|
87
|
-
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
_define_property$2(this, "library", {
|
|
92
|
-
entry: {},
|
|
93
|
-
formats: [
|
|
94
|
-
"es",
|
|
95
|
-
"cjs"
|
|
96
|
-
]
|
|
97
|
-
});
|
|
98
|
-
}
|
|
48
|
+
*/
|
|
49
|
+
build() {
|
|
50
|
+
return cloneDeep(this.library);
|
|
51
|
+
}
|
|
99
52
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
53
|
+
class ZViteTestBuilder {
|
|
54
|
+
/**
|
|
55
|
+
* Initializes a new instance of this object.
|
|
56
|
+
*/
|
|
57
|
+
constructor() {
|
|
58
|
+
this.node = this.environment.bind(this, "node");
|
|
59
|
+
this.browser = this.environment.bind(this, "happy-dom");
|
|
60
|
+
this.v8 = this.coverage.bind(this, "v8");
|
|
61
|
+
this.istanbul = this.coverage.bind(this, "istanbul");
|
|
62
|
+
this.test = {
|
|
63
|
+
environment: "node",
|
|
64
|
+
testTimeout: 3e4,
|
|
65
|
+
coverage: {
|
|
66
|
+
all: false,
|
|
67
|
+
provider: void 0
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
118
72
|
* Sets the test environment.
|
|
119
73
|
*
|
|
120
74
|
* @param environment -
|
|
@@ -122,11 +76,12 @@ function _define_property$1(obj, key, value) {
|
|
|
122
76
|
*
|
|
123
77
|
* @returns
|
|
124
78
|
* This object.
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
79
|
+
*/
|
|
80
|
+
environment(environment) {
|
|
81
|
+
this.test.environment = environment;
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
130
85
|
* Sets the test coverage provider.
|
|
131
86
|
*
|
|
132
87
|
* @param provider -
|
|
@@ -134,114 +89,126 @@ function _define_property$1(obj, key, value) {
|
|
|
134
89
|
*
|
|
135
90
|
* @returns
|
|
136
91
|
* This object.
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
92
|
+
*/
|
|
93
|
+
coverage(provider) {
|
|
94
|
+
this.test.coverage = { ...this.test.coverage, provider };
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Adds to the list of projects.
|
|
99
|
+
*
|
|
100
|
+
* @param project -
|
|
101
|
+
* The list of projects.
|
|
102
|
+
*
|
|
103
|
+
* @returns
|
|
104
|
+
* This object.
|
|
105
|
+
*/
|
|
106
|
+
project(project = []) {
|
|
107
|
+
const projects = this.test.projects || [];
|
|
108
|
+
this.test.projects = projects.concat(project);
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Adds monorepo support to the test builder.
|
|
113
|
+
*
|
|
114
|
+
* @param packages -
|
|
115
|
+
* The path to the package directory.
|
|
116
|
+
*
|
|
117
|
+
* @returns
|
|
118
|
+
* This object.
|
|
119
|
+
*/
|
|
120
|
+
monorepo(packages = "packages") {
|
|
121
|
+
return this.project(`${packages}/*/vitest.config.{js,cjs,mjs,ts,mts}`);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
142
124
|
* Returns the built test configuration.
|
|
143
125
|
*
|
|
144
126
|
* @returns
|
|
145
127
|
* A deep clone of the test configuration.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
128
|
+
*/
|
|
129
|
+
build() {
|
|
130
|
+
return cloneDeep(this.test);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
class ZViteConfigBuilder {
|
|
134
|
+
/**
|
|
150
135
|
* Initializes a new instance of this object.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
136
|
+
*/
|
|
137
|
+
constructor() {
|
|
138
|
+
this.config = {
|
|
139
|
+
build: {
|
|
140
|
+
minify: true,
|
|
141
|
+
sourcemap: false
|
|
142
|
+
},
|
|
143
|
+
plugins: [tsConfigPaths()]
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Sets whether to minify the build output.
|
|
148
|
+
*
|
|
149
|
+
* @param minify -
|
|
150
|
+
* The flag as to minify the output.
|
|
155
151
|
*
|
|
156
152
|
* @returns
|
|
157
153
|
* This object.
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
|
|
154
|
+
*/
|
|
155
|
+
minify(minify = true) {
|
|
156
|
+
this.config.build = { ...this.config.build, minify };
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Adds a list of plugins.
|
|
161
|
+
*
|
|
162
|
+
* @param option -
|
|
163
|
+
* The plugins to add.
|
|
161
164
|
*
|
|
162
165
|
* @returns
|
|
163
166
|
* This object.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
*/
|
|
168
|
+
plugin(option = []) {
|
|
169
|
+
const plugins = this.config.plugins;
|
|
170
|
+
this.config.plugins = plugins.concat(castArray(option));
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Adds the swc plugin.
|
|
175
|
+
*
|
|
176
|
+
* This is mostly for nest projects as nest requires
|
|
177
|
+
* swc to support decorators.
|
|
178
|
+
*/
|
|
179
|
+
swc() {
|
|
180
|
+
return this.plugin(swc.vite());
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Sets whether to generate source maps.
|
|
184
|
+
*
|
|
185
|
+
* @param sourcemap -
|
|
186
|
+
* True to generate a sourcemap, false for faster build.
|
|
167
187
|
*
|
|
168
188
|
* @returns
|
|
169
189
|
* This object.
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
*/
|
|
191
|
+
sourceMap(sourcemap = true) {
|
|
192
|
+
this.config.build = { ...this.config.build, sourcemap };
|
|
193
|
+
return this;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Assigns the server options.
|
|
197
|
+
*
|
|
198
|
+
* @param options -
|
|
199
|
+
* The server options to assign.
|
|
173
200
|
*
|
|
174
201
|
* @returns
|
|
175
202
|
* This object.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
provider: undefined
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function _define_property(obj, key, value) {
|
|
189
|
-
if (key in obj) {
|
|
190
|
-
Object.defineProperty(obj, key, {
|
|
191
|
-
value: value,
|
|
192
|
-
enumerable: true,
|
|
193
|
-
configurable: true,
|
|
194
|
-
writable: true
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
obj[key] = value;
|
|
198
|
-
}
|
|
199
|
-
return obj;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* A config builder for the vite build system.
|
|
203
|
-
*
|
|
204
|
-
* This is helpful when building different types
|
|
205
|
-
* of projects and keeping a standard.
|
|
206
|
-
*
|
|
207
|
-
* @example vite.config.ts
|
|
208
|
-
*
|
|
209
|
-
* ```ts
|
|
210
|
-
* // Before Config Builder
|
|
211
|
-
* export default defineConfig({
|
|
212
|
-
* build: {
|
|
213
|
-
* lib: {
|
|
214
|
-
* entry: {
|
|
215
|
-
* index: "./src/index.ts",
|
|
216
|
-
* },
|
|
217
|
-
* formats: ["cjs", "es"],
|
|
218
|
-
* },
|
|
219
|
-
* },
|
|
220
|
-
* minify: false,
|
|
221
|
-
* sourceMap: true,
|
|
222
|
-
* plugins: [
|
|
223
|
-
* swc.vite(),
|
|
224
|
-
* tsConfigPaths(),
|
|
225
|
-
* externalizeDeps(),
|
|
226
|
-
* dtsPlugin({
|
|
227
|
-
* compilerOptions: {
|
|
228
|
-
* paths: {},
|
|
229
|
-
* },
|
|
230
|
-
* }),
|
|
231
|
-
* ],
|
|
232
|
-
* });
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* ```ts
|
|
236
|
-
* // After config builder
|
|
237
|
-
* const config = new ZViteConfigBuilder().library().build();
|
|
238
|
-
* export default defineConfig(config);
|
|
239
|
-
* ```
|
|
240
|
-
*/ class ZViteConfigBuilder {
|
|
241
|
-
/**
|
|
203
|
+
*/
|
|
204
|
+
server(options) {
|
|
205
|
+
this.config.server = cloneDeep(options);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
242
209
|
* Sets vite into library mode.
|
|
243
210
|
*
|
|
244
|
-
* @param
|
|
211
|
+
* @param lib -
|
|
245
212
|
* The options for the library. You can set this to
|
|
246
213
|
* nothing to use the default library which looks for
|
|
247
214
|
* an entry point at the source directory called index.ts
|
|
@@ -250,33 +217,21 @@ function _define_property(obj, key, value) {
|
|
|
250
217
|
*
|
|
251
218
|
* @returns
|
|
252
219
|
* This object.
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
dtsPlugin({
|
|
269
|
-
compilerOptions: {
|
|
270
|
-
// Always turn off paths when building for production. You want to make
|
|
271
|
-
// sure that your build is building in the correct order and that your
|
|
272
|
-
// actual paths are correct.
|
|
273
|
-
paths: {}
|
|
274
|
-
}
|
|
275
|
-
})
|
|
276
|
-
];
|
|
277
|
-
return this;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
220
|
+
*/
|
|
221
|
+
library(lib = new ZViteLibraryBuilder().index().build()) {
|
|
222
|
+
this.config.build = { ...this.config.build, lib };
|
|
223
|
+
const dts = dtsPlugin({
|
|
224
|
+
compilerOptions: {
|
|
225
|
+
// Always turn off paths when building for production. You want to make
|
|
226
|
+
// sure that your build is building in the correct order and that your
|
|
227
|
+
// actual paths are correct.
|
|
228
|
+
paths: {}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
const external = externalizeDeps();
|
|
232
|
+
return this.minify(false).sourceMap().plugin(external).plugin(dts);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
280
235
|
* Constructs the config to act as if it's compiling a node application.
|
|
281
236
|
*
|
|
282
237
|
* This is just an alias to {@link ZViteConfigBuilder.library} with two
|
|
@@ -287,49 +242,108 @@ function _define_property(obj, key, value) {
|
|
|
287
242
|
*
|
|
288
243
|
* @returns
|
|
289
244
|
* This object.
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
245
|
+
*/
|
|
246
|
+
cli() {
|
|
247
|
+
const library = new ZViteLibraryBuilder().entry("index", "src/index.ts").entry("cli", "src/cli.ts").build();
|
|
248
|
+
return this.library(library);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Constructs the config to act as if it's compiling a nest application.
|
|
252
|
+
*
|
|
253
|
+
* This is just an alias to {@link ZViteConfigBuilder.library} with a single
|
|
254
|
+
* entry point.
|
|
255
|
+
*
|
|
256
|
+
* 1. The file, src/main.mts
|
|
257
|
+
*
|
|
258
|
+
* @returns
|
|
259
|
+
* This object.
|
|
260
|
+
*/
|
|
261
|
+
nest() {
|
|
262
|
+
const library = new ZViteLibraryBuilder().entry("main", "src/main.mts").build();
|
|
263
|
+
return this.library(library).swc();
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Constructs the config to act as if it's compiling a web application.
|
|
267
|
+
*
|
|
268
|
+
* @returns
|
|
269
|
+
* This object.
|
|
270
|
+
*/
|
|
271
|
+
web() {
|
|
272
|
+
return this.minify().sourceMap(false).plugin(checker({ typescript: true }));
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Constructs the config to compile a react application.
|
|
276
|
+
*
|
|
277
|
+
* @returns
|
|
278
|
+
* This object.
|
|
279
|
+
*/
|
|
280
|
+
react() {
|
|
281
|
+
return this.web().plugin(react());
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
298
284
|
* Constructs the config to be for testing.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
285
|
+
*
|
|
286
|
+
* @param options -
|
|
287
|
+
* The test config to use. If this is falsy,
|
|
288
|
+
* then a test setup using a monorepo with an
|
|
289
|
+
* istanbul provider in node is used.
|
|
290
|
+
*/
|
|
291
|
+
test(options = new ZViteTestBuilder().node().istanbul().monorepo().build()) {
|
|
292
|
+
this.config.test = options;
|
|
293
|
+
return this;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
304
296
|
* Returns the currently built config.
|
|
305
297
|
*
|
|
306
298
|
* @returns
|
|
307
299
|
* The currently built config.
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
sourcemap: false
|
|
325
|
-
},
|
|
326
|
-
plugins: [
|
|
327
|
-
swc.vite(),
|
|
328
|
-
tsConfigPaths()
|
|
329
|
-
]
|
|
330
|
-
};
|
|
300
|
+
*/
|
|
301
|
+
build() {
|
|
302
|
+
return cloneDeep(this.config);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
class ZViteServerBuilder {
|
|
306
|
+
constructor() {
|
|
307
|
+
this.options = {};
|
|
308
|
+
this.localhost = this.host.bind(this, "127.0.0.1");
|
|
309
|
+
}
|
|
310
|
+
allowedHost(name) {
|
|
311
|
+
if (name === true) {
|
|
312
|
+
this.options.allowedHosts = true;
|
|
313
|
+
} else if (this.options.allowedHosts !== true) {
|
|
314
|
+
const hosts = this.options.allowedHosts || [];
|
|
315
|
+
this.options.allowedHosts = hosts.concat(name);
|
|
331
316
|
}
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
denyAllHosts() {
|
|
320
|
+
delete this.options.allowedHosts;
|
|
321
|
+
return this;
|
|
322
|
+
}
|
|
323
|
+
port(port) {
|
|
324
|
+
this.options.port = port;
|
|
325
|
+
return this;
|
|
326
|
+
}
|
|
327
|
+
strictPort() {
|
|
328
|
+
this.options.strictPort = true;
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
host(ip) {
|
|
332
|
+
this.options.host = ip;
|
|
333
|
+
return this;
|
|
334
|
+
}
|
|
335
|
+
dev() {
|
|
336
|
+
return this.strictPort().host("0.0.0.0").allowedHost(true);
|
|
337
|
+
}
|
|
338
|
+
build() {
|
|
339
|
+
const clone = cloneDeep(this.options);
|
|
340
|
+
return omitBy(clone, isUndefined);
|
|
341
|
+
}
|
|
332
342
|
}
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
export {
|
|
344
|
+
ZViteConfigBuilder,
|
|
345
|
+
ZViteLibraryBuilder,
|
|
346
|
+
ZViteServerBuilder,
|
|
347
|
+
ZViteTestBuilder
|
|
348
|
+
};
|
|
335
349
|
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.js","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,SAAAA,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,W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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.js","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 react from \"@vitejs/plugin-react\";\nimport { 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: [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 * Adds the swc plugin.\n *\n * This is mostly for nest projects as nest requires\n * swc to support decorators.\n */\n public swc() {\n return this.plugin(swc.vite());\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).swc();\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 * Constructs the config to compile a react application.\n *\n * @returns\n * This object.\n */\n public react() {\n return this.web().plugin(react());\n }\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":[],"mappings":";;;;;;;AAMO,MAAM,oBAAoB;AAAA,EAA1B,cAAA;AACL,SAAQ,UAA0B;AAAA,MAChC,OAAO,CAAC;AAAA,MACR,SAAS,CAAC,MAAM,KAAK;AAAA,IACvB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaO,MAAM,MAAc,MAAc;AACvC,SAAK,QAAQ,QAAQ;AAAA,MACnB,GAAI,KAAK,QAAQ;AAAA,MACjB,CAAC,IAAI,GAAG;AAAA,IACV;AACO,WAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUF,QAAQ;AACN,WAAA,KAAK,MAAM,SAAS,gBAAgB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAStC,QAAQ;AACN,WAAA,UAAU,KAAK,OAAO;AAAA,EAAA;AAEjC;AC7CO,MAAM,iBAAiB;AAAA;AAAA;A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