vite-plugin-lib 2.0.13 → 2.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/index.d.mts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.mjs +35 -9
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -9,17 +9,23 @@ declare const coverage: {
|
|
|
9
9
|
provider: "v8";
|
|
10
10
|
};
|
|
11
11
|
interface Options {
|
|
12
|
-
/** Defaults to
|
|
12
|
+
/** Defaults to `src/index.ts`. */
|
|
13
13
|
entry: string;
|
|
14
14
|
externalPackages?: (string | RegExp)[];
|
|
15
|
-
/** Defaults to ['es'] */
|
|
15
|
+
/** Defaults to `['es']`. */
|
|
16
16
|
formats?: LibraryFormats[];
|
|
17
|
-
/** Defaults to
|
|
17
|
+
/** Defaults to `package.json`. */
|
|
18
18
|
manifest: string;
|
|
19
19
|
name?: string;
|
|
20
20
|
verbose?: boolean;
|
|
21
|
+
/** Remove any temporary build files. Defaults to `true`. */
|
|
22
|
+
cleanup?: boolean;
|
|
21
23
|
}
|
|
22
24
|
declare function tsconfigPaths(options?: Partial<Options>): Plugin;
|
|
23
25
|
declare function library(options?: Partial<Options>): Plugin[];
|
|
26
|
+
/**
|
|
27
|
+
* Remove any temporary `vite.config.ts.timestamp-*` files.
|
|
28
|
+
*/
|
|
29
|
+
declare function cleanup(): Plugin;
|
|
24
30
|
|
|
25
|
-
export { type Options, coverage, library, tsconfigPaths };
|
|
31
|
+
export { type Options, cleanup, coverage, library, tsconfigPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,17 +9,23 @@ declare const coverage: {
|
|
|
9
9
|
provider: "v8";
|
|
10
10
|
};
|
|
11
11
|
interface Options {
|
|
12
|
-
/** Defaults to
|
|
12
|
+
/** Defaults to `src/index.ts`. */
|
|
13
13
|
entry: string;
|
|
14
14
|
externalPackages?: (string | RegExp)[];
|
|
15
|
-
/** Defaults to ['es'] */
|
|
15
|
+
/** Defaults to `['es']`. */
|
|
16
16
|
formats?: LibraryFormats[];
|
|
17
|
-
/** Defaults to
|
|
17
|
+
/** Defaults to `package.json`. */
|
|
18
18
|
manifest: string;
|
|
19
19
|
name?: string;
|
|
20
20
|
verbose?: boolean;
|
|
21
|
+
/** Remove any temporary build files. Defaults to `true`. */
|
|
22
|
+
cleanup?: boolean;
|
|
21
23
|
}
|
|
22
24
|
declare function tsconfigPaths(options?: Partial<Options>): Plugin;
|
|
23
25
|
declare function library(options?: Partial<Options>): Plugin[];
|
|
26
|
+
/**
|
|
27
|
+
* Remove any temporary `vite.config.ts.timestamp-*` files.
|
|
28
|
+
*/
|
|
29
|
+
declare function cleanup(): Plugin;
|
|
24
30
|
|
|
25
|
-
export { type Options, coverage, library, tsconfigPaths };
|
|
31
|
+
export { type Options, cleanup, coverage, library, tsconfigPaths };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readdirSync, rmSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { unlink, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { builtinModules } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -107,7 +107,8 @@ const coverage = {
|
|
|
107
107
|
const defaults = {
|
|
108
108
|
entry: "src/index.ts",
|
|
109
109
|
formats: ["es"],
|
|
110
|
-
manifest: "package.json"
|
|
110
|
+
manifest: "package.json",
|
|
111
|
+
cleanup: true
|
|
111
112
|
};
|
|
112
113
|
function mergeWithDefaults(options) {
|
|
113
114
|
return {
|
|
@@ -265,7 +266,7 @@ function formatToFileName(entry, format) {
|
|
|
265
266
|
}
|
|
266
267
|
function library(options = {}) {
|
|
267
268
|
const mergedOptions = mergeWithDefaults(options);
|
|
268
|
-
|
|
269
|
+
const plugins = [
|
|
269
270
|
tsconfigPaths(),
|
|
270
271
|
buildConfig(mergedOptions),
|
|
271
272
|
dts__default({
|
|
@@ -274,13 +275,21 @@ function library(options = {}) {
|
|
|
274
275
|
include: `${path.resolve(mergedOptions.entry, "..")}/**`,
|
|
275
276
|
outDir: typesDir,
|
|
276
277
|
staticImport: true,
|
|
277
|
-
afterBuild:
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
afterBuild: async () => {
|
|
279
|
+
if (includesESFormat(mergedOptions.formats)) {
|
|
280
|
+
await generateMTSDeclarations(
|
|
281
|
+
typesDir,
|
|
282
|
+
mergedOptions.formats?.length === 1,
|
|
283
|
+
options.verbose
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
282
287
|
})
|
|
283
288
|
];
|
|
289
|
+
if (mergedOptions.cleanup) {
|
|
290
|
+
plugins.push(cleanup());
|
|
291
|
+
}
|
|
292
|
+
return plugins;
|
|
284
293
|
}
|
|
285
294
|
function transformExistingAlias(alias) {
|
|
286
295
|
if (!alias) {
|
|
@@ -317,5 +326,22 @@ function getErrorMessage(error) {
|
|
|
317
326
|
const isObject = typeof error === "object" && error !== null && "message" in error;
|
|
318
327
|
return isObject ? error.message : String(error);
|
|
319
328
|
}
|
|
329
|
+
function cleanup() {
|
|
330
|
+
return {
|
|
331
|
+
name: "vite-plugin-lib:cleanup",
|
|
332
|
+
enforce: "post",
|
|
333
|
+
closeBundle: () => {
|
|
334
|
+
let deletedCount = 0;
|
|
335
|
+
readdirSync(".").forEach((file) => {
|
|
336
|
+
if (!file.startsWith("vite.config.ts.timestamp-")) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
rmSync(`./${file}`);
|
|
340
|
+
deletedCount++;
|
|
341
|
+
});
|
|
342
|
+
log(`Removed ${deletedCount} temporary files.`);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
320
346
|
|
|
321
|
-
export { coverage, library, tsconfigPaths };
|
|
347
|
+
export { cleanup, coverage, library, tsconfigPaths };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Vite plugin for build configuration, automatic aliases, and type declarations.",
|
|
5
5
|
"author": "Jan Müller <janmueller3698@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "5.5.4",
|
|
47
47
|
"unbuild": "2.0.0",
|
|
48
48
|
"vite": "5.3.5",
|
|
49
|
-
"@yeger/tsconfig": "2.0.
|
|
49
|
+
"@yeger/tsconfig": "2.0.8"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|