jiek 0.4.2 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cli.cjs +9 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.min.cjs +1 -1
- package/dist/cli.min.cjs.map +1 -1
- package/dist/commands/base.esm.js.map +1 -1
- package/dist/commands/base.esm.min.js.map +1 -1
- package/dist/commands/build.esm.js +9 -3
- package/dist/commands/build.esm.js.map +1 -1
- package/dist/commands/build.esm.min.js +1 -1
- package/dist/commands/build.esm.min.js.map +1 -1
- package/dist/rollup.cjs +121 -102
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.esm.js +121 -102
- package/dist/rollup.esm.js.map +1 -1
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/dist/rollup.min.cjs +1 -1
- package/dist/rollup.min.cjs.map +1 -1
- package/package.json +2 -2
package/dist/rollup.esm.js
CHANGED
@@ -3,7 +3,7 @@ import { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir';
|
|
3
3
|
import json from '@rollup/plugin-json';
|
4
4
|
import autoprefixer from 'autoprefixer';
|
5
5
|
import { MultiBar, Presets } from 'cli-progress';
|
6
|
-
import { dts } from 'rollup-plugin-dts';
|
6
|
+
import { dts } from '@jiek/rollup-plugin-dts';
|
7
7
|
import esbuild from 'rollup-plugin-esbuild';
|
8
8
|
import postcss from 'rollup-plugin-postcss';
|
9
9
|
import { createGlobalsLinkage } from './rollup/plugins/globals.esm.js';
|
@@ -12,7 +12,15 @@ 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
|
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
|
}
|
@@ -40,6 +48,8 @@ const template = ({
|
|
40
48
|
dts: dtsPlugins = []
|
41
49
|
} = {}
|
42
50
|
} = {}, pkg) => {
|
51
|
+
if (targets.length === 0)
|
52
|
+
throw new Error("no target specified");
|
43
53
|
const { jiek: {
|
44
54
|
noBrowser = false,
|
45
55
|
outdir = "dist"
|
@@ -79,14 +89,15 @@ const template = ({
|
|
79
89
|
bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
|
80
90
|
return { ...add, [entry]: bar };
|
81
91
|
}, {});
|
82
|
-
const progressState = {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
};
|
92
|
+
const progressState = {};
|
93
|
+
targets.forEach((target2) => {
|
94
|
+
progressState[target2] = addBarsByEntries(target2);
|
95
|
+
});
|
87
96
|
const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
|
88
|
-
const watchingProgress = (type, defaultEntry) => {
|
97
|
+
const watchingProgress = (type, isLast = false, defaultEntry) => {
|
89
98
|
const group = progressState[type];
|
99
|
+
if (!group)
|
100
|
+
throw new Error(`target ${type} found`);
|
90
101
|
return watchProgress(
|
91
102
|
Object.values(exportsEntries),
|
92
103
|
(entry) => {
|
@@ -111,7 +122,7 @@ const template = ({
|
|
111
122
|
} else {
|
112
123
|
bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
|
113
124
|
}
|
114
|
-
if (
|
125
|
+
if (isLast) {
|
115
126
|
resolved[e] = true;
|
116
127
|
if (Object.values(resolved).every(Boolean)) {
|
117
128
|
setTimeout(() => multiBars.stop(), 200);
|
@@ -120,109 +131,117 @@ const template = ({
|
|
120
131
|
}
|
121
132
|
);
|
122
133
|
};
|
123
|
-
|
124
|
-
|
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 {
|
125
157
|
...commonOptions,
|
126
|
-
input
|
127
|
-
output: [
|
158
|
+
input,
|
159
|
+
output: noBrowser ? [
|
160
|
+
...withMinify({
|
161
|
+
...outputOptions,
|
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
|
+
}),
|
128
173
|
...withMinify({
|
129
174
|
...outputOptions,
|
130
|
-
|
131
|
-
|
132
|
-
|
175
|
+
name: outputName,
|
176
|
+
format: "umd",
|
177
|
+
entryFileNames: `${name}.umd.js`
|
133
178
|
})
|
134
179
|
],
|
135
180
|
plugins: [
|
136
|
-
watchingProgress("
|
181
|
+
watchingProgress("umd", isLast, input),
|
137
182
|
commonPlugins,
|
138
|
-
|
139
|
-
styled &&
|
183
|
+
globalsOutput,
|
184
|
+
styled && postcss({
|
185
|
+
plugins: [autoprefixer],
|
186
|
+
minimize: true,
|
187
|
+
sourceMap: true,
|
188
|
+
extract: `${name}.css`
|
189
|
+
}),
|
140
190
|
esbuild(),
|
141
|
-
|
142
|
-
]
|
143
|
-
},
|
144
|
-
...Object.entries(exportsEntries).map(([name, input]) => {
|
145
|
-
const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
|
146
|
-
return {
|
147
|
-
...commonOptions,
|
148
|
-
input,
|
149
|
-
output: noBrowser ? [
|
150
|
-
...withMinify({
|
151
|
-
...outputOptions,
|
152
|
-
name: outputName,
|
153
|
-
format: "cjs",
|
154
|
-
entryFileNames: `${name}.cjs`
|
155
|
-
})
|
156
|
-
] : [
|
157
|
-
...withMinify({
|
158
|
-
...outputOptions,
|
159
|
-
name: outputName,
|
160
|
-
format: "iife",
|
161
|
-
entryFileNames: `${name}.iife.js`
|
162
|
-
}),
|
163
|
-
...withMinify({
|
164
|
-
...outputOptions,
|
165
|
-
name: outputName,
|
166
|
-
format: "umd",
|
167
|
-
entryFileNames: `${name}.umd.js`
|
168
|
-
})
|
169
|
-
],
|
170
|
-
plugins: [
|
171
|
-
watchingProgress("umd", input),
|
172
|
-
commonPlugins,
|
173
|
-
globalsOutput,
|
174
|
-
styled && postcss({
|
175
|
-
plugins: [autoprefixer],
|
176
|
-
minimize: true,
|
177
|
-
sourceMap: true,
|
178
|
-
extract: `${name}.css`
|
179
|
-
}),
|
180
|
-
esbuild(),
|
181
|
-
entryPlugins
|
182
|
-
],
|
183
|
-
external
|
184
|
-
};
|
185
|
-
}),
|
186
|
-
{
|
187
|
-
...commonOptions,
|
188
|
-
input: exportsEntries,
|
189
|
-
output: [
|
190
|
-
{
|
191
|
-
dir: "dist"
|
192
|
-
},
|
193
|
-
{
|
194
|
-
dir: "dist",
|
195
|
-
entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
|
196
|
-
preserveModules: true
|
197
|
-
}
|
198
|
-
],
|
199
|
-
plugins: [
|
200
|
-
watchingProgress("dts"),
|
201
|
-
commonPlugins,
|
202
|
-
styled && skip({ patterns: [/\.s?css$/] }),
|
203
|
-
dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
|
204
|
-
{
|
205
|
-
name: "rollup-plugin-declare-module-replacer",
|
206
|
-
/**
|
207
|
-
* replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
|
208
|
-
* in output file generated
|
209
|
-
*/
|
210
|
-
generateBundle(_, bundle) {
|
211
|
-
for (const file of Object.values(bundle)) {
|
212
|
-
if (!("code" in file))
|
213
|
-
continue;
|
214
|
-
file.code = file.code.replace(
|
215
|
-
/declare module ['|"]\..*['|"]/g,
|
216
|
-
`declare module '${pkg.name}'`
|
217
|
-
);
|
218
|
-
}
|
219
|
-
}
|
220
|
-
},
|
221
|
-
dtsPlugins
|
191
|
+
entryPlugins
|
222
192
|
],
|
223
193
|
external
|
224
|
-
}
|
225
|
-
|
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({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
|
214
|
+
{
|
215
|
+
name: "rollup-plugin-declare-module-replacer",
|
216
|
+
/**
|
217
|
+
* replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
|
218
|
+
* in output file generated
|
219
|
+
*/
|
220
|
+
generateBundle(_, bundle) {
|
221
|
+
for (const file of Object.values(bundle)) {
|
222
|
+
if (!("code" in file))
|
223
|
+
continue;
|
224
|
+
file.code = file.code.replace(
|
225
|
+
/declare module ['|"]\..*['|"]/g,
|
226
|
+
`declare module '${pkg.name}'`
|
227
|
+
);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
},
|
231
|
+
dtsPlugins
|
232
|
+
],
|
233
|
+
external
|
234
|
+
});
|
235
|
+
const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts };
|
236
|
+
return targets.flatMap((target2) => {
|
237
|
+
const optsGen = optionsMap[target2];
|
238
|
+
if (optsGen === void 0)
|
239
|
+
throw new Error(`target ${target2} is not supported`);
|
240
|
+
const opts = optsGen(target2 === targets[targets.length - 1]);
|
241
|
+
if (Array.isArray(opts))
|
242
|
+
return opts;
|
243
|
+
return [opts];
|
244
|
+
});
|
226
245
|
};
|
227
246
|
|
228
247
|
export { template };
|
package/dist/rollup.esm.js.map
CHANGED
@@ -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 { 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":["entries"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,gBAAgB,eAAgB,EAAA,CAAA;AACtC,SAAS,qBAAqB,CAAW,EAAA;AACvC,EAAO,OAAA,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA;AACjC,CAAA;AAEA,SAAS,aAAA,CACP,OACA,EAAA,YAAA,EACA,WACQ,EAAA;AACR,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,UAAA;AAAA,IACN,SAAA,CAAU,QAAQ,Q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B,EAAA,IAAA;AAAA,SACnB;AAAA,OACF;AAAA,MACA,OAAS,EAAA;AAAA,QACP,iBAAiB,KAAK,CAAA;AAAA,QACtB,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 '@jiek/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({ 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 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,KAAK,gBAAiB,CAAA,QAAA,CAAS,CAAC,CAAC,CAAA,CAAA;AAE7C,MAAM,aAAA,GAAgB,aAAa,eAAgB,EAAA,CAAA;AACnD,SAAS,qBAAqB,CAAW,EAAA;AACvC,EAAO,OAAA,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA;AACjC,CAAA;AAEA,SAAS,aAAA,CACP,OACA,EAAA,YAAA,EACA,WACQ,EAAA;AACR,EAAO,OAAA;AAAA,IACL,IAAM,E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AAK,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;;;;"}
|
package/dist/rollup.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{resolve as e}from"node:path";import{getWorkspaceDir as
|
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 n,Presets as o}from"cli-progress";import{dts as i}from"@jiek/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 b=y.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),O=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(O).map((e=>e.length)));function N(e){return e.padEnd(x)}const[k,M]=l(),B=c(),F={},I=[t()],T=new n({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},o.shades_classic),C=Object.values(O),_={};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(O),(r=>{const n=t??r,o=s[n];o&&o.update(0,{type:e,entry:N(n),message:"processing"})}),((n,o)=>{const i=t??O[n],m=s[i];if(!m)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(o)?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:O,output:[...d({...E,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[J("esm",e),I,k({external:B}),r&&a({patterns:[/\.s?css$/]}),m(),f]}),umd:e=>Object.entries(O).map((([t,n])=>{const o=b+("index"===t?"":t.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{...F,input:n,output:$?[...d({...E,name:o,format:"cjs",entryFileNames:`${t}.cjs`})]:[...d({...E,name:o,format:"iife",entryFileNames:`${t}.iife.js`}),...d({...E,name:o,format:"umd",entryFileNames:`${t}.umd.js`})],plugins:[J("umd",e,n),I,M,r&&p({plugins:[s],minimize:!0,sourceMap:!0,extract:`${t}.css`}),m(),g],external:B}})),dts:t=>{return{...F,input:O,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))}),{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 { 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":["workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","outdir","outputOptions","commonOutputOptions","dir","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","startsWith","test","value","map","maxLengthEntry","Math","max","values","v","length","paddingEntry","padEnd","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","addBarsByEntries","type","reduce","add","bar","create","update","message","progressState","esm","umd","resolved","watchingProgress","defaultEntry","group","onProcessing","onProcessed","resolveId","source","importer","includes","writeBundle","options","bundle","forEach","fileName","watchProgress","e","every","Boolean","setTimeout","stop","input","output","withMinify","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","file","code"],"mappings":"+nBAkBA,MAAMA,EAAgBC,IAyBf,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,EAAIO,KACD,MAAA,IAAIC,MAAM,wBAEZ,MAAAC,EAAaT,EAChBO,KACAG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQjB,EAAIkB,SAAW,CAAA,GAE3BC,QAAO,EAAEC,MAAUA,EAAIC,WAAW,KAAKlB,OAAciB,EAAIC,WAAWlB,KAEpEgB,QAAO,EAAEC,MAAU,qBAAqBE,KAAKF,KAE7CD,QAAO,EAAC,CAAGI,KAA4B,iBAAVA,GAAsBA,EAAM,cAAgBA,EAAc,SACvFC,KAAI,EAAEJ,EAAKG,KAAW,CACrBH,EACGV,QA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E,cAGvBd,QAAS,CACPmE,EAAiB,MAAOoB,GACxBzC,EACAL,EACA1C,GAAUiG,EAAQ,CAChBhG,QAAS,CAACiG,GACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGtF,UAEdgF,IACA1F,GAEFuC,WACF,IAEF,IACKE,EACH0C,MAAOlE,EACPmE,OAAQ,CACN,CACE3E,IAAK,QAEP,CACEA,IAAK,OACL6E,eAAgB,EAAG5E,UAAW,GAAGA,EAAKG,QAAQ,SAAU,eACxD0E,iBAAiB,IAGrB3F,QAAS,CACPmE,EAAiB,OACjBrB,EACA/C,GAAU6F,EAAK,CAAEC,SAAU,CAAC,cAC5BxF,EAAI,CAAEgG,UAxOgBC,EAwOe,oBAvOpCC,EAAQ3G,EAAe0G,MAwOxB,CACExF,KAAM,wCAKN,cAAA0F,CAAetF,EAAG4D,GAChB,IAAA,MAAW2B,KAAQnF,OAAOa,OAAO2C,GACzB,SAAU2B,IAEXA,EAAAC,KAAOD,EAAKC,KAAKzF,QACpB,iCACA,mBAAmBV,EAAIO,SAG7B,GAEFR,GAEFqC,aA5PN,IAA8B2D,CA8P5B"}
|
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 '@jiek/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({ 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 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","generateBundle","file","code","flatMap","optsGen","opts","Array","isArray"],"mappings":"qoBAkBA,MAAMA,YACJA,EAAAC,YACAA,EAAAC,UACAA,GACEC,QAAQC,IAGNC,E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IAAK,QAEP,CACEA,IAAK,OACL0E,eAAgB,EAAGzE,UAAW,GAAGA,EAAKE,QAAQ,SAAU,eACxDwE,iBAAiB,IAGrB1F,QAAS,CACPiE,EAAiB,MAAOC,GACxBrB,EACA9C,GAAU4F,EAAK,CAAEC,SAAU,CAAC,cAC5BvF,EAAI,CAAE+F,UA3OkBC,EA2Oa,oBA1OlCC,EAAQ1G,EAAeyG,MA2O1B,CACErF,KAAM,wCAKN,cAAAuF,CAAepF,EAAGyD,GAChB,IAAA,MAAW4B,KAAQjF,OAAOY,OAAOyC,GACzB,SAAU4B,IAEXA,EAAAC,KAAOD,EAAKC,KAAKvF,QACpB,iCACA,mBAAmBX,EAAIS,SAG7B,GAEFV,GAEFoC,YA/PJ,IAA8B2D,CAgQ5B,GAEO,OAAA/G,EAAQoH,SAAQlD,IACf,MAAAmD,EAAUtB,EAAW7B,GAC3B,QAAgB,IAAZmD,EACF,MAAM,IAAIlG,MAAM,UAAU+C,sBAC5B,MAAMoD,EAAOD,EAAQnD,IAAWlE,EAAQA,EAAQkB,OAAS,IACrD,OAAAqG,MAAMC,QAAQF,GAAcA,EACzB,CAACA,EAAI,GACb"}
|
package/dist/rollup.min.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),
|
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("@jiek/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,h=["esm","umd","dts"],O=(b??"esm,umd,dts").split(",").filter(Boolean).filter((e=>h.includes(e))),x=w??t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:o=[]}={}}={},a)=>{if(0===O.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 h(e){return e.padEnd(w)}const[E,k]=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})}]}(),q=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={};O.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:h(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:h(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:h(o),message:"finished"}):a.update(95,{type:e,entry:h(o),message:"processed"}),t&&(_[o]=!0,Object.values(_).every(Boolean)&&setTimeout((()=>M.stop()),200))}))},T={esm:e=>({...N,input:b,output:[...$({...f,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[C("esm",e),F,E({external:q}),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,k,t&&m.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${r}.css`}),d.default(),s],external:q}})),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))}),{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:q};var s}};return O.flatMap((e=>{const t=T[e];if(void 0===t)throw new Error(`target ${e} is not supported`);const r=t(e===O[O.length-1]);return Array.isArray(r)?r:[r]}))};
|
2
2
|
//# sourceMappingURL=rollup.min.cjs.map
|
package/dist/rollup.min.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rollup.min.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(/(\\.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","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","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","outdir","outputOptions","dir","Error","namePrefix","exportsEntries","Object","fromEntries","entries","filter","key","value","map","maxLengthEntry","Math","max","values","v","length","paddingEntry","padEnd","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","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","addBarsByEntries","type","bar","create","update","message","progressState","esm","umd","resolved","watchingProgress","defaultEntry","group","onProcessing","onProcessed","source","importer","writeBundle","bundle","forEach","fileName","watchProgress","e","every","Boolean","setTimeout","stop","input","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","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,YAAa,UAC5DqB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCGA,MAAMC,EAAgBC,EAAgBA,mCAyBd,EAEpBC,UAAS,EACTJ,SACEK,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KASA,MAAQC,MAAMC,UACZA,GAAY,EAAAC,OAC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ElBY,EAAW,IACTkB,EACH9B,KAAM8G,EACNjC,OAAQ,MACR/D,eAAgB,GAAGd,cAGvBe,QAAS,CACP2E,EAAiB,MAAOiB,GACxBpC,EACApB,EACAhC,GAAU4F,EAAAA,QAAQ,CAChBhG,QAAS,CAACiG,EAAAA,SACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGnH,UAEd6G,YACAtF,GAEFhC,WACF,IAEF,IACK+E,EACHqC,MAAOzE,EACPrB,OAAQ,CACN,CACEkB,IAAK,QAEP,CACEA,IAAK,OACLjB,eAAgB,EAAGd,UAAW,GAAGA,EAAKN,QAAQ,SAAU,eACxDkH,iBAAiB,IAGrB7F,QAAS,CACP2E,EAAiB,OACjBnB,EACApD,GAAUrB,EAAK,CAAEK,SAAU,CAAC,cAC5BqB,EAAAA,IAAI,CAAE4F,UAxOgBC,EAwOe,oBAvOpCC,EAAAA,QAAQrG,EAAeoG,MAwOxB,CACErH,KAAM,wCAKN,cAAAuH,CAAe5H,EAAGuG,GAChB,IAAA,MAAWsB,KAAQrF,OAAOU,OAAOqD,GACzB,SAAUsB,IAEXA,EAAAC,KAAOD,EAAKC,KAAK/H,QACpB,iCACA,mBAAmBgC,EAAI1B,SAG7B,GAEFyB,GAEFlC,aA5PN,IAA8B8H,CA8P5B"}
|
1
|
+
{"version":3,"file":"rollup.min.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(/(\\.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 '@jiek/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({ 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 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","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","JIEK_SILENT","JIEK_TARGET","JIEK_ROOT","process","env","ACCEPTED_TARGETS","targets","split","filter","Boolean","t","workspaceRoot","getWorkspaceDir","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","length","Error","jiek","noBrowser","outdir","outputOptions","dir","namePrefix","exportsEntries","Object","fromEntries","entries","key","value","map","maxLengthEntry","Math","max","values","v","paddingEntry","padEnd","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","dep","RegExp","add","reduce","acc","createGlobalsLinkage","cwd","require","peerDependencies","optionalDependencies","keys","concat","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","progressState","forEach","target","type","bar","create","update","message","resolved","watchingProgress","isLast","defaultEntry","group","onProcessing","onProcessed","source","importer","writeBundle","bundle","fileName","watchProgress","e","esm","umd","every","setTimeout","stop","optionsMap","input","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","file","code","flatMap","optsGen","opts","Array","isArray"],"mappings":"8YAAA,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,YAAa,UAC5DqB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCGA,MAAMC,YACJA,EAAAC,YACAA,EAAAC,UACAA,GACEC,QAAQC,IAGNC,EAAmB,CAAC,MAAO,MAAO,OAClCC,GAFSL,GAAe,eAIzBM,MAAM,KACNC,OAAOC,SACPD,QAAOE,GAAKL,EAAiBhB,SAASqB,KAErCC,EAAgBT,GA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A0C,EAAUjB,EAAWzB,GAC3B,QAAgB,IAAZ0C,EACF,MAAM,IAAI9F,MAAM,UAAUoD,sBAC5B,MAAM2C,EAAOD,EAAQ1C,IAAWpE,EAAQA,EAAQe,OAAS,IACrD,OAAAiG,MAAMC,QAAQF,GAAcA,EACzB,CAACA,EAAI,GACb"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
|
-
"version": "0.4.
|
3
|
+
"version": "0.4.4",
|
4
4
|
"description": "YiJie's personal kits.",
|
5
5
|
"bin": {
|
6
6
|
"jiek": "bin/jiek.js",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"micromatch": "^4.0.5",
|
47
47
|
"rollup": "^4.1.5",
|
48
48
|
"rollup-plugin-copy": "^3.5.0",
|
49
|
-
"rollup-plugin-dts": "^6.1.
|
49
|
+
"@jiek/rollup-plugin-dts": "^6.1.1",
|
50
50
|
"rollup-plugin-esbuild": "^6.1.0",
|
51
51
|
"rollup-plugin-postcss": "^4.0.2",
|
52
52
|
"@jiek/pkger": "0.1.9",
|