jiek 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/rollup.cjs CHANGED
@@ -1,2 +1,311 @@
1
- "use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),s=require("@rollup/plugin-json"),r=require("autoprefixer"),n=require("rollup-plugin-dts"),a=require("rollup-plugin-esbuild"),i=require("rollup-plugin-postcss"),u=require("cli-progress"),o=require("@rollup/plugin-terser");function p(e){return e&&e.__esModule?e:{default:e}}var d=p(s),c=p(r),l=p(a),m=p(i),g=p(o);function y(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var f=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={exports:"named",interop:"auto",sourcemap:!0};function $(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],g.default()]}]}const b=t.getWorkspaceDir();function v(e,t,s,r){return{name:"progress",resolveId(s,r){(e.includes(s)||void 0===r)&&t(s)},transform(e,t){s(t)},writeBundle(e,t){Object.entries(t).forEach((([e,t])=>{void 0!==t.name&&"isEntry"in t&&r(t.name,t.fileName)}))}}}exports.template=({styled:t=!1,plugins:{index:s=[],entry:r=[],dts:a=[]}={}}={},i)=>{const{jiek:{noBrowser:o=!1,outdir:p="dist"}={}}=i,g={...j,dir:p};if(!i.name)throw new Error("pkg.name is required");const x=i.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),O=Object.fromEntries(Object.entries(i.exports??{}).filter((([e])=>!e.startsWith(`./${p}`)&&!e.startsWith(p))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,t])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof t?t:t["inner-src"]]))),[h,w]=function(){let e={};const t=new Set([]);return[({external:s}={})=>({name:"globals",resolveId:e=>s?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:s=>(e=[...t].reduce(((e,t)=>({...e,[t]:y(t)})),{}),{...s,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),q=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:s={},peerDependencies:r={},optionalDependencies:n={}}=t;return Object.keys(s).concat(Object.keys(r)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),k={},N=[d.default()],W=new u.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},u.Presets.shades_classic),F=Object.values(O),E={esm:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"esm",entry:t,message:"waiting"}),{...e,[t]:s}}),{}),umd:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"umd",entry:t,message:"waiting"}),{...e,[t]:s}}),{}),dts:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"dts",entry:t,message:"waiting"}),{...e,[t]:s}}),{})},B=F.reduce(((e,t)=>({...e,[t]:!1})),{});return[{...k,input:O,output:[...$({...g,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[v(Object.values(O),(e=>{const t=E.esm[e];t&&t.update(0,{type:"esm",entry:e,message:"processing"})}),(e=>{const t=E.esm[e];t&&t.update(50,{type:"esm",entry:e,message:`transforming ${e}`})}),((e,t)=>{const s=O[e],r=E.esm[s];r&&(t.endsWith(".min.js")?r.update(100,{type:"esm",entry:s,message:"finished"}):r.update(95,{type:"esm",entry:s,message:"processed"}))})),N,h({external:q}),t&&f({patterns:[/\.s?css$/]}),l.default(),s]},...Object.entries(O).map((([e,s])=>{const n=x+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{...k,input:s,output:o?[...$({...g,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...$({...g,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...$({...g,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[v([s],(e=>{const t=E.umd[e];t&&t.update(0,{type:"umd",entry:e,message:"processing"})}),(e=>{const t=E.umd[s];t&&t.update(50,{type:"umd",input:s,message:`transforming ${e}`})}),((e,t)=>{const r=E.umd[s];r&&(t.endsWith(".min.js")?r.update(100,{type:"umd",input:s,message:"finished"}):r.update(95,{type:"umd",input:s,message:"processed"}))})),N,w,t&&m.default({plugins:[c.default],minimize:!0,sourceMap:!0,extract:`${e}.css`}),l.default(),r],external:q}})),{...k,input:O,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[v(Object.values(O),(e=>{const t=E.dts[e];t&&t.update(0,{type:"dts",entry:e,message:"processing"})}),(e=>{const t=E.dts[e];t&&t.update(50,{type:"dts",entry:e,message:`transforming ${e}`})}),((e,t)=>{const s=O[e],r=E.dts[s];r&&(t.endsWith(".esm.d.ts")?(r.update(100,{type:"dts",entry:s,message:"finished"}),B[s]=!0):r.update(95,{type:"dts",entry:s,message:"processed"}),Object.values(B).every(Boolean)&&setTimeout((()=>{W.stop()}),100))})),N,t&&f({patterns:[/\.s?css$/]}),n.dts({tsconfig:(C="tsconfig.dts.json",e.resolve(b,C))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,t){for(const e of Object.values(t))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${i.name}'`))}},a],external:q}];var C};
1
+ 'use strict';
2
+
3
+ var node_path = require('node:path');
4
+ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
5
+ var json = require('@rollup/plugin-json');
6
+ var autoprefixer = require('autoprefixer');
7
+ var cliProgress = require('cli-progress');
8
+ var rollupPluginDts = require('rollup-plugin-dts');
9
+ var esbuild = require('rollup-plugin-esbuild');
10
+ var postcss = require('rollup-plugin-postcss');
11
+ var terser = require('@rollup/plugin-terser');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var json__default = /*#__PURE__*/_interopDefault(json);
16
+ var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
17
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
18
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
19
+ var terser__default = /*#__PURE__*/_interopDefault(terser);
20
+
21
+ function globalResolver(external) {
22
+ if (external.startsWith("node:")) {
23
+ return external.slice(5);
24
+ }
25
+ return external.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
26
+ }
27
+
28
+ function createGlobalsLinkage() {
29
+ let globals = {};
30
+ const dependencies = /* @__PURE__ */ new Set([]);
31
+ return [
32
+ ({ external } = {}) => {
33
+ return {
34
+ name: "globals",
35
+ resolveId(id) {
36
+ if (external?.some((dep) => dep instanceof RegExp ? dep.test(id) : dep === id)) {
37
+ dependencies.add(id);
38
+ return { id, external: true };
39
+ }
40
+ return null;
41
+ },
42
+ outputOptions(options) {
43
+ globals = [...dependencies].reduce((acc, value) => ({
44
+ ...acc,
45
+ [value]: globalResolver(value)
46
+ }), {});
47
+ return { ...options, globals };
48
+ }
49
+ };
50
+ },
51
+ { outputOptions: (options) => ({ ...options, globals }) }
52
+ ];
53
+ }
54
+
55
+ var skip = (options = {}) => {
56
+ return {
57
+ name: "skip",
58
+ // skip the specified files by `options.patterns`
59
+ load(id) {
60
+ if (options.patterns?.some(
61
+ (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
62
+ )) {
63
+ return "";
64
+ }
65
+ }
66
+ };
67
+ };
68
+
69
+ const defineOutput = (output) => output;
70
+ const commonOutputOptions = defineOutput({
71
+ exports: "named",
72
+ interop: "auto",
73
+ sourcemap: true
74
+ });
75
+
76
+ function externalResolver() {
77
+ const cwd = process.cwd();
78
+ const pkg = require(`${cwd}/package.json`);
79
+ const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
80
+ const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
81
+ return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
82
+ /^node:/
83
+ ]);
84
+ }
85
+
86
+ function withMinify(output) {
87
+ return [
88
+ output,
89
+ {
90
+ ...output,
91
+ entryFileNames: output.entryFileNames?.replace(/(\.c?js)$/, ".min$1"),
92
+ plugins: [...output.plugins ?? [], terser__default.default()]
93
+ }
94
+ ];
95
+ }
96
+
97
+ const workspaceRoot = getWorkspaceDir.getWorkspaceDir();
98
+ function resolveWorkspacePath(p) {
99
+ return node_path.resolve(workspaceRoot, p);
100
+ }
101
+ function watchProgress(entries, onProcessing, onProcessed) {
102
+ return {
103
+ name: "progress",
104
+ resolveId(source, importer) {
105
+ if (entries.includes(source) || importer === void 0)
106
+ onProcessing(source);
107
+ },
108
+ writeBundle(options, bundle) {
109
+ Object.entries(bundle).forEach(([key, value]) => {
110
+ if (value.name === void 0 || !("isEntry" in value))
111
+ return;
112
+ onProcessed(value.name, value.fileName);
113
+ });
114
+ }
115
+ };
116
+ }
117
+ const template = ({
118
+ styled = false,
119
+ plugins: {
120
+ index: indexPlugins = [],
121
+ entry: entryPlugins = [],
122
+ dts: dtsPlugins = []
123
+ } = {}
124
+ } = {}, pkg) => {
125
+ const { jiek: {
126
+ noBrowser = false,
127
+ outdir = "dist"
128
+ } = {} } = pkg;
129
+ const outputOptions = {
130
+ ...commonOutputOptions,
131
+ dir: outdir
132
+ };
133
+ if (!pkg.name) {
134
+ throw new Error("pkg.name is required");
135
+ }
136
+ const namePrefix = pkg.name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
137
+ const exportsEntries = Object.fromEntries(
138
+ Object.entries(pkg.exports ?? {}).filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir)).filter(([key]) => !/\.(json|css|scss)$/.test(key)).filter(([, value]) => typeof value === "object" && value["inner-src"] && value["import"]).map(([key, value]) => [
139
+ key.replace(/^\.$/, "index").replace(/^\.\//, ""),
140
+ typeof value === "string" ? value : value["inner-src"]
141
+ ])
142
+ );
143
+ const maxLengthEntry = Math.max(...Object.values(exportsEntries).map((v) => v.length));
144
+ function paddingEntry(entry) {
145
+ return entry.padEnd(maxLengthEntry);
146
+ }
147
+ const [globalsRegister, globalsOutput] = createGlobalsLinkage();
148
+ const external = externalResolver();
149
+ const commonOptions = {};
150
+ const commonPlugins = [
151
+ json__default.default()
152
+ ];
153
+ const multiBars = new cliProgress.MultiBar({
154
+ clearOnComplete: false,
155
+ hideCursor: true,
156
+ format: "- {bar} | {type} | {entry} | {message}"
157
+ }, cliProgress.Presets.shades_classic);
158
+ const entries = Object.values(exportsEntries);
159
+ const addBarsByEntries = (type) => entries.reduce((add, entry) => {
160
+ const bar = multiBars.create(100, 0);
161
+ bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
162
+ return { ...add, [entry]: bar };
163
+ }, {});
164
+ const progressState = {
165
+ esm: addBarsByEntries("esm"),
166
+ umd: addBarsByEntries("umd"),
167
+ dts: addBarsByEntries("dts")
168
+ };
169
+ const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
170
+ const watchingProgress = (type, defaultEntry) => {
171
+ const group = progressState[type];
172
+ return watchProgress(
173
+ Object.values(exportsEntries),
174
+ (entry) => {
175
+ const e = defaultEntry ?? entry;
176
+ const bar = group[e];
177
+ if (!bar)
178
+ return;
179
+ bar.update(0, { type, entry: paddingEntry(e), message: "processing" });
180
+ },
181
+ (name, fileName) => {
182
+ const e = defaultEntry ?? exportsEntries[name];
183
+ const bar = group[e];
184
+ if (!bar)
185
+ return;
186
+ const endsReg = {
187
+ esm: /\.min\.js$/,
188
+ umd: /\.min\.c?js$/,
189
+ dts: /\.esm\.d\.ts$/
190
+ }[type];
191
+ if (!endsReg.test(fileName)) {
192
+ bar.update(95, { type, entry: paddingEntry(e), message: "processed" });
193
+ } else {
194
+ bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
195
+ }
196
+ if (type === "dts") {
197
+ resolved[e] = true;
198
+ if (Object.values(resolved).every(Boolean)) {
199
+ setTimeout(() => multiBars.stop(), 200);
200
+ }
201
+ }
202
+ }
203
+ );
204
+ };
205
+ return [
206
+ {
207
+ ...commonOptions,
208
+ input: exportsEntries,
209
+ output: [
210
+ ...withMinify({
211
+ ...outputOptions,
212
+ format: "esm",
213
+ entryFileNames: "[name].esm.js",
214
+ preserveModules: true
215
+ })
216
+ ],
217
+ plugins: [
218
+ watchingProgress("esm"),
219
+ commonPlugins,
220
+ globalsRegister({ external }),
221
+ styled && skip({ patterns: [/\.s?css$/] }),
222
+ esbuild__default.default(),
223
+ indexPlugins
224
+ ]
225
+ },
226
+ ...Object.entries(exportsEntries).map(([name, input]) => {
227
+ const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
228
+ return {
229
+ ...commonOptions,
230
+ input,
231
+ output: noBrowser ? [
232
+ ...withMinify({
233
+ ...outputOptions,
234
+ name: outputName,
235
+ format: "cjs",
236
+ entryFileNames: `${name}.cjs`
237
+ })
238
+ ] : [
239
+ ...withMinify({
240
+ ...outputOptions,
241
+ name: outputName,
242
+ format: "iife",
243
+ entryFileNames: `${name}.iife.js`
244
+ }),
245
+ ...withMinify({
246
+ ...outputOptions,
247
+ name: outputName,
248
+ format: "umd",
249
+ entryFileNames: `${name}.umd.js`
250
+ })
251
+ ],
252
+ plugins: [
253
+ watchingProgress("umd", input),
254
+ commonPlugins,
255
+ globalsOutput,
256
+ styled && postcss__default.default({
257
+ plugins: [autoprefixer__default.default],
258
+ minimize: true,
259
+ sourceMap: true,
260
+ extract: `${name}.css`
261
+ }),
262
+ esbuild__default.default(),
263
+ entryPlugins
264
+ ],
265
+ external
266
+ };
267
+ }),
268
+ {
269
+ ...commonOptions,
270
+ input: exportsEntries,
271
+ output: [
272
+ {
273
+ dir: "dist"
274
+ },
275
+ {
276
+ dir: "dist",
277
+ entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
278
+ preserveModules: true
279
+ }
280
+ ],
281
+ plugins: [
282
+ watchingProgress("dts"),
283
+ commonPlugins,
284
+ styled && skip({ patterns: [/\.s?css$/] }),
285
+ rollupPluginDts.dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
286
+ {
287
+ name: "rollup-plugin-declare-module-replacer",
288
+ /**
289
+ * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
290
+ * in output file generated
291
+ */
292
+ generateBundle(_, bundle) {
293
+ for (const file of Object.values(bundle)) {
294
+ if (!("code" in file))
295
+ continue;
296
+ file.code = file.code.replace(
297
+ /declare module ['|"]\..*['|"]/g,
298
+ `declare module '${pkg.name}'`
299
+ );
300
+ }
301
+ }
302
+ },
303
+ dtsPlugins
304
+ ],
305
+ external
306
+ }
307
+ ];
308
+ };
309
+
310
+ exports.template = template;
2
311
  //# sourceMappingURL=rollup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\nimport { MultiBar, Presets } from 'cli-progress'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction progress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onTransforming: (id: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n transform(_, id) {\n onTransforming(id)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const progressState = {\n esm: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'esm', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>),\n umd: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'umd', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>),\n dts: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'dts', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n }\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n return [\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n progress(\n Object.values(exportsEntries),\n entry => {\n const bar = progressState.esm[entry]\n if (!bar) return\n bar.update(0, { type: 'esm', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.esm[id]\n if (!bar) return\n bar.update(50, { type: 'esm', entry: id, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const entry = exportsEntries[name]\n const bar = progressState.esm[entry]\n if (!bar) return\n if (!fileName.endsWith('.min.js')) {\n bar.update(95, { type: 'esm', entry, message: `processed` })\n } else {\n bar.update(100, { type: 'esm', entry, message: `finished` })\n }\n }\n ),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n progress(\n [input],\n entry => {\n const bar = progressState.umd[entry]\n if (!bar) return\n bar.update(0, { type: 'umd', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.umd[input]\n if (!bar) return\n bar.update(50, { type: 'umd', input, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const bar = progressState.umd[input]\n if (!bar) return\n if (!fileName.endsWith('.min.js')) {\n bar.update(95, { type: 'umd', input, message: `processed` })\n } else {\n bar.update(100, { type: 'umd', input, message: `finished` })\n }\n }\n ),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n progress(\n Object.values(exportsEntries),\n entry => {\n const bar = progressState.dts[entry]\n if (!bar) return\n bar.update(0, { type: 'dts', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.dts[id]\n if (!bar) return\n bar.update(50, { type: 'dts', entry: id, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const entry = exportsEntries[name]\n const bar = progressState.dts[entry]\n if (!bar) return\n if (!fileName.endsWith('.esm.d.ts')) {\n bar.update(95, { type: 'dts', entry, message: `processed` })\n } else {\n bar.update(100, { type: 'dts', entry, message: `finished` })\n resolved[entry] = true\n }\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => {\n multiBars.stop()\n }, 100)\n }\n }\n ),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n"],"names":["globalResolver","external","startsWith","slice","replace","_","$1","toUpperCase","skip","options","name","load","id","patterns","some","pattern","includes","test","commonOutputOptions","exports","interop","sourcemap","withMinify","output","entryFileNames","plugins","terser","workspaceRoot","getWorkspaceDir","progress","entries","onProcessing","onTransforming","onProcessed","resolveId","source","importer","transform","writeBundle","bundle","Object","forEach","key","value","fileName","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","outdir","outputOptions","dir","Error","namePrefix","exportsEntries","fromEntries","filter","map","globalsRegister","globalsOutput","globals","dependencies","Set","dep","RegExp","add","reduce","acc","createGlobalsLinkage","cwd","process","require","peerDependencies","optionalDependencies","keys","concat","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","values","progressState","esm","bar","create","update","type","message","umd","resolved","input","preserveModules","endsWith","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","every","Boolean","setTimeout","stop","tsconfig","p","resolve","generateBundle","file","code"],"mappings":"wYAAA,SAAAA,EAAyBC,GAOnB,OAAAA,EAASC,WAAW,SACfD,EAASE,MAAM,GAEjBF,EACJG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,eAC1C,CCNA,IAAAC,EAAgB,CAACC,EAAU,CAAA,KAClB,CACLC,KAAM,OAEN,IAAAC,CAAKC,GACH,GACEH,EAAQI,UAAUC,MAAMC,GACH,iBAAZA,EACHH,EAAGI,SAASD,GACZA,EAAQE,KAAKL,KAGZ,MAAA,EAEX,IClBJ,MAEaM,EAAmC,CAC9CC,QAAS,QACTC,QAAS,OACTC,WAAW,GCJb,SAAAC,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBpB,QAAQ,UAAW,UAC1DqB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCGA,MAAMC,EAAgBC,EAAgBA,kBAKtC,SAASC,EACPC,EACAC,EACAC,EACAC,GAEO,MAAA,CACLvB,KAAM,WACN,SAAAwB,CAAUC,EAAQC,IACZN,EAAQd,SAASmB,SAAwB,IAAbC,IAC9BL,EAAaI,EACjB,EACA,SAAAE,CAAUhC,EAAGO,GACXoB,EAAepB,EACjB,EACA,WAAA0B,CAAY7B,EAAS8B,GACZC,OAAAV,QAAQS,GAAQE,SAAQ,EAAEC,EAAKC,WACjB,IAAfA,EAAMjC,MAAwB,YAAaiC,GACnCV,EAAAU,EAAMjC,KAAMiC,EAAMC,SAAQ,GAE1C,EAEJ,kBAEwB,EAEpBC,UAAS,EACTpB,SACEqB,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KASA,MAAQC,MAAMC,UACZA,GAAY,EAAAC,OACZA,EAAS,QACP,CAAA,GAAOH,EACLI,EAAgB,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cAC5BqC,EAAAA,IAAI,CAAEmE,UAjRgBC,EAiRe,oBAhRpCC,EAAAA,QAAQ5F,EAAe2F,MAiRxB,CACE5G,KAAM,wCAKN,cAAA8G,CAAenH,EAAGkC,GAChB,IAAA,MAAWkF,KAAQjF,OAAOqD,OAAOtD,GACzB,SAAUkF,IAEXA,EAAAC,KAAOD,EAAKC,KAAKtH,QACpB,iCACA,mBAAmBgD,EAAI1C,SAG7B,GAEFyC,GAEFlD,aArSN,IAA8BqH,CAuS5B"}
