unplugin-dts-bundle-generator 3.0.0 → 3.0.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/dts-bundle-generator.cjs +1 -1
- package/dist/dts-bundle-generator.mjs +1 -1
- package/dist/{factory-D34KlQ_a.js → factory-77C0Vfx8.js} +11 -8
- package/dist/factory-77C0Vfx8.js.map +1 -0
- package/dist/factory-SCNW8ysY.cjs +3 -0
- package/dist/factory-SCNW8ysY.cjs.map +1 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +2 -2
- package/dist/factory-D34KlQ_a.js.map +0 -1
- package/dist/factory-v7XFnpMY.cjs +0 -3
- package/dist/factory-v7XFnpMY.cjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const n=require("unplugin"),e=require("./factory-
|
|
1
|
+
"use strict";const n=require("unplugin"),e=require("./factory-SCNW8ysY.cjs"),r=n.createUnplugin(e.unpluginFactory);module.exports=r;
|
|
2
2
|
//# sourceMappingURL=dts-bundle-generator.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Buffer as c } from "node:buffer";
|
|
2
|
-
import
|
|
2
|
+
import g from "node:fs";
|
|
3
3
|
import a from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import { generateDtsBundle as
|
|
4
|
+
import f from "node:zlib";
|
|
5
|
+
import { generateDtsBundle as u } from "dts-bundle-generator";
|
|
6
6
|
import s from "picocolors";
|
|
7
7
|
const d = (e, i) => {
|
|
8
8
|
typeof i == "string" ? Object.assign(e, {
|
|
@@ -13,7 +13,7 @@ const d = (e, i) => {
|
|
|
13
13
|
});
|
|
14
14
|
}) : Object.assign(e, i);
|
|
15
15
|
}, F = (e) => {
|
|
16
|
-
const i = [], o = {}, l = {}, m = typeof e.fileName == "
|
|
16
|
+
const i = [], o = {}, l = {}, m = typeof e.fileName == "string" ? () => e.fileName : e.fileName;
|
|
17
17
|
return {
|
|
18
18
|
name: "unplugin-dts-bundle-generator",
|
|
19
19
|
buildEnd() {
|
|
@@ -22,15 +22,18 @@ const d = (e, i) => {
|
|
|
22
22
|
libraries: e.libraries,
|
|
23
23
|
output: e.output
|
|
24
24
|
}));
|
|
25
|
-
|
|
26
|
-
compressedSize:
|
|
25
|
+
u(t, e.compilation).forEach((r, n) => i.push({
|
|
26
|
+
compressedSize: f.gzipSync(r).length,
|
|
27
27
|
content: r,
|
|
28
28
|
outFile: m(Object.keys(o)[n]),
|
|
29
29
|
size: c.byteLength(r)
|
|
30
30
|
}));
|
|
31
31
|
},
|
|
32
32
|
writeBundle() {
|
|
33
|
-
i.forEach((t) =>
|
|
33
|
+
i.forEach((t) => g.writeFileSync(
|
|
34
|
+
a.resolve(l.outDir ?? "", t.outFile),
|
|
35
|
+
t.content
|
|
36
|
+
));
|
|
34
37
|
},
|
|
35
38
|
vite: {
|
|
36
39
|
configResolved(t) {
|
|
@@ -54,4 +57,4 @@ ${s.green("✓")} ${t} declaration bundles generated.`);
|
|
|
54
57
|
export {
|
|
55
58
|
F as u
|
|
56
59
|
};
|
|
57
|
-
//# sourceMappingURL=factory-
|
|
60
|
+
//# sourceMappingURL=factory-77C0Vfx8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory-77C0Vfx8.js","sources":["../src/core/factory.ts"],"sourcesContent":["import type { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';\nimport type { InputOption } from 'rollup';\nimport type { UnpluginFactory } from 'unplugin';\n\nimport { Buffer } from 'node:buffer';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { generateDtsBundle } from 'dts-bundle-generator';\nimport colors from 'picocolors';\n\nexport interface Options {\n fileName: string | ((entryName: string) => string);\n output?: EntryPointConfig['output'];\n libraries?: EntryPointConfig['libraries'];\n compilation?: CompilationOptions;\n}\n\ninterface DeclarationBundle {\n compressedSize: number;\n content: string;\n outFile: string;\n size: number;\n}\n\ninterface BuildConfig {\n outDir?: string;\n}\n\nconst assignEntry = (entry: Record<string, string>, input: InputOption): void => {\n if (typeof input == 'string') {\n Object.assign(entry, {\n default: input,\n });\n }\n else if (Array.isArray(input)) {\n input.forEach((i) => {\n Object.assign(entry, {\n [path.basename(i, path.extname(i))]: i,\n });\n });\n }\n else {\n Object.assign(entry, input);\n }\n};\n\nexport const unpluginFactory: UnpluginFactory<Options, false> = (options) => {\n const bundles: Array<DeclarationBundle> = [];\n const entry: Record<string, string> = {};\n const buildConfig: BuildConfig = {};\n\n const fileName = typeof options.fileName == 'string' ? () => options.fileName as string : options.fileName;\n\n return {\n name: 'unplugin-dts-bundle-generator',\n buildEnd() {\n const entryPointConfigs: Array<EntryPointConfig> = Object.values(entry).map((entryPath) => ({\n filePath: entryPath,\n libraries: options.libraries,\n output: options.output,\n }));\n\n generateDtsBundle(entryPointConfigs, options.compilation).forEach((content, i) => bundles.push({\n compressedSize: zlib.gzipSync(content).length,\n content,\n outFile: fileName(Object.keys(entry)[i]),\n size: Buffer.byteLength(content),\n }));\n },\n writeBundle() {\n bundles.forEach((bundle) => fs.writeFileSync(\n path.resolve(buildConfig.outDir ?? '', bundle.outFile),\n bundle.content,\n ));\n },\n vite: {\n configResolved(config) {\n if (config.build.lib) {\n assignEntry(entry, config.build.lib.entry);\n }\n\n buildConfig.outDir = config.build.outDir;\n },\n closeBundle() {\n const length = bundles.length.toString();\n this.environment.logger.info(`\\n${colors.green('✓')} ${length} declaration bundles generated.`);\n\n const options = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n };\n\n bundles.forEach((bundle) => this.environment.logger.info(\n colors.dim(`${buildConfig.outDir}/`)\n + colors.cyan(`${bundle.outFile} `)\n + colors.dim(`${(bundle.size / 1000).toLocaleString('en', options)} kB │ `)\n + colors.dim(`gzip: ${(bundle.compressedSize / 1000).toLocaleString('en', options)} kB`),\n ));\n },\n },\n };\n};\n"],"names":["assignEntry","entry","input","i","path","unpluginFactory","options","bundles","buildConfig","fileName","entryPointConfigs","entryPath","generateDtsBundle","content","zlib","Buffer","bundle","fs","config","length","colors"],"mappings":";;;;;;AA8BA,MAAMA,IAAc,CAACC,GAA+BC,MAA6B;AAC/E,EAAI,OAAOA,KAAS,WAClB,OAAO,OAAOD,GAAO;AAAA,IACnB,SAASC;AAAA,EAAA,CACV,IAEM,MAAM,QAAQA,CAAK,IAC1BA,EAAM,QAAQ,CAACC,MAAM;AACnB,WAAO,OAAOF,GAAO;AAAA,MACnB,CAACG,EAAK,SAASD,GAAGC,EAAK,QAAQD,CAAC,CAAC,CAAC,GAAGA;AAAA,IAAA,CACtC;AAAA,EACH,CAAC,IAGD,OAAO,OAAOF,GAAOC,CAAK;AAE9B,GAEaG,IAAmD,CAACC,MAAY;AAC3E,QAAMC,IAAoC,CAAA,GACpCN,IAAgC,CAAA,GAChCO,IAA2B,CAAA,GAE3BC,IAAW,OAAOH,EAAQ,YAAY,WAAW,MAAMA,EAAQ,WAAqBA,EAAQ;AAElG,SAAO;AAAA,IACL,MAAM;AAAA,IACN,WAAW;AACT,YAAMI,IAA6C,OAAO,OAAOT,CAAK,EAAE,IAAI,CAACU,OAAe;AAAA,QAC1F,UAAUA;AAAA,QACV,WAAWL,EAAQ;AAAA,QACnB,QAAQA,EAAQ;AAAA,MAAA,EAChB;AAEF,MAAAM,EAAkBF,GAAmBJ,EAAQ,WAAW,EAAE,QAAQ,CAACO,GAASV,MAAMI,EAAQ,KAAK;AAAA,QAC7F,gBAAgBO,EAAK,SAASD,CAAO,EAAE;AAAA,QACvC,SAAAA;AAAA,QACA,SAASJ,EAAS,OAAO,KAAKR,CAAK,EAAEE,CAAC,CAAC;AAAA,QACvC,MAAMY,EAAO,WAAWF,CAAO;AAAA,MAAA,CAChC,CAAC;AAAA,IACJ;AAAA,IACA,cAAc;AACZ,MAAAN,EAAQ,QAAQ,CAACS,MAAWC,EAAG;AAAA,QAC7Bb,EAAK,QAAQI,EAAY,UAAU,IAAIQ,EAAO,OAAO;AAAA,QACrDA,EAAO;AAAA,MAAA,CACR;AAAA,IACH;AAAA,IACA,MAAM;AAAA,MACJ,eAAeE,GAAQ;AACrB,QAAIA,EAAO,MAAM,OACflB,EAAYC,GAAOiB,EAAO,MAAM,IAAI,KAAK,GAG3CV,EAAY,SAASU,EAAO,MAAM;AAAA,MACpC;AAAA,MACA,cAAc;AACZ,cAAMC,IAASZ,EAAQ,OAAO,SAAA;AAC9B,aAAK,YAAY,OAAO,KAAK;AAAA,EAAKa,EAAO,MAAM,GAAG,CAAC,IAAID,CAAM,iCAAiC;AAE9F,cAAMb,IAAU;AAAA,UACd,uBAAuB;AAAA,UACvB,uBAAuB;AAAA,QAAA;AAGzB,QAAAC,EAAQ,QAAQ,CAACS,MAAW,KAAK,YAAY,OAAO;AAAA,UAClDI,EAAO,IAAI,GAAGZ,EAAY,MAAM,GAAG,IACjCY,EAAO,KAAK,GAAGJ,EAAO,OAAO,IAAI,IACjCI,EAAO,IAAI,IAAIJ,EAAO,OAAO,KAAM,eAAe,MAAMV,CAAO,CAAC,SAAS,IACzEc,EAAO,IAAI,UAAUJ,EAAO,iBAAiB,KAAM,eAAe,MAAMV,CAAO,CAAC,KAAK;AAAA,QAAA,CACxF;AAAA,MACH;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";const u=require("node:buffer"),g=require("node:fs"),a=require("node:path"),f=require("node:zlib"),d=require("dts-bundle-generator"),o=require("picocolors"),m=(e,i)=>{typeof i=="string"?Object.assign(e,{default:i}):Array.isArray(i)?i.forEach(n=>{Object.assign(e,{[a.basename(n,a.extname(n))]:n})}):Object.assign(e,i)},b=e=>{const i=[],n={},l={},c=typeof e.fileName=="string"?()=>e.fileName:e.fileName;return{name:"unplugin-dts-bundle-generator",buildEnd(){const t=Object.values(n).map(r=>({filePath:r,libraries:e.libraries,output:e.output}));d.generateDtsBundle(t,e.compilation).forEach((r,s)=>i.push({compressedSize:f.gzipSync(r).length,content:r,outFile:c(Object.keys(n)[s]),size:u.Buffer.byteLength(r)}))},writeBundle(){i.forEach(t=>g.writeFileSync(a.resolve(l.outDir??"",t.outFile),t.content))},vite:{configResolved(t){t.build.lib&&m(n,t.build.lib.entry),l.outDir=t.build.outDir},closeBundle(){const t=i.length.toString();this.environment.logger.info(`
|
|
2
|
+
${o.green("✓")} ${t} declaration bundles generated.`);const r={maximumFractionDigits:2,minimumFractionDigits:2};i.forEach(s=>this.environment.logger.info(o.dim(`${l.outDir}/`)+o.cyan(`${s.outFile} `)+o.dim(`${(s.size/1e3).toLocaleString("en",r)} kB │ `)+o.dim(`gzip: ${(s.compressedSize/1e3).toLocaleString("en",r)} kB`)))}}}};exports.unpluginFactory=b;
|
|
3
|
+
//# sourceMappingURL=factory-SCNW8ysY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory-SCNW8ysY.cjs","sources":["../src/core/factory.ts"],"sourcesContent":["import type { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';\nimport type { InputOption } from 'rollup';\nimport type { UnpluginFactory } from 'unplugin';\n\nimport { Buffer } from 'node:buffer';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { generateDtsBundle } from 'dts-bundle-generator';\nimport colors from 'picocolors';\n\nexport interface Options {\n fileName: string | ((entryName: string) => string);\n output?: EntryPointConfig['output'];\n libraries?: EntryPointConfig['libraries'];\n compilation?: CompilationOptions;\n}\n\ninterface DeclarationBundle {\n compressedSize: number;\n content: string;\n outFile: string;\n size: number;\n}\n\ninterface BuildConfig {\n outDir?: string;\n}\n\nconst assignEntry = (entry: Record<string, string>, input: InputOption): void => {\n if (typeof input == 'string') {\n Object.assign(entry, {\n default: input,\n });\n }\n else if (Array.isArray(input)) {\n input.forEach((i) => {\n Object.assign(entry, {\n [path.basename(i, path.extname(i))]: i,\n });\n });\n }\n else {\n Object.assign(entry, input);\n }\n};\n\nexport const unpluginFactory: UnpluginFactory<Options, false> = (options) => {\n const bundles: Array<DeclarationBundle> = [];\n const entry: Record<string, string> = {};\n const buildConfig: BuildConfig = {};\n\n const fileName = typeof options.fileName == 'string' ? () => options.fileName as string : options.fileName;\n\n return {\n name: 'unplugin-dts-bundle-generator',\n buildEnd() {\n const entryPointConfigs: Array<EntryPointConfig> = Object.values(entry).map((entryPath) => ({\n filePath: entryPath,\n libraries: options.libraries,\n output: options.output,\n }));\n\n generateDtsBundle(entryPointConfigs, options.compilation).forEach((content, i) => bundles.push({\n compressedSize: zlib.gzipSync(content).length,\n content,\n outFile: fileName(Object.keys(entry)[i]),\n size: Buffer.byteLength(content),\n }));\n },\n writeBundle() {\n bundles.forEach((bundle) => fs.writeFileSync(\n path.resolve(buildConfig.outDir ?? '', bundle.outFile),\n bundle.content,\n ));\n },\n vite: {\n configResolved(config) {\n if (config.build.lib) {\n assignEntry(entry, config.build.lib.entry);\n }\n\n buildConfig.outDir = config.build.outDir;\n },\n closeBundle() {\n const length = bundles.length.toString();\n this.environment.logger.info(`\\n${colors.green('✓')} ${length} declaration bundles generated.`);\n\n const options = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n };\n\n bundles.forEach((bundle) => this.environment.logger.info(\n colors.dim(`${buildConfig.outDir}/`)\n + colors.cyan(`${bundle.outFile} `)\n + colors.dim(`${(bundle.size / 1000).toLocaleString('en', options)} kB │ `)\n + colors.dim(`gzip: ${(bundle.compressedSize / 1000).toLocaleString('en', options)} kB`),\n ));\n },\n },\n };\n};\n"],"names":["assignEntry","entry","input","i","path","unpluginFactory","options","bundles","buildConfig","fileName","entryPointConfigs","entryPath","generateDtsBundle","content","zlib","Buffer","bundle","fs","config","length","colors"],"mappings":"yKA8BMA,EAAc,CAACC,EAA+BC,IAA6B,CAC3E,OAAOA,GAAS,SAClB,OAAO,OAAOD,EAAO,CACnB,QAASC,CAAA,CACV,EAEM,MAAM,QAAQA,CAAK,EAC1BA,EAAM,QAASC,GAAM,CACnB,O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AClDI,EAAO,IAAI,GAAGZ,EAAY,MAAM,GAAG,EACjCY,EAAO,KAAK,GAAGJ,EAAO,OAAO,IAAI,EACjCI,EAAO,IAAI,IAAIJ,EAAO,KAAO,KAAM,eAAe,KAAMV,CAAO,CAAC,SAAS,EACzEc,EAAO,IAAI,UAAUJ,EAAO,eAAiB,KAAM,eAAe,KAAMV,CAAO,CAAC,KAAK,CAAA,CACxF,CACH,CAAA,CACF,CAEJ"}
|
package/dist/vite.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("unplugin"),e=require("./factory-
|
|
1
|
+
"use strict";const t=require("unplugin"),e=require("./factory-SCNW8ysY.cjs"),r=t.createVitePlugin(e.unpluginFactory);module.exports=r;
|
|
2
2
|
//# sourceMappingURL=vite.cjs.map
|
package/dist/vite.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-dts-bundle-generator",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "DTS bundle generator for Unplugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unplugin",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@nuxt/kit": "^3",
|
|
65
65
|
"@nuxt/schema": "^3",
|
|
66
66
|
"esbuild": "*",
|
|
67
|
-
"rollup": "
|
|
67
|
+
"rollup": ">=3",
|
|
68
68
|
"vite": ">=3",
|
|
69
69
|
"webpack": "^4 || ^5"
|
|
70
70
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory-D34KlQ_a.js","sources":["../src/core/factory.ts"],"sourcesContent":["import type { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';\nimport type { InputOption } from 'rollup';\nimport type { UnpluginFactory } from 'unplugin';\n\nimport { Buffer } from 'node:buffer';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { generateDtsBundle } from 'dts-bundle-generator';\nimport colors from 'picocolors';\n\nexport interface Options {\n fileName: string | ((entryName: string) => string);\n output?: EntryPointConfig['output'];\n libraries?: EntryPointConfig['libraries'];\n compilation?: CompilationOptions;\n}\n\ninterface DeclarationBundle {\n compressedSize: number;\n content: string;\n outFile: string;\n size: number;\n}\n\ninterface BuildConfig {\n outDir: string;\n}\n\nconst assignEntry = (entry: Record<string, string>, input: InputOption): void => {\n if (typeof input == 'string') {\n Object.assign(entry, {\n default: input,\n });\n }\n else if (Array.isArray(input)) {\n input.forEach((i) => {\n Object.assign(entry, {\n [path.basename(i, path.extname(i))]: i,\n });\n });\n }\n else {\n Object.assign(entry, input);\n }\n};\n\nexport const unpluginFactory: UnpluginFactory<Options, false> = (options) => {\n const bundles: Array<DeclarationBundle> = [];\n const entry: Record<string, string> = {};\n const buildConfig: BuildConfig = {} as BuildConfig;\n\n const fileName = typeof options.fileName == 'function'\n ? options.fileName\n : () => options.fileName as string;\n\n return {\n name: 'unplugin-dts-bundle-generator',\n buildEnd() {\n const entryPointConfigs: Array<EntryPointConfig> = Object.values(entry).map((entryPath) => ({\n filePath: entryPath,\n libraries: options.libraries,\n output: options.output,\n }));\n\n generateDtsBundle(entryPointConfigs, options.compilation).forEach((content, i) => bundles.push({\n compressedSize: zlib.gzipSync(content).length,\n content,\n outFile: fileName(Object.keys(entry)[i]),\n size: Buffer.byteLength(content),\n }));\n },\n writeBundle() {\n bundles.forEach((bundle) => fs.writeFileSync(path.resolve(buildConfig.outDir, bundle.outFile), bundle.content));\n },\n vite: {\n configResolved(config) {\n if (config.build.lib) {\n assignEntry(entry, config.build.lib.entry);\n }\n\n buildConfig.outDir = config.build.outDir;\n },\n closeBundle() {\n const length = bundles.length.toString();\n this.environment.logger.info(`\\n${colors.green('✓')} ${length} declaration bundles generated.`);\n\n const options = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n };\n\n bundles.forEach((bundle) => this.environment.logger.info(\n colors.dim(`${buildConfig.outDir}/`)\n + colors.cyan(`${bundle.outFile} `)\n + colors.dim(`${(bundle.size / 1000).toLocaleString('en', options)} kB │ `)\n + colors.dim(`gzip: ${(bundle.compressedSize / 1000).toLocaleString('en', options)} kB`),\n ));\n },\n },\n };\n};\n"],"names":["assignEntry","entry","input","i","path","unpluginFactory","options","bundles","buildConfig","fileName","entryPointConfigs","entryPath","generateDtsBundle","content","zlib","Buffer","bundle","fs","config","length","colors"],"mappings":";;;;;;AA8BA,MAAMA,IAAc,CAACC,GAA+BC,MAA6B;AAC/E,EAAI,OAAOA,KAAS,WAClB,OAAO,OAAOD,GAAO;AAAA,IACnB,SAASC;AAAA,EAAA,CACV,IAEM,MAAM,QAAQA,CAAK,IAC1BA,EAAM,QAAQ,CAACC,MAAM;AACnB,WAAO,OAAOF,GAAO;AAAA,MACnB,CAACG,EAAK,SAASD,GAAGC,EAAK,QAAQD,CAAC,CAAC,CAAC,GAAGA;AAAA,IAAA,CACtC;AAAA,EAAA,CACF,IAGD,OAAO,OAAOF,GAAOC,CAAK;AAE9B,GAEaG,IAAmD,CAACC,MAAY;AAC3E,QAAMC,IAAoC,CAAA,GACpCN,IAAgC,CAAA,GAChCO,IAA2B,CAAA,GAE3BC,IAAW,OAAOH,EAAQ,YAAY,aACxCA,EAAQ,WACR,MAAMA,EAAQ;AAElB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,WAAW;AACT,YAAMI,IAA6C,OAAO,OAAOT,CAAK,EAAE,IAAI,CAACU,OAAe;AAAA,QAC1F,UAAUA;AAAA,QACV,WAAWL,EAAQ;AAAA,QACnB,QAAQA,EAAQ;AAAA,MAAA,EAChB;AAEF,MAAAM,EAAkBF,GAAmBJ,EAAQ,WAAW,EAAE,QAAQ,CAACO,GAASV,MAAMI,EAAQ,KAAK;AAAA,QAC7F,gBAAgBO,EAAK,SAASD,CAAO,EAAE;AAAA,QACvC,SAAAA;AAAA,QACA,SAASJ,EAAS,OAAO,KAAKR,CAAK,EAAEE,CAAC,CAAC;AAAA,QACvC,MAAMY,EAAO,WAAWF,CAAO;AAAA,MAAA,CAChC,CAAC;AAAA,IAAA;AAAA,IAEJ,cAAc;AACZ,MAAAN,EAAQ,QAAQ,CAACS,MAAWC,EAAG,cAAcb,EAAK,QAAQI,EAAY,QAAQQ,EAAO,OAAO,GAAGA,EAAO,OAAO,CAAC;AAAA,IAAA;AAAA,IAEhH,MAAM;AAAA,MACJ,eAAeE,GAAQ;AACrB,QAAIA,EAAO,MAAM,OACflB,EAAYC,GAAOiB,EAAO,MAAM,IAAI,KAAK,GAG3CV,EAAY,SAASU,EAAO,MAAM;AAAA,MAAA;AAAA,MAEpC,cAAc;AACZ,cAAMC,IAASZ,EAAQ,OAAO,SAAA;AAC9B,aAAK,YAAY,OAAO,KAAK;AAAA,EAAKa,EAAO,MAAM,GAAG,CAAC,IAAID,CAAM,iCAAiC;AAE9F,cAAMb,IAAU;AAAA,UACd,uBAAuB;AAAA,UACvB,uBAAuB;AAAA,QAAA;AAGzB,QAAAC,EAAQ,QAAQ,CAACS,MAAW,KAAK,YAAY,OAAO;AAAA,UAClDI,EAAO,IAAI,GAAGZ,EAAY,MAAM,GAAG,IACjCY,EAAO,KAAK,GAAGJ,EAAO,OAAO,IAAI,IACjCI,EAAO,IAAI,IAAIJ,EAAO,OAAO,KAAM,eAAe,MAAMV,CAAO,CAAC,SAAS,IACzEc,EAAO,IAAI,UAAUJ,EAAO,iBAAiB,KAAM,eAAe,MAAMV,CAAO,CAAC,KAAK;AAAA,QAAA,CACxF;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("node:buffer"),g=require("node:fs"),a=require("node:path"),f=require("node:zlib"),d=require("dts-bundle-generator"),s=require("picocolors"),m=(e,i)=>{typeof i=="string"?Object.assign(e,{default:i}):Array.isArray(i)?i.forEach(r=>{Object.assign(e,{[a.basename(r,a.extname(r))]:r})}):Object.assign(e,i)},b=e=>{const i=[],r={},l={},c=typeof e.fileName=="function"?e.fileName:()=>e.fileName;return{name:"unplugin-dts-bundle-generator",buildEnd(){const t=Object.values(r).map(n=>({filePath:n,libraries:e.libraries,output:e.output}));d.generateDtsBundle(t,e.compilation).forEach((n,o)=>i.push({compressedSize:f.gzipSync(n).length,content:n,outFile:c(Object.keys(r)[o]),size:u.Buffer.byteLength(n)}))},writeBundle(){i.forEach(t=>g.writeFileSync(a.resolve(l.outDir,t.outFile),t.content))},vite:{configResolved(t){t.build.lib&&m(r,t.build.lib.entry),l.outDir=t.build.outDir},closeBundle(){const t=i.length.toString();this.environment.logger.info(`
|
|
2
|
-
${s.green("✓")} ${t} declaration bundles generated.`);const n={maximumFractionDigits:2,minimumFractionDigits:2};i.forEach(o=>this.environment.logger.info(s.dim(`${l.outDir}/`)+s.cyan(`${o.outFile} `)+s.dim(`${(o.size/1e3).toLocaleString("en",n)} kB │ `)+s.dim(`gzip: ${(o.compressedSize/1e3).toLocaleString("en",n)} kB`)))}}}};exports.unpluginFactory=b;
|
|
3
|
-
//# sourceMappingURL=factory-v7XFnpMY.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"factory-v7XFnpMY.cjs","sources":["../src/core/factory.ts"],"sourcesContent":["import type { CompilationOptions, EntryPointConfig } from 'dts-bundle-generator';\nimport type { InputOption } from 'rollup';\nimport type { UnpluginFactory } from 'unplugin';\n\nimport { Buffer } from 'node:buffer';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport zlib from 'node:zlib';\n\nimport { generateDtsBundle } from 'dts-bundle-generator';\nimport colors from 'picocolors';\n\nexport interface Options {\n fileName: string | ((entryName: string) => string);\n output?: EntryPointConfig['output'];\n libraries?: EntryPointConfig['libraries'];\n compilation?: CompilationOptions;\n}\n\ninterface DeclarationBundle {\n compressedSize: number;\n content: string;\n outFile: string;\n size: number;\n}\n\ninterface BuildConfig {\n outDir: string;\n}\n\nconst assignEntry = (entry: Record<string, string>, input: InputOption): void => {\n if (typeof input == 'string') {\n Object.assign(entry, {\n default: input,\n });\n }\n else if (Array.isArray(input)) {\n input.forEach((i) => {\n Object.assign(entry, {\n [path.basename(i, path.extname(i))]: i,\n });\n });\n }\n else {\n Object.assign(entry, input);\n }\n};\n\nexport const unpluginFactory: UnpluginFactory<Options, false> = (options) => {\n const bundles: Array<DeclarationBundle> = [];\n const entry: Record<string, string> = {};\n const buildConfig: BuildConfig = {} as BuildConfig;\n\n const fileName = typeof options.fileName == 'function'\n ? options.fileName\n : () => options.fileName as string;\n\n return {\n name: 'unplugin-dts-bundle-generator',\n buildEnd() {\n const entryPointConfigs: Array<EntryPointConfig> = Object.values(entry).map((entryPath) => ({\n filePath: entryPath,\n libraries: options.libraries,\n output: options.output,\n }));\n\n generateDtsBundle(entryPointConfigs, options.compilation).forEach((content, i) => bundles.push({\n compressedSize: zlib.gzipSync(content).length,\n content,\n outFile: fileName(Object.keys(entry)[i]),\n size: Buffer.byteLength(content),\n }));\n },\n writeBundle() {\n bundles.forEach((bundle) => fs.writeFileSync(path.resolve(buildConfig.outDir, bundle.outFile), bundle.content));\n },\n vite: {\n configResolved(config) {\n if (config.build.lib) {\n assignEntry(entry, config.build.lib.entry);\n }\n\n buildConfig.outDir = config.build.outDir;\n },\n closeBundle() {\n const length = bundles.length.toString();\n this.environment.logger.info(`\\n${colors.green('✓')} ${length} declaration bundles generated.`);\n\n const options = {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n };\n\n bundles.forEach((bundle) => this.environment.logger.info(\n colors.dim(`${buildConfig.outDir}/`)\n + colors.cyan(`${bundle.outFile} `)\n + colors.dim(`${(bundle.size / 1000).toLocaleString('en', options)} kB │ `)\n + colors.dim(`gzip: ${(bundle.compressedSize / 1000).toLocaleString('en', options)} kB`),\n ));\n },\n },\n };\n};\n"],"names":["assignEntry","entry","input","i","path","unpluginFactory","options","bundles","buildConfig","fileName","entryPointConfigs","entryPath","generateDtsBundle","content","zlib","Buffer","bundle","fs","config","length","colors"],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