unplugin-dts-bundle-generator 3.1.0 → 3.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/README.md CHANGED
@@ -22,6 +22,7 @@ Currently, only Vite and Rollup are fully supported, more bundlers to come. Plea
22
22
 
23
23
  <details>
24
24
  <summary>Vite</summary><br>
25
+
25
26
  With Vite, add this block to your `vite.config.ts`:
26
27
 
27
28
  ```ts
@@ -57,6 +58,7 @@ export default defineConfig({
57
58
 
58
59
  <details>
59
60
  <summary>Rollup</summary><br>
61
+
60
62
  With Rollup, add this block to your `rollup.config.ts`:
61
63
 
62
64
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-dts-bundle-generator",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "DTS bundle generator for Unplugin",
5
5
  "keywords": [
6
6
  "unplugin",
@@ -1,6 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint",
4
- "editorconfig.editorconfig"
5
- ]
6
- }
@@ -1,10 +0,0 @@
1
- {
2
- "[json]": {
3
- "editor.defaultFormatter": "dbaeumer.vscode-eslint",
4
- "editor.quickSuggestions": {
5
- "strings": true
6
- },
7
- "editor.suggest.insertMode": "replace",
8
- "editor.tabSize": 2
9
- }
10
- }
@@ -1,82 +0,0 @@
1
- import { Buffer } from 'node:buffer';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import zlib from 'node:zlib';
5
- import { generateDtsBundle } from 'dts-bundle-generator';
6
- import colors from 'picocolors';
7
-
8
- const assignEntry = (entry, input) => {
9
- if (typeof input == 'string') {
10
- Object.assign(entry, {
11
- default: input,
12
- });
13
- }
14
- else if (Array.isArray(input)) {
15
- input.forEach((i) => {
16
- Object.assign(entry, {
17
- [path.basename(i, path.extname(i))]: i,
18
- });
19
- });
20
- }
21
- else {
22
- Object.assign(entry, input);
23
- }
24
- };
25
- const unpluginFactory = (options) => {
26
- const bundles = [];
27
- const entry = {};
28
- const buildConfig = {};
29
- const fileName = typeof options.fileName == 'string' ? () => options.fileName : options.fileName;
30
- return {
31
- name: 'unplugin-dts-bundle-generator',
32
- buildEnd() {
33
- const entryPointConfigs = Object.values(entry).map((entryPath) => ({
34
- filePath: entryPath,
35
- libraries: options.libraries,
36
- output: options.output,
37
- }));
38
- generateDtsBundle(entryPointConfigs, options.compilation).forEach((content, i) => bundles.push({
39
- compressedSize: zlib.gzipSync(content).length,
40
- content,
41
- outFile: fileName(Object.keys(entry)[i]),
42
- size: Buffer.byteLength(content),
43
- }));
44
- },
45
- writeBundle() {
46
- bundles.forEach((bundle) => fs.writeFileSync(path.resolve(buildConfig.outDir ?? '', bundle.outFile), bundle.content));
47
- },
48
- rollup: {
49
- buildStart(options) {
50
- assignEntry(entry, options.input);
51
- },
52
- outputOptions(outputOptions) {
53
- buildConfig.outDir = outputOptions.dir;
54
- return outputOptions;
55
- },
56
- },
57
- vite: {
58
- configResolved(config) {
59
- if (config.build.lib) {
60
- assignEntry(entry, config.build.lib.entry);
61
- }
62
- buildConfig.outDir = config.build.outDir;
63
- },
64
- closeBundle() {
65
- const length = bundles.length.toString();
66
- this.environment.logger.info(`\n${colors.green('✓')} ${length} declaration bundles generated.`);
67
- const options = {
68
- maximumFractionDigits: 2,
69
- minimumFractionDigits: 2,
70
- };
71
- const outFileLength = Math.max(...bundles.map((bundle) => bundle.outFile.length));
72
- bundles.forEach((bundle) => this.environment.logger.info(colors.dim(`${buildConfig.outDir}/`)
73
- + colors.cyan(`${bundle.outFile}`)
74
- + ' '.repeat(outFileLength - bundle.outFile.length + 2)
75
- + colors.gray(`${(bundle.size / 1000).toLocaleString('en', options)} kB │ `)
76
- + colors.dim(`gzip: ${(bundle.compressedSize / 1000).toLocaleString('en', options)} kB`)));
77
- },
78
- },
79
- };
80
- };
81
-
82
- export { unpluginFactory as u };
@@ -1,15 +0,0 @@
1
- import { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';
2
-
3
- export interface Options {
4
- fileName: string | ((entryName: string) => string);
5
- output?: EntryPointConfig["output"];
6
- libraries?: EntryPointConfig["libraries"];
7
- compilation?: CompilationOptions;
8
- }
9
- declare const _default: import("unplugin").UnpluginInstance<Options, false>;
10
-
11
- export {
12
- _default as default,
13
- };
14
-
15
- export {};
@@ -1,12 +0,0 @@
1
- import { createUnplugin } from 'unplugin';
2
- import { u as unpluginFactory } from './factory.es.js';
3
- import 'node:buffer';
4
- import 'node:fs';
5
- import 'node:path';
6
- import 'node:zlib';
7
- import 'dts-bundle-generator';
8
- import 'picocolors';
9
-
10
- var index = createUnplugin(unpluginFactory);
11
-
12
- export { index as default };
@@ -1,15 +0,0 @@
1
- import { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';
2
-
3
- export interface Options {
4
- fileName: string | ((entryName: string) => string);
5
- output?: EntryPointConfig["output"];
6
- libraries?: EntryPointConfig["libraries"];
7
- compilation?: CompilationOptions;
8
- }
9
- declare const _default: (options: Options) => import("rollup").Plugin<any> | import("rollup").Plugin<any>[];
10
-
11
- export {
12
- _default as default,
13
- };
14
-
15
- export {};
@@ -1,12 +0,0 @@
1
- import { createRollupPlugin } from 'unplugin';
2
- import { u as unpluginFactory } from './factory.es.js';
3
- import 'node:buffer';
4
- import 'node:fs';
5
- import 'node:path';
6
- import 'node:zlib';
7
- import 'dts-bundle-generator';
8
- import 'picocolors';
9
-
10
- var rollup = createRollupPlugin(unpluginFactory);
11
-
12
- export { rollup as default };
@@ -1,15 +0,0 @@
1
- import { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';
2
-
3
- export interface Options {
4
- fileName: string | ((entryName: string) => string);
5
- output?: EntryPointConfig["output"];
6
- libraries?: EntryPointConfig["libraries"];
7
- compilation?: CompilationOptions;
8
- }
9
- declare const _default: (options: Options) => import("vite").Plugin<any> | import("vite").Plugin<any>[];
10
-
11
- export {
12
- _default as default,
13
- };
14
-
15
- export {};
@@ -1,12 +0,0 @@
1
- import { createVitePlugin } from 'unplugin';
2
- import { u as unpluginFactory } from './factory.es.js';
3
- import 'node:buffer';
4
- import 'node:fs';
5
- import 'node:path';
6
- import 'node:zlib';
7
- import 'dts-bundle-generator';
8
- import 'picocolors';
9
-
10
- var vite = createVitePlugin(unpluginFactory);
11
-
12
- export { vite as default };