jiek 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,30 +2,35 @@ 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';
12
12
  import externalResolver from './rollup/utils/externalResolver.esm.js';
13
13
  import withMinify from './rollup/utils/withMinify.esm.js';
14
14
 
15
- const workspaceRoot = getWorkspaceDir();
15
+ const {
16
+ JIEK_SILENT,
17
+ JIEK_TARGET,
18
+ JIEK_ROOT
19
+ } = process.env;
20
+ const target = JIEK_TARGET ?? "esm,umd,dts";
21
+ const ACCEPTED_TARGETS = ["esm", "umd", "dts"];
22
+ const targets = target.split(",").filter(Boolean).filter((t) => ACCEPTED_TARGETS.includes(t));
23
+ const workspaceRoot = JIEK_ROOT ?? getWorkspaceDir();
16
24
  function resolveWorkspacePath(p) {
17
25
  return resolve(workspaceRoot, p);
18
26
  }
19
- function progress(entries, onProcessing, onTransforming, onProcessed) {
27
+ function watchProgress(entries, onProcessing, onProcessed) {
20
28
  return {
21
29
  name: "progress",
22
30
  resolveId(source, importer) {
23
31
  if (entries.includes(source) || importer === void 0)
24
32
  onProcessing(source);
25
33
  },
26
- transform(_, id) {
27
- onTransforming(id);
28
- },
29
34
  writeBundle(options, bundle) {
30
35
  Object.entries(bundle).forEach(([key, value]) => {
31
36
  if (value.name === void 0 || !("isEntry" in value))
@@ -43,6 +48,8 @@ const template = ({
43
48
  dts: dtsPlugins = []
44
49
  } = {}
45
50
  } = {}, pkg) => {
51
+ if (targets.length === 0)
52
+ throw new Error("no target specified");
46
53
  const { jiek: {
47
54
  noBrowser = false,
48
55
  outdir = "dist"
@@ -61,6 +68,10 @@ const template = ({
61
68
  typeof value === "string" ? value : value["inner-src"]
62
69
  ])
63
70
  );
71
+ const maxLengthEntry = Math.max(...Object.values(exportsEntries).map((v) => v.length));
72
+ function paddingEntry(entry) {
73
+ return entry.padEnd(maxLengthEntry);
74
+ }
64
75
  const [globalsRegister, globalsOutput] = createGlobalsLinkage();
65
76
  const external = externalResolver();
66
77
  const commonOptions = {};
@@ -73,207 +84,167 @@ const template = ({
73
84
  format: "- {bar} | {type} | {entry} | {message}"
74
85
  }, Presets.shades_classic);
75
86
  const entries = Object.values(exportsEntries);
76
- 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
- }, {})
92
- };
87
+ const addBarsByEntries = (type) => entries.reduce((add, entry) => {
88
+ const bar = multiBars.create(100, 0);
89
+ bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
90
+ return { ...add, [entry]: bar };
91
+ }, {});
92
+ const progressState = {};
93
+ targets.forEach((target2) => {
94
+ progressState[target2] = addBarsByEntries(target2);
95
+ });
93
96
  const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
94
- return [
95
- {
97
+ const watchingProgress = (type, isLast = false, defaultEntry) => {
98
+ const group = progressState[type];
99
+ if (!group)
100
+ throw new Error(`target ${type} found`);
101
+ return watchProgress(
102
+ Object.values(exportsEntries),
103
+ (entry) => {
104
+ const e = defaultEntry ?? entry;
105
+ const bar = group[e];
106
+ if (!bar)
107
+ return;
108
+ bar.update(0, { type, entry: paddingEntry(e), message: "processing" });
109
+ },
110
+ (name, fileName) => {
111
+ const e = defaultEntry ?? exportsEntries[name];
112
+ const bar = group[e];
113
+ if (!bar)
114
+ return;
115
+ const endsReg = {
116
+ esm: /\.min\.js$/,
117
+ umd: /\.min\.c?js$/,
118
+ dts: /\.esm\.d\.ts$/
119
+ }[type];
120
+ if (!endsReg.test(fileName)) {
121
+ bar.update(95, { type, entry: paddingEntry(e), message: "processed" });
122
+ } else {
123
+ bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
124
+ }
125
+ if (isLast) {
126
+ resolved[e] = true;
127
+ if (Object.values(resolved).every(Boolean)) {
128
+ setTimeout(() => multiBars.stop(), 200);
129
+ }
130
+ }
131
+ }
132
+ );
133
+ };
134
+ const esmOpts = (isLast) => ({
135
+ ...commonOptions,
136
+ input: exportsEntries,
137
+ output: [
138
+ ...withMinify({
139
+ ...outputOptions,
140
+ format: "esm",
141
+ entryFileNames: "[name].esm.js",
142
+ preserveModules: true
143
+ })
144
+ ],
145
+ plugins: [
146
+ watchingProgress("esm", isLast),
147
+ commonPlugins,
148
+ globalsRegister({ external }),
149
+ styled && skip({ patterns: [/\.s?css$/] }),
150
+ esbuild(),
151
+ indexPlugins
152
+ ]
153
+ });
154
+ const umdOpts = (isLast) => Object.entries(exportsEntries).map(([name, input]) => {
155
+ const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
156
+ return {
96
157
  ...commonOptions,
97
- input: exportsEntries,
98
- output: [
158
+ input,
159
+ output: noBrowser ? [
99
160
  ...withMinify({
100
161
  ...outputOptions,
101
- format: "esm",
102
- entryFileNames: "[name].esm.js",
103
- preserveModules: true
162
+ name: outputName,
163
+ format: "cjs",
164
+ entryFileNames: `${name}.cjs`
165
+ })
166
+ ] : [
167
+ ...withMinify({
168
+ ...outputOptions,
169
+ name: outputName,
170
+ format: "iife",
171
+ entryFileNames: `${name}.iife.js`
172
+ }),
173
+ ...withMinify({
174
+ ...outputOptions,
175
+ name: outputName,
176
+ format: "umd",
177
+ entryFileNames: `${name}.umd.js`
104
178
  })
105
179
  ],
106
180
  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
- ),
181
+ watchingProgress("umd", isLast, input),
133
182
  commonPlugins,
134
- globalsRegister({ external }),
135
- styled && skip({ patterns: [/\.s?css$/] }),
183
+ globalsOutput,
184
+ styled && postcss({
185
+ plugins: [autoprefixer],
186
+ minimize: true,
187
+ sourceMap: true,
188
+ extract: `${name}.css`
189
+ }),
136
190
  esbuild(),
137
- indexPlugins
138
- ]
139
- },
140
- ...Object.entries(exportsEntries).map(([name, input]) => {
141
- const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
142
- return {
143
- ...commonOptions,
144
- input,
145
- output: noBrowser ? [
146
- ...withMinify({
147
- ...outputOptions,
148
- name: outputName,
149
- format: "cjs",
150
- entryFileNames: `${name}.cjs`
151
- })
152
- ] : [
153
- ...withMinify({
154
- ...outputOptions,
155
- name: outputName,
156
- format: "iife",
157
- entryFileNames: `${name}.iife.js`
158
- }),
159
- ...withMinify({
160
- ...outputOptions,
161
- name: outputName,
162
- format: "umd",
163
- entryFileNames: `${name}.umd.js`
164
- })
165
- ],
166
- 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
- ),
192
- commonPlugins,
193
- globalsOutput,
194
- styled && postcss({
195
- plugins: [autoprefixer],
196
- minimize: true,
197
- sourceMap: true,
198
- extract: `${name}.css`
199
- }),
200
- esbuild(),
201
- entryPlugins
202
- ],
203
- external
204
- };
205
- }),
206
- {
207
- ...commonOptions,
208
- input: exportsEntries,
209
- output: [
210
- {
211
- dir: "dist"
212
- },
213
- {
214
- dir: "dist",
215
- entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
216
- preserveModules: true
217
- }
218
- ],
219
- 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
- ),
252
- commonPlugins,
253
- styled && skip({ patterns: [/\.s?css$/] }),
254
- dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
255
- {
256
- name: "rollup-plugin-declare-module-replacer",
257
- /**
258
- * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
259
- * in output file generated
260
- */
261
- generateBundle(_, bundle) {
262
- for (const file of Object.values(bundle)) {
263
- if (!("code" in file))
264
- continue;
265
- file.code = file.code.replace(
266
- /declare module ['|"]\..*['|"]/g,
267
- `declare module '${pkg.name}'`
268
- );
269
- }
270
- }
271
- },
272
- dtsPlugins
191
+ entryPlugins
273
192
  ],
274
193
  external
275
- }
276
- ];
194
+ };
195
+ });
196
+ const dtsOpts = (isLast) => ({
197
+ ...commonOptions,
198
+ input: exportsEntries,
199
+ output: [
200
+ {
201
+ dir: "dist"
202
+ },
203
+ {
204
+ dir: "dist",
205
+ entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
206
+ preserveModules: true
207
+ }
208
+ ],
209
+ plugins: [
210
+ watchingProgress("dts", isLast),
211
+ commonPlugins,
212
+ styled && skip({ patterns: [/\.s?css$/] }),
213
+ dts({
214
+ tsconfig: resolveWorkspacePath("tsconfig.dts.json"),
215
+ compilerOptions: { outDir: outdir }
216
+ }),
217
+ {
218
+ name: "rollup-plugin-declare-module-replacer",
219
+ /**
220
+ * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
221
+ * in output file generated
222
+ */
223
+ generateBundle(_, bundle) {
224
+ for (const file of Object.values(bundle)) {
225
+ if (!("code" in file))
226
+ continue;
227
+ file.code = file.code.replace(
228
+ /declare module ['|"]\..*['|"]/g,
229
+ `declare module '${pkg.name}'`
230
+ );
231
+ }
232
+ }
233
+ },
234
+ dtsPlugins
235
+ ],
236
+ external
237
+ });
238
+ const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts };
239
+ return targets.flatMap((target2) => {
240
+ const optsGen = optionsMap[target2];
241
+ if (optsGen === void 0)
242
+ throw new Error(`target ${target2} is not supported`);
243
+ const opts = optsGen(target2 === targets[targets.length - 1]);
244
+ if (Array.isArray(opts))
245
+ return opts;
246
+ return [opts];
247
+ });
277
248
  };