1
+ {"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.c?js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction watchProgress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n const maxLengthEntry = Math.max(...Object.values(exportsEntries).map(v => v.length))\n function paddingEntry(entry: string) {\n return entry.padEnd(maxLengthEntry)\n }\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const addBarsByEntries = (type: 'esm' | 'umd' | 'dts') => entries\n .reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type, entry: paddingEntry(entry), message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n const progressState = {\n esm: addBarsByEntries('esm'),\n umd: addBarsByEntries('umd'),\n dts: addBarsByEntries('dts')\n }\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n return watchProgress(\n Object.values(exportsEntries),\n entry => {\n const e = defaultEntry ?? entry\n const bar = group[e]\n if (!bar) return\n bar.update(0, { type, entry: paddingEntry(e), message: 'processing' })\n },\n (name, fileName) => {\n const e = defaultEntry ?? exportsEntries[name]\n const bar = group[e]\n if (!bar) return\n const endsReg = {\n esm: /\\.min\\.js$/,\n umd: /\\.min\\.c?js$/,\n dts: /\\.esm\\.d\\.ts$/\n }[type]\n if (!endsReg.test(fileName)) {\n bar.update(95, { type, entry: paddingEntry(e), message: 'processed' })\n } else {\n bar.update(100, { type, entry: paddingEntry(e), message: 'finished' })\n }\n if (type === 'dts') {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n return [\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n watchingProgress('esm'),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n watchingProgress('umd', input),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n watchingProgress('dts'),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["terser","getWorkspaceDir","resolve","json","MultiBar","Presets","entries","esbuild","postcss","autoprefixer","dts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,OAAO,CAAG,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,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,eAC7B,CAAA;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
@@ -2,10 +2,10 @@ import { resolve } from 'node:path';
2
2
  import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
3
3
  import json from '@rollup/plugin-json';
4
4
  import autoprefixer from 'autoprefixer';
5
+ import { MultiBar, Presets } from 'cli-progress';
5
6
  import { dts } from 'rollup-plugin-dts';
6
7
  import esbuild from 'rollup-plugin-esbuild';
7
8
  import postcss from 'rollup-plugin-postcss';
8
- import { MultiBar, Presets } from 'cli-progress';
9
9
  import { createGlobalsLinkage } from './rollup/plugins/globals.esm.js';
10
10
  import skip from './rollup/plugins/skip.esm.js';
11
11
  import { commonOutputOptions } from './rollup/utils/commonOptions.esm.js';
@@ -16,16 +16,13 @@ const workspaceRoot = getWorkspaceDir();
16
16
  function resolveWorkspacePath(p) {
17
17
  return resolve(workspaceRoot, p);
18
18
  }
19
- function progress(entries, onProcessing, onTransforming, onProcessed) {
19
+ function watchProgress(entries, onProcessing, onProcessed) {
20
20
  return {
21
21
  name: "progress",
22
22
  resolveId(source, importer) {
23
23
  if (entries.includes(source) || importer === void 0)
24
24
  onProcessing(source);
25
25
  },
26
- transform(_, id) {
27
- onTransforming(id);
28
- },
29
26
  writeBundle(options, bundle) {
30
27
  Object.entries(bundle).forEach(([key, value]) => {
31
28
  if (value.name === void 0 || !("isEntry" in value))
@@ -61,6 +58,10 @@ const template = ({
61
58
  typeof value === "string" ? value : value["inner-src"]
62
59
  ])
63
60
  );
61
+ const maxLengthEntry = Math.max(...Object.values(exportsEntries).map((v) => v.length));
62
+ function paddingEntry(entry) {
63
+ return entry.padEnd(maxLengthEntry);
64
+ }
64
65
  const [globalsRegister, globalsOutput] = createGlobalsLinkage();
65
66
  const external = externalResolver();
66
67
  const commonOptions = {};
@@ -73,24 +74,52 @@ const template = ({
73
74
  format: "- {bar} | {type} | {entry} | {message}"
74
75
  }, Presets.shades_classic);
75
76
  const entries = Object.values(exportsEntries);
77
+ const addBarsByEntries = (type) => entries.reduce((add, entry) => {
78
+ const bar = multiBars.create(100, 0);
79
+ bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
80
+ return { ...add, [entry]: bar };
81
+ }, {});
76
82
  const progressState = {
77
- esm: entries.reduce((add, entry) => {
78
- const bar = multiBars.create(100, 0);
79
- bar.update(0, { type: "esm", entry, message: "waiting" });
80
- return { ...add, [entry]: bar };
81
- }, {}),
82
- umd: entries.reduce((add, entry) => {
83
- const bar = multiBars.create(100, 0);
84
- bar.update(0, { type: "umd", entry, message: "waiting" });
85
- return { ...add, [entry]: bar };
86
- }, {}),
87
- dts: entries.reduce((add, entry) => {
88
- const bar = multiBars.create(100, 0);
89
- bar.update(0, { type: "dts", entry, message: "waiting" });
90
- return { ...add, [entry]: bar };
91
- }, {})
83
+ esm: addBarsByEntries("esm"),
84
+ umd: addBarsByEntries("umd"),
85
+ dts: addBarsByEntries("dts")
92
86
  };
93
87
  const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
88
+ const watchingProgress = (type, defaultEntry) => {
89
+ const group = progressState[type];
90
+ return watchProgress(
91
+ Object.values(exportsEntries),
92
+ (entry) => {
93
+ const e = defaultEntry ?? entry;
94
+ const bar = group[e];
95
+ if (!bar)
96
+ return;
97
+ bar.update(0, { type, entry: paddingEntry(e), message: "processing" });
98
+ },
99
+ (name, fileName) => {
100
+ const e = defaultEntry ?? exportsEntries[name];
101
+ const bar = group[e];
102
+ if (!bar)
103
+ return;
104
+ const endsReg = {
105
+ esm: /\.min\.js$/,
106
+ umd: /\.min\.c?js$/,
107
+ dts: /\.esm\.d\.ts$/
108
+ }[type];
109
+ if (!endsReg.test(fileName)) {
110
+ bar.update(95, { type, entry: paddingEntry(e), message: "processed" });
111
+ } else {
112
+ bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
113
+ }
114
+ if (type === "dts") {
115
+ resolved[e] = true;
116
+ if (Object.values(resolved).every(Boolean)) {
117
+ setTimeout(() => multiBars.stop(), 200);
118
+ }
119
+ }
120
+ }
121
+ );
122
+ };
94
123
  return [
95
124
  {
96
125
  ...commonOptions,
@@ -104,32 +133,7 @@ const template = ({
104
133
  })
105
134
  ],
106
135
  plugins: [
107
- progress(
108
- Object.values(exportsEntries),
109
- (entry) => {
110
- const bar = progressState.esm[entry];
111
- if (!bar)
112
- return;
113
- bar.update(0, { type: "esm", entry, message: "processing" });
114
- },
115
- (id) => {
116
- const bar = progressState.esm[id];
117
- if (!bar)
118
- return;
119
- bar.update(50, { type: "esm", entry: id, message: `transforming ${id}` });
120
- },
121
- (name, fileName) => {
122
- const entry = exportsEntries[name];
123
- const bar = progressState.esm[entry];
124
- if (!bar)
125
- return;
126
- if (!fileName.endsWith(".min.js")) {
127
- bar.update(95, { type: "esm", entry, message: `processed` });
128
- } else {
129
- bar.update(100, { type: "esm", entry, message: `finished` });
130
- }
131
- }
132
- ),
136
+ watchingProgress("esm"),
133
137
  commonPlugins,
134
138
  globalsRegister({ external }),
135
139
  styled && skip({ patterns: [/\.s?css$/] }),
@@ -164,31 +168,7 @@ const template = ({
164
168
  })
165
169
  ],
166
170
  plugins: [
167
- progress(
168
- [input],
169
- (entry) => {
170
- const bar = progressState.umd[entry];
171
- if (!bar)
172
- return;
173
- bar.update(0, { type: "umd", entry, message: "processing" });
174
- },
175
- (id) => {
176
- const bar = progressState.umd[input];
177
- if (!bar)
178
- return;
179
- bar.update(50, { type: "umd", input, message: `transforming ${id}` });
180
- },
181
- (name2, fileName) => {
182
- const bar = progressState.umd[input];
183
- if (!bar)
184
- return;
185
- if (!fileName.endsWith(".min.js")) {
186
- bar.update(95, { type: "umd", input, message: `processed` });
187
- } else {
188
- bar.update(100, { type: "umd", input, message: `finished` });
189
- }
190
- }
191
- ),
171
+ watchingProgress("umd", input),
192
172
  commonPlugins,
193
173
  globalsOutput,
194
174
  styled && postcss({
@@ -217,38 +197,7 @@ const template = ({
217
197
  }
218
198
  ],
219
199
  plugins: [
220
- progress(
221
- Object.values(exportsEntries),
222
- (entry) => {
223
- const bar = progressState.dts[entry];
224
- if (!bar)
225
- return;
226
- bar.update(0, { type: "dts", entry, message: "processing" });
227
- },
228
- (id) => {
229
- const bar = progressState.dts[id];
230
- if (!bar)
231
- return;
232
- bar.update(50, { type: "dts", entry: id, message: `transforming ${id}` });
233
- },
234
- (name, fileName) => {
235
- const entry = exportsEntries[name];
236
- const bar = progressState.dts[entry];
237
- if (!bar)
238
- return;
239
- if (!fileName.endsWith(".esm.d.ts")) {
240
- bar.update(95, { type: "dts", entry, message: `processed` });
241
- } else {
242
- bar.update(100, { type: "dts", entry, message: `finished` });
243
- resolved[entry] = true;
244
- }
245
- if (Object.values(resolved).every(Boolean)) {
246
- setTimeout(() => {
247
- multiBars.stop();
248
- }, 100);
249
- }
250
- }
251
- ),
200
+ watchingProgress("dts"),
252
201
  commonPlugins,
253
202
  styled && skip({ patterns: [/\.s?css$/] }),
254
203
  dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),