278
249
 
279
250
  export { template };
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.esm.js","sources":["../src/rollup/index.ts"],"sourcesContent":["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"],"names":["entries","name"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,gBAAgB,eAAgB,EAAA,CAA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MAAA,CAAO,KAAK,EAAE,IAAA,EAAM,OAAO,KAAO,EAAA,OAAA,EAAS,YAAY,CAAA,CAAA;AAC3D,cAAA,QAAA,CAAS,KAAK,CAAI,GAAA,IAAA,CAAA;AAAA,aACpB;AACA,YAAA,IAAI,OAAO,MAAO,CAAA,QAAQ,CAAE,CAAA,KAAA,CAAM,OAAO,CAAG,EAAA;AAC1C,cAAA,UAAA,CAAW,MAAM;AACf,gBAAA,SAAA,CAAU,IAAK,EAAA,CAAA;AAAA,iBACd,GAAG,CAAA,CAAA;AAAA,aACR;AAAA,WACF;AAAA,SACF;AAAA,QACA,aAAA;AAAA,QACA,UAAU,IAAK,CAAA,EAAE,UAAU,CAAC,UAAU,GAAG,CAAA;AAAA,QACzC,IAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;AAAA,QAC3D;AAAA,UACE,IAAM,EAAA,uCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;AACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;AACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;AAAO,gBAAA,SAAA;AAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,gBACpB,gCAAA;AAAA,gBACA,CAAA,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;;;;"}
1
+ {"version":3,"file":"rollup.esm.js","sources":["../src/rollup/index.ts"],"sourcesContent":["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 {\n JIEK_SILENT,\n JIEK_TARGET,\n JIEK_ROOT\n} = process.env\nconst silent = JIEK_SILENT === 'true'\nconst target = JIEK_TARGET ?? 'esm,umd,dts'\nconst ACCEPTED_TARGETS = ['esm', 'umd', 'dts']\nconst targets = (\n target\n .split(',')\n .filter(Boolean)\n .filter(t => ACCEPTED_TARGETS.includes(t))\n) as ('esm' | 'umd' | 'dts')[]\nconst workspaceRoot = JIEK_ROOT ?? 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 if (targets.length === 0)\n throw new Error('no target specified')\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: Partial<Record<'esm' | 'umd' | 'dts', ReturnType<typeof addBarsByEntries>>> = {}\n targets.forEach(target => {\n progressState[target] = addBarsByEntries(target)\n })\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n isLast = false,\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n if (!group) throw new Error(`target ${type} found`)\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 (isLast) {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n const esmOpts: (isLast: boolean) => RollupOptions = isLast => ({\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', isLast),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n })\n const umdOpts: (isLast: boolean) => RollupOptions[] = isLast => 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', isLast, 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 const dtsOpts: (isLast: boolean) => RollupOptions = isLast => ({\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', isLast),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({\n tsconfig: resolveWorkspacePath('tsconfig.dts.json'),\n compilerOptions: { outDir: outdir }\n }),\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 const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts }\n return targets.flatMap(target => {\n const optsGen = optionsMap[target as 'esm' | 'umd' | 'dts']\n if (optsGen === undefined)\n throw new Error(`target ${target} is not supported`)\n const opts = optsGen(target === targets[targets.length - 1])\n if (Array.isArray(opts)) return opts\n return [opts]\n })\n}\n"],"names":["target","entries"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM;AAAA,EACJ,WAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AACF,CAAA,GAAI,OAAQ,CAAA,GAAA,CAAA;AAEZ,MAAM,SAAS,WAAe,IAAA,aAAA,CAAA;AAC9B,MAAM,gBAAmB,GAAA,CAAC,KAAO,EAAA,KAAA,EAAO,KAAK,CAAA,CAAA;AAC7C,MAAM,OACJ,GAAA,MAAA,CACG,KAAM,CAAA,GAAG,CACT,CAAA,MAAA,CAAO,OAAO,CAAA,CACd,MAAO,CAAA,CAAA,CAAA,KAA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AA;AACxC,YAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;AAAO,cAAA,SAAA;AAEvB,YAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,cACpB,gCAAA;AAAA,cACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,aAC7B,CAAA;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,MACA,UAAA;AAAA,KACF;AAAA,IACA,QAAA;AAAA,GACF,CAAA,CAAA;AACA,EAAA,MAAM,aAAa,EAAE,GAAA,EAAK,SAAS,GAAK,EAAA,OAAA,EAAS,KAAK,OAAQ,EAAA,CAAA;AAC9D,EAAO,OAAA,OAAA,CAAQ,OAAQ,CAAA,CAAAD,OAAU,KAAA;AAC/B,IAAM,MAAA,OAAA,GAAU,WAAWA,OAA+B,CAAA,CAAA;AAC1D,IAAA,IAAI,OAAY,KAAA,KAAA,CAAA;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAUA,OAAAA,EAAAA,OAAM,CAAmB,iBAAA,CAAA,CAAA,CAAA;AACrD,IAAA,MAAM,OAAO,OAAQA,CAAAA,OAAAA,KAAW,QAAQ,OAAQ,CAAA,MAAA,GAAS,CAAC,CAAC,CAAA,CAAA;AAC3D,IAAI,IAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;AAAG,MAAO,OAAA,IAAA,CAAA;AAChC,IAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;"}
@@ -1,2 +1,2 @@
1
- import{resolve as e}from"node:path";import{getWorkspaceDir as s}from"@jiek/utils/getWorkspaceDir";import t from"@rollup/plugin-json";import r from"autoprefixer";import{dts as n}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import o from"rollup-plugin-postcss";import{MultiBar as m,Presets as p}from"cli-progress";import{createGlobalsLinkage as a}from"./rollup/plugins/globals.esm.min.js";import u from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as d}from"./rollup/utils/commonOptions.esm.min.js";import l from"./rollup/utils/externalResolver.esm.min.js";import c from"./rollup/utils/withMinify.esm.min.js";const g=s();function f(e,s,t,r){return{name:"progress",resolveId(t,r){(e.includes(t)||void 0===r)&&s(t)},transform(e,s){t(s)},writeBundle(e,s){Object.entries(s).forEach((([e,s])=>{void 0!==s.name&&"isEntry"in s&&r(s.name,s.fileName)}))}}}const y=({styled:s=!1,plugins:{index:y=[],entry:j=[],dts:h=[]}={}}={},$)=>{const{jiek:{noBrowser:b=!1,outdir:v="dist"}={}}=$,w={...d,dir:v};if(!$.name)throw new Error("pkg.name is required");const x=$.name.replace(/[@|/-](\w)/g,((e,s)=>s.toUpperCase())),O=Object.fromEntries(Object.entries($.exports??{}).filter((([e])=>!e.startsWith(`./${v}`)&&!e.startsWith(v))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,s])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof s?s:s["inner-src"]]))),[N,W]=a(),k=l(),F={},B=[t()],C=new m({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},p.shades_classic),E=Object.values(O),M={esm:E.reduce(((e,s)=>{const t=C.create(100,0);return t.update(0,{type:"esm",entry:s,message:"waiting"}),{...e,[s]:t}}),{}),umd:E.reduce(((e,s)=>{const t=C.create(100,0);return t.update(0,{type:"umd",entry:s,message:"waiting"}),{...e,[s]:t}}),{}),dts:E.reduce(((e,s)=>{const t=C.create(100,0);return t.update(0,{type:"dts",entry:s,message:"waiting"}),{...e,[s]:t}}),{})},U=E.reduce(((e,s)=>({...e,[s]:!1})),{});return[{...F,input:O,output:[...c({...w,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[f(Object.values(O),(e=>{const s=M.esm[e];s&&s.update(0,{type:"esm",entry:e,message:"processing"})}),(e=>{const s=M.esm[e];s&&s.update(50,{type:"esm",entry:e,message:`transforming ${e}`})}),((e,s)=>{const t=O[e],r=M.esm[t];r&&(s.endsWith(".min.js")?r.update(100,{type:"esm",entry:t,message:"finished"}):r.update(95,{type:"esm",entry:t,message:"processed"}))})),B,N({external:k}),s&&u({patterns:[/\.s?css$/]}),i(),y]},...Object.entries(O).map((([e,t])=>{const n=x+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,s)=>s.toUpperCase())));return{...F,input:t,output:b?[...c({...w,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...c({...w,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...c({...w,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[f([t],(e=>{const s=M.umd[e];s&&s.update(0,{type:"umd",entry:e,message:"processing"})}),(e=>{const s=M.umd[t];s&&s.update(50,{type:"umd",input:t,message:`transforming ${e}`})}),((e,s)=>{const r=M.umd[t];r&&(s.endsWith(".min.js")?r.update(100,{type:"umd",input:t,message:"finished"}):r.update(95,{type:"umd",input:t,message:"processed"}))})),B,W,s&&o({plugins:[r],minimize:!0,sourceMap:!0,extract:`${e}.css`}),i(),j],external:k}})),{...F,input:O,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[f(Object.values(O),(e=>{const s=M.dts[e];s&&s.update(0,{type:"dts",entry:e,message:"processing"})}),(e=>{const s=M.dts[e];s&&s.update(50,{type:"dts",entry:e,message:`transforming ${e}`})}),((e,s)=>{const t=O[e],r=M.dts[t];r&&(s.endsWith(".esm.d.ts")?(r.update(100,{type:"dts",entry:t,message:"finished"}),U[t]=!0):r.update(95,{type:"dts",entry:t,message:"processed"}),Object.values(U).every(Boolean)&&setTimeout((()=>{C.stop()}),100))})),B,s&&u({patterns:[/\.s?css$/]}),n({tsconfig:(q="tsconfig.dts.json",e(g,q))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,s){for(const e of Object.values(s))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${$.name}'`))}},h],external:k}];var q};export{y as template};
1
+ import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import t from"@rollup/plugin-json";import s from"autoprefixer";import{MultiBar as o,Presets as n}from"cli-progress";import{dts as i}from"rollup-plugin-dts";import m from"rollup-plugin-esbuild";import p from"rollup-plugin-postcss";import{createGlobalsLinkage as l}from"./rollup/plugins/globals.esm.min.js";import a from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as u}from"./rollup/utils/commonOptions.esm.min.js";import c from"./rollup/utils/externalResolver.esm.min.js";import d from"./rollup/utils/withMinify.esm.min.js";const{JIEK_SILENT:f,JIEK_TARGET:g,JIEK_ROOT:j}=process.env,y=["esm","umd","dts"],h=(g??"esm,umd,dts").split(",").filter(Boolean).filter((e=>y.includes(e))),v=j??r();const $=({styled:r=!1,plugins:{index:f=[],entry:g=[],dts:j=[]}={}}={},y)=>{if(0===h.length)throw new Error("no target specified");const{jiek:{noBrowser:$=!1,outdir:w="dist"}={}}=y,E={...u,dir:w};if(!y.name)throw new Error("pkg.name is required");const O=y.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),b=Object.fromEntries(Object.entries(y.exports??{}).filter((([e])=>!e.startsWith(`./${w}`)&&!e.startsWith(w))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,r])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof r?r:r["inner-src"]]))),x=Math.max(...Object.values(b).map((e=>e.length)));function N(e){return e.padEnd(x)}const[M,k]=l(),B=c(),F={},I=[t()],T=new o({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},n.shades_classic),C=Object.values(b),_={};h.forEach((e=>{var r;_[e]=(r=e,C.reduce(((e,t)=>{const s=T.create(100,0);return s.update(0,{type:r,entry:N(t),message:"waiting"}),{...e,[t]:s}}),{}))}));const A=C.reduce(((e,r)=>({...e,[r]:!1})),{}),J=(e,r=!1,t)=>{const s=_[e];if(!s)throw new Error(`target ${e} found`);return function(e,r,t){return{name:"progress",resolveId(t,s){(e.includes(t)||void 0===s)&&r(t)},writeBundle(e,r){Object.entries(r).forEach((([e,r])=>{void 0!==r.name&&"isEntry"in r&&t(r.name,r.fileName)}))}}}(Object.values(b),(r=>{const o=t??r,n=s[o];n&&n.update(0,{type:e,entry:N(o),message:"processing"})}),((o,n)=>{const i=t??b[o],m=s[i];if(!m)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(n)?m.update(100,{type:e,entry:N(i),message:"finished"}):m.update(95,{type:e,entry:N(i),message:"processed"}),r&&(A[i]=!0,Object.values(A).every(Boolean)&&setTimeout((()=>T.stop()),200))}))},K={esm:e=>({...F,input:b,output:[...d({...E,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[J("esm",e),I,M({external:B}),r&&a({patterns:[/\.s?css$/]}),m(),f]}),umd:e=>Object.entries(b).map((([t,o])=>{const n=O+("index"===t?"":t.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{...F,input:o,output:$?[...d({...E,name:n,format:"cjs",entryFileNames:`${t}.cjs`})]:[...d({...E,name:n,format:"iife",entryFileNames:`${t}.iife.js`}),...d({...E,name:n,format:"umd",entryFileNames:`${t}.umd.js`})],plugins:[J("umd",e,o),I,k,r&&p({plugins:[s],minimize:!0,sourceMap:!0,extract:`${t}.css`}),m(),g],external:B}})),dts:t=>{return{...F,input:b,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[J("dts",t),I,r&&a({patterns:[/\.s?css$/]}),i({tsconfig:(s="tsconfig.dts.json",e(v,s)),compilerOptions:{outDir:w}}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,r){for(const e of Object.values(r))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${y.name}'`))}},j],external:B};var s}};return h.flatMap((e=>{const r=K[e];if(void 0===r)throw new Error(`target ${e} is not supported`);const t=r(e===h[h.length-1]);return Array.isArray(t)?t:[t]}))};export{$ as template};
2
2
  //# sourceMappingURL=rollup.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["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"],"names":["workspaceRoot","getWorkspaceDir","progress","entries","onProcessing","onTransforming","onProcessed","name","resolveId","source","importer","includes","transform","_","id","writeBundle","options","bundle","Object","forEach","key","value","fileName","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","outdir","outputOptions","commonOutputOptions","dir","Error","namePrefix","replace","$1","toUpperCase","exportsEntries","fromEntries","exports","filter","startsWith","test","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","values","progressState","esm","reduce","add","bar","create","update","type","message","umd","resolved","input","output","withMinify","entryFileNames","preserveModules","endsWith","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","every","Boolean","setTimeout","stop","tsconfig","p","resolve","generateBundle","file","code"],"mappings":"+nBAkBA,MAAMA,EAAgBC,IAKtB,SAASC,EACPC,EACAC,EACAC,EACAC,GAEO,MAAA,CACLC,KAAM,WACN,SAAAC,CAAUC,EAAQC,IACZP,EAAQQ,SAASF,SAAwB,IAAbC,IAC9BN,EAAaK,EACjB,EACA,SAAAG,CAAUC,EAAGC,GACXT,EAAeS,EACjB,EACA,WAAAC,CAAYC,EAASC,GACZC,OAAAf,QAAQc,GAAQE,SAAQ,EAAEC,EAAKC,WACjB,IAAfA,EAAMd,MAAwB,YAAac,GACnCf,EAAAe,EAAMd,KAAMc,EAAMC,SAAQ,GAE1C,EAEJ,CAEO,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,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,IACjBC,EACHC,IAAKH,GAEH,IAACH,EAAIzB,KACD,MAAA,IAAIgC,MAAM,wBAEZ,MAAAC,EAAaR,EAChBzB,KACAkC,QAAQ,eAAe,CAAC5B,EAAG6B,IAAOA,EAAGC,gBAClCC,EAAiB1B,O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BZ,EAAAE,OAAO,IAAK,CAAEC,KAAM,MAAO9C,QAAO+C,QAAS,aAC/CE,EAASjD,IAAS,GAHd2C,EAAAE,OAAO,GAAI,CAAEC,KAAM,MAAO9C,QAAO+C,QAAS,cAK5CzD,OAAOgD,OAAOW,GAAUgB,MAAMC,UAChCC,YAAW,KACTpC,EAAUqC,MAAK,GACd,KACL,IAGJvC,EACAjC,GAAU4D,EAAK,CAAEC,SAAU,CAAC,cAC5BvD,EAAI,CAAEmE,UAjRgBC,EAiRe,oBAhRpCC,EAAQnG,EAAekG,MAiRxB,CACE3F,KAAM,wCAKN,cAAA6F,CAAevF,EAAGI,GAChB,IAAA,MAAWoF,KAAQnF,OAAOgD,OAAOjD,GACzB,SAAUoF,IAEXA,EAAAC,KAAOD,EAAKC,KAAK7D,QACpB,iCACA,mBAAmBT,EAAIzB,SAG7B,GAEFwB,GAEFuB,aArSN,IAA8B4C,CAuS5B"}
1
+ {"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["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 {\n JIEK_SILENT,\n JIEK_TARGET,\n JIEK_ROOT\n} = process.env\nconst silent = JIEK_SILENT === 'true'\nconst target = JIEK_TARGET ?? 'esm,umd,dts'\nconst ACCEPTED_TARGETS = ['esm', 'umd', 'dts']\nconst targets = (\n target\n .split(',')\n .filter(Boolean)\n .filter(t => ACCEPTED_TARGETS.includes(t))\n) as ('esm' | 'umd' | 'dts')[]\nconst workspaceRoot = JIEK_ROOT ?? 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 if (targets.length === 0)\n throw new Error('no target specified')\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: Partial<Record<'esm' | 'umd' | 'dts', ReturnType<typeof addBarsByEntries>>> = {}\n targets.forEach(target => {\n progressState[target] = addBarsByEntries(target)\n })\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n isLast = false,\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n if (!group) throw new Error(`target ${type} found`)\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 (isLast) {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n const esmOpts: (isLast: boolean) => RollupOptions = isLast => ({\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', isLast),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n })\n const umdOpts: (isLast: boolean) => RollupOptions[] = isLast => 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', isLast, 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 const dtsOpts: (isLast: boolean) => RollupOptions = isLast => ({\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', isLast),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({\n tsconfig: resolveWorkspacePath('tsconfig.dts.json'),\n compilerOptions: { outDir: outdir }\n }),\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 const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts }\n return targets.flatMap(target => {\n const optsGen = optionsMap[target as 'esm' | 'umd' | 'dts']\n if (optsGen === undefined)\n throw new Error(`target ${target} is not supported`)\n const opts = optsGen(target === targets[targets.length - 1])\n if (Array.isArray(opts)) return opts\n return [opts]\n })\n}\n"],"names":["JIEK_SILENT","JIEK_TARGET","JIEK_ROOT","process","env","ACCEPTED_TARGETS","targets","split","filter","Boolean","t","includes","workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","length","Error","jiek","noBrowser","outdir","outputOptions","commonOutputOptions","dir","name","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","key","startsWith","test","value","map","maxLengthEntry","Math","max","values","v","paddingEntry","padEnd","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","progressState","forEach","target","type","reduce","add","bar","create","update","message","resolved","watchingProgress","isLast","defaultEntry","group","onProcessing","onProcessed","resolveId","source","importer","writeBundle","options","bundle","fileName","watchProgress","e","esm","umd","every","setTimeout","stop","optionsMap","input","output","withMinify","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","compilerOptions","outDir","generateBundle","file","code","flatMap","optsGen","opts","Array","isArray"],"mappings":"+nBAkBA,MAAMA,YACJA,EAAAC,YACAA,EAAAC,UACAA,GACEC,QAAQC,IAGNC,EAAmB,CAAC,MAAO,MAAO,OAClCC,GAFSL,GAAe,eAIzBM,MAAM,KACNC,OAAOC,SACPD,QAAOE,GAAKL,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BAAiB,IAGrB1F,QAAS,CACPiE,EAAiB,MAAOC,GACxBrB,EACA9C,GAAU4F,EAAK,CAAEC,SAAU,CAAC,cAC5BvF,EAAI,CACF+F,UA5OsBC,EA4OS,oBA3O9BC,EAAQ1G,EAAeyG,IA4OxBE,gBAAiB,CAAEC,OAAQ5F,KAE7B,CACEI,KAAM,wCAKN,cAAAyF,CAAetF,EAAGyD,GAChB,IAAA,MAAW8B,KAAQnF,OAAOY,OAAOyC,GACzB,SAAU8B,IAEXA,EAAAC,KAAOD,EAAKC,KAAKzF,QACpB,iCACA,mBAAmBX,EAAIS,SAG7B,GAEFV,GAEFoC,YAlQJ,IAA8B2D,CAmQ5B,GAEO,OAAA/G,EAAQsH,SAAQpD,IACf,MAAAqD,EAAUxB,EAAW7B,GAC3B,QAAgB,IAAZqD,EACF,MAAM,IAAIpG,MAAM,UAAU+C,sBAC5B,MAAMsD,EAAOD,EAAQrD,IAAWlE,EAAQA,EAAQkB,OAAS,IACrD,OAAAuG,MAAMC,QAAQF,GAAcA,EACzB,CAACA,EAAI,GACb"}
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),r=require("@rollup/plugin-json"),s=require("autoprefixer"),n=require("cli-progress"),i=require("rollup-plugin-dts"),o=require("rollup-plugin-esbuild"),a=require("rollup-plugin-postcss"),u=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var c=l(r),p=l(s),d=l(o),m=l(a),f=l(u);function g(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var y=(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(/(\.c?js)$/,".min$1"),plugins:[...e.plugins??[],f.default()]}]}const{JIEK_SILENT:v,JIEK_TARGET:b,JIEK_ROOT:w}=process.env,O=["esm","umd","dts"],h=(b??"esm,umd,dts").split(",").filter(Boolean).filter((e=>O.includes(e))),x=w??t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:o=[]}={}}={},a)=>{if(0===h.length)throw new Error("no target specified");const{jiek:{noBrowser:u=!1,outdir:l="dist"}={}}=a,f={...j,dir:l};if(!a.name)throw new Error("pkg.name is required");const v=a.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),b=Object.fromEntries(Object.entries(a.exports??{}).filter((([e])=>!e.startsWith(`./${l}`)&&!e.startsWith(l))).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"]]))),w=Math.max(...Object.values(b).map((e=>e.length)));function O(e){return e.padEnd(w)}const[E,q]=function(){let e={};const t=new Set([]);return[({external:r}={})=>({name:"globals",resolveId:e=>r?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:r=>(e=[...t].reduce(((e,t)=>({...e,[t]:g(t)})),{}),{...r,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),k=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:r={},peerDependencies:s={},optionalDependencies:n={}}=t;return Object.keys(r).concat(Object.keys(s)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),N={},F=[c.default()],M=new n.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},n.Presets.shades_classic),B=Object.values(b),I={};h.forEach((e=>{var t;I[e]=(t=e,B.reduce(((e,r)=>{const s=M.create(100,0);return s.update(0,{type:t,entry:O(r),message:"waiting"}),{...e,[r]:s}}),{}))}));const _=B.reduce(((e,t)=>({...e,[t]:!1})),{}),C=(e,t=!1,r)=>{const s=I[e];if(!s)throw new Error(`target ${e} found`);return function(e,t,r){return{name:"progress",resolveId(r,s){(e.includes(r)||void 0===s)&&t(r)},writeBundle(e,t){Object.entries(t).forEach((([e,t])=>{void 0!==t.name&&"isEntry"in t&&r(t.name,t.fileName)}))}}}(Object.values(b),(t=>{const n=r??t,i=s[n];i&&i.update(0,{type:e,entry:O(n),message:"processing"})}),((n,i)=>{const o=r??b[n],a=s[o];if(!a)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(i)?a.update(100,{type:e,entry:O(o),message:"finished"}):a.update(95,{type:e,entry:O(o),message:"processed"}),t&&(_[o]=!0,Object.values(_).every(Boolean)&&setTimeout((()=>M.stop()),200))}))},D={esm:e=>({...N,input:b,output:[...$({...f,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[C("esm",e),F,E({external:k}),t&&y({patterns:[/\.s?css$/]}),d.default(),r]}),umd:e=>Object.entries(b).map((([r,n])=>{const i=v+("index"===r?"":r.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{...N,input:n,output:u?[...$({...f,name:i,format:"cjs",entryFileNames:`${r}.cjs`})]:[...$({...f,name:i,format:"iife",entryFileNames:`${r}.iife.js`}),...$({...f,name:i,format:"umd",entryFileNames:`${r}.umd.js`})],plugins:[C("umd",e,n),F,q,t&&m.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${r}.css`}),d.default(),s],external:k}})),dts:r=>{return{...N,input:b,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[C("dts",r),F,t&&y({patterns:[/\.s?css$/]}),i.dts({tsconfig:(s="tsconfig.dts.json",e.resolve(x,s)),compilerOptions:{outDir:l}}),{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 '${a.name}'`))}},o],external:k};var s}};return h.flatMap((e=>{const t=D[e];if(void 0===t)throw new Error(`target ${e} is not supported`);const r=t(e===h[h.length-1]);return Array.isArray(r)?r:[r]}))};
2
+ //# sourceMappingURL=rollup.min.cjs.map