jiek 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"build.esm.min.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\nimport { tsRegisterName } from '../utils/tsRegister'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('jiek/rollup').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir, { excludeDistInExports: true })\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (tsRegisterName) {\n prefix = `node -r ${tsRegisterName} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} --silent -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n"],"names":["FILE_TEMPLATE","manifest","JSON","stringify","trimStart","program","command","action","async","actionRestore","wd","value","getSelectedProjectsGraph","Object","keys","length","Error","jiekTempDir","paths","path","resolve","fs","existsSync","mkdirSync","rollupBinaryPath","require","replace","i","dir","entries","newManifest","mergePackageJson","excludeDistInExports","escapeManifestName","name","configFile","writeFileSync","prefix","tsRegisterName","childProcess","execSync","cwd","stdio","actionDone"],"mappings":"8YAWA,MAAMA,EAAiBC,GAAsB,iBAC/BC,KAAKC,UAAUF,EAAU,KAAM,wOAQ3CG,YAEFC,EACGC,QAAQ,SACRC,QAAOC,UACQC,IACR,MAAAC,GACJA,EAAAC,MAAIA,EAAQ,CAAC,SACLC,KAA8B,GAExC,GAAkC,IAA9BC,OAAOC,KAAKH,GAAOI,OACf,MAAA,IAAIC,MAAM,oBAEZ,MAAAC,EAAc,IAAIC,IAAoBC,EAAKC,QAAQV,EAAI,wBAAyBQ,GACjFG,EAAGC,WAAWL,MAAmBI,EAAAE,UAAUN,KAEhD,MAAMO,EAAmBC,QAAQL,QAAQ,UACtCM,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYC,EAAK3B,KAAaY,OAAOgB,QAAQlB,GAAQ,CACnD,MAAMmB,EAAcC,EAAiB9B,EAAU2B,EAAK,CAAEI,sBAAsB,IAEtEC,EAAqBhC,EAASiC,MAAMR,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtES,EAAalB,EACjB,GAAGgB,GAAsB,aAAaN,wBAExCN,EAAGe,cAAcD,EAAYnC,EAAc8B,IAC3C,IAAIO,EAAS,GACTC,IACFD,EAAS,WAAWC,MAGtBC,EAAaC,SAAS,GAAGH,IAASb,iBAAgCW,IAAc,CAC9EM,IAAKb,EAAKc,MAAO,WAErB,CAEWC,GAAA"}
1
+ {"version":3,"file":"build.esm.min.js","sources":["../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\nimport { tsRegisterName } from '../utils/tsRegister'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('jiek/rollup').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .option('-t, --target <type>', 'target flow: esm|umd|dts, default esm,umd,dts')\n .option('-s, --silent', 'silent mode')\n .action(async ({ target, silent }) => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir, { excludeDistInExports: true })\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest))\n let prefix = ''\n if (tsRegisterName) {\n prefix = `node -r ${tsRegisterName} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} --silent -c ${configFile}`, {\n cwd: dir, stdio: 'inherit',\n env: {\n JIEK_TARGET: target ?? process.env.JIEK_TARGET ?? 'esm,umd,dts',\n JIEK_SILENT: `${silent}` ?? process.env.JIEK_SILENT,\n JIEK_ROOT: wd\n }\n })\n }\n\n actionDone()\n })\n"],"names":["FILE_TEMPLATE","manifest","JSON","stringify","trimStart","program","command","option","action","async","target","silent","actionRestore","wd","value","getSelectedProjectsGraph","Object","keys","length","Error","jiekTempDir","paths","path","resolve","fs","existsSync","mkdirSync","rollupBinaryPath","require","replace","i","dir","entries","newManifest","mergePackageJson","excludeDistInExports","escapeManifestName","name","configFile","writeFileSync","prefix","tsRegisterName","childProcess","execSync","cwd","stdio","env","JIEK_TARGET","process","JIEK_SILENT","JIEK_ROOT","actionDone"],"mappings":"8YAWA,MAAMA,EAAiBC,GAAsB,iBAC/BC,KAAKC,UAAUF,EAAU,KAAM,wOAQ3CG,YAEFC,EACGC,QAAQ,SACRC,OAAO,sBAAuB,iDAC9BA,OAAO,eAAgB,eACvBC,QAAOC,OAASC,SAAQC,aACTC,IACR,MAAAC,GACJA,EAAAC,MAAIA,EAAQ,CAAC,SACLC,KAA8B,GAExC,GAAkC,IAA9BC,OAAOC,KAAKH,GAAOI,OACf,MAAA,IAAIC,MAAM,oBAEZ,MAAAC,EAAc,IAAIC,IAAoBC,EAAKC,QAAQV,EAAI,wBAAyBQ,GACjFG,EAAGC,WAAWL,MAAmBI,EAAAE,UAAUN,KAEhD,MAAMO,EAAmBC,QAAQL,QAAQ,UACtCM,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYC,EAAK9B,KAAae,OAAOgB,QAAQlB,GAAQ,CACnD,MAAMmB,EAAcC,EAAiBjC,EAAU8B,EAAK,CAAEI,sBAAsB,IAEtEC,EAAqBnC,EAASoC,MAAMR,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtES,EAAalB,EACjB,GAAGgB,GAAsB,aAAaN,wBAExCN,EAAGe,cAAcD,EAAYtC,EAAciC,IAC3C,IAAIO,EAAS,GACTC,IACFD,EAAS,WAAWC,MAGtBC,EAAaC,SAAS,GAAGH,IAASb,iBAAgCW,IAAc,CAC9EM,IAAKb,EAAKc,MAAO,UACjBC,IAAK,CACHC,YAAarC,GAAUsC,QAAQF,IAAIC,aAAe,cAClDE,YAAa,GAAGtC,KAAYqC,QAAQF,IAAIG,YACxCC,UAAWrC,IAGjB,CAEWsC,GAAA"}
package/dist/rollup.cjs CHANGED
@@ -94,7 +94,15 @@ function withMinify(output) {
94
94
  ];
95
95
  }
96
96
 
97
- const workspaceRoot = getWorkspaceDir.getWorkspaceDir();
97
+ const {
98
+ JIEK_SILENT,
99
+ JIEK_TARGET,
100
+ JIEK_ROOT
101
+ } = process.env;
102
+ const target = JIEK_TARGET ?? "esm,umd,dts";
103
+ const ACCEPTED_TARGETS = ["esm", "umd", "dts"];
104
+ const targets = target.split(",").filter(Boolean).filter((t) => ACCEPTED_TARGETS.includes(t));
105
+ const workspaceRoot = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
98
106
  function resolveWorkspacePath(p) {
99
107
  return node_path.resolve(workspaceRoot, p);
100
108
  }
@@ -122,6 +130,8 @@ const template = ({
122
130
  dts: dtsPlugins = []
123
131
  } = {}
124
132
  } = {}, pkg) => {
133
+ if (targets.length === 0)
134
+ throw new Error("no target specified");
125
135
  const { jiek: {
126
136
  noBrowser = false,
127
137
  outdir = "dist"
@@ -161,14 +171,15 @@ const template = ({
161
171
  bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
162
172
  return { ...add, [entry]: bar };
163
173
  }, {});
164
- const progressState = {
165
- esm: addBarsByEntries("esm"),
166
- umd: addBarsByEntries("umd"),
167
- dts: addBarsByEntries("dts")
168
- };
174
+ const progressState = {};
175
+ targets.forEach((target2) => {
176
+ progressState[target2] = addBarsByEntries(target2);
177
+ });
169
178
  const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
170
- const watchingProgress = (type, defaultEntry) => {
179
+ const watchingProgress = (type, isLast = false, defaultEntry) => {
171
180
  const group = progressState[type];
181
+ if (!group)
182
+ throw new Error(`target ${type} found`);
172
183
  return watchProgress(
173
184
  Object.values(exportsEntries),
174
185
  (entry) => {
@@ -193,7 +204,7 @@ const template = ({
193
204
  } else {
194
205
  bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
195
206
  }
196
- if (type === "dts") {
207
+ if (isLast) {
197
208
  resolved[e] = true;
198
209
  if (Object.values(resolved).every(Boolean)) {
199
210
  setTimeout(() => multiBars.stop(), 200);
@@ -202,109 +213,120 @@ const template = ({
202
213
  }
203
214
  );
204
215
  };
205
- return [
206
- {
216
+ const esmOpts = (isLast) => ({
217
+ ...commonOptions,
218
+ input: exportsEntries,
219
+ output: [
220
+ ...withMinify({
221
+ ...outputOptions,
222
+ format: "esm",
223
+ entryFileNames: "[name].esm.js",
224
+ preserveModules: true
225
+ })
226
+ ],
227
+ plugins: [
228
+ watchingProgress("esm", isLast),
229
+ commonPlugins,
230
+ globalsRegister({ external }),
231
+ styled && skip({ patterns: [/\.s?css$/] }),
232
+ esbuild__default.default(),
233
+ indexPlugins
234
+ ]
235
+ });
236
+ const umdOpts = (isLast) => Object.entries(exportsEntries).map(([name, input]) => {
237
+ const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
238
+ return {
207
239
  ...commonOptions,
208
- input: exportsEntries,
209
- output: [
240
+ input,
241
+ output: noBrowser ? [
242
+ ...withMinify({
243
+ ...outputOptions,
244
+ name: outputName,
245
+ format: "cjs",
246
+ entryFileNames: `${name}.cjs`
247
+ })
248
+ ] : [
249
+ ...withMinify({
250
+ ...outputOptions,
251
+ name: outputName,
252
+ format: "iife",
253
+ entryFileNames: `${name}.iife.js`
254
+ }),
210
255
  ...withMinify({
211
256
  ...outputOptions,
212
- format: "esm",
213
- entryFileNames: "[name].esm.js",
214
- preserveModules: true
257
+ name: outputName,
258
+ format: "umd",
259
+ entryFileNames: `${name}.umd.js`
215
260
  })
216
261
  ],
217
262
  plugins: [
218
- watchingProgress("esm"),
263
+ watchingProgress("umd", isLast, input),
219
264
  commonPlugins,
220
- globalsRegister({ external }),
221
- styled && skip({ patterns: [/\.s?css$/] }),
265
+ globalsOutput,
266
+ styled && postcss__default.default({
267
+ plugins: [autoprefixer__default.default],
268
+ minimize: true,
269
+ sourceMap: true,
270
+ extract: `${name}.css`
271
+ }),
222
272
  esbuild__default.default(),
223
- indexPlugins
224
- ]
225
- },
226
- ...Object.entries(exportsEntries).map(([name, input]) => {
227
- const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
228
- return {
229
- ...commonOptions,
230
- input,
231
- output: noBrowser ? [
232
- ...withMinify({
233
- ...outputOptions,
234
- name: outputName,
235
- format: "cjs",
236
- entryFileNames: `${name}.cjs`
237
- })
238
- ] : [
239
- ...withMinify({
240
- ...outputOptions,
241
- name: outputName,
242
- format: "iife",
243
- entryFileNames: `${name}.iife.js`
244
- }),
245
- ...withMinify({
246
- ...outputOptions,
247
- name: outputName,
248
- format: "umd",
249
- entryFileNames: `${name}.umd.js`
250
- })
251
- ],
252
- plugins: [
253
- watchingProgress("umd", input),
254
- commonPlugins,
255
- globalsOutput,
256
- styled && postcss__default.default({
257
- plugins: [autoprefixer__default.default],
258
- minimize: true,
259
- sourceMap: true,
260
- extract: `${name}.css`
261
- }),
262
- esbuild__default.default(),
263
- entryPlugins
264
- ],
265
- external
266
- };
267
- }),
268
- {
269
- ...commonOptions,
270
- input: exportsEntries,
271
- output: [
272
- {
273
- dir: "dist"
274
- },
275
- {
276
- dir: "dist",
277
- entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
278
- preserveModules: true
279
- }
280
- ],
281
- plugins: [
282
- watchingProgress("dts"),
283
- commonPlugins,
284
- styled && skip({ patterns: [/\.s?css$/] }),
285
- rollupPluginDts.dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
286
- {
287
- name: "rollup-plugin-declare-module-replacer",
288
- /**
289
- * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
290
- * in output file generated
291
- */
292
- generateBundle(_, bundle) {
293
- for (const file of Object.values(bundle)) {
294
- if (!("code" in file))
295
- continue;
296
- file.code = file.code.replace(
297
- /declare module ['|"]\..*['|"]/g,
298
- `declare module '${pkg.name}'`
299
- );
300
- }
301
- }
302
- },
303
- dtsPlugins
273
+ entryPlugins
304
274
  ],
305
275
  external
306
- }
307
- ];
276
+ };
277
+ });
278
+ const dtsOpts = (isLast) => ({
279
+ ...commonOptions,
280
+ input: exportsEntries,
281
+ output: [
282
+ {
283
+ dir: "dist"
284
+ },
285
+ {
286
+ dir: "dist",
287
+ entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
288
+ preserveModules: true
289
+ }
290
+ ],
291
+ plugins: [
292
+ watchingProgress("dts", isLast),
293
+ commonPlugins,
294
+ styled && skip({ patterns: [/\.s?css$/] }),
295
+ rollupPluginDts.dts({
296
+ tsconfig: resolveWorkspacePath("tsconfig.dts.json"),
297
+ compilerOptions: { outDir: outdir }
298
+ }),
299
+ {
300
+ name: "rollup-plugin-declare-module-replacer",
301
+ /**
302
+ * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
303
+ * in output file generated
304
+ */
305
+ generateBundle(_, bundle) {
306
+ for (const file of Object.values(bundle)) {
307
+ if (!("code" in file))
308
+ continue;
309
+ file.code = file.code.replace(
310
+ /declare module ['|"]\..*['|"]/g,
311
+ `declare module '${pkg.name}'`
312
+ );
313
+ }
314
+ }
315
+ },
316
+ dtsPlugins
317
+ ],
318
+ external
319
+ });
320
+ const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts };
321
+ return targets.flatMap((target2) => {
322
+ const optsGen = optionsMap[target2];
323
+ if (optsGen === void 0)
324
+ throw new Error(`target ${target2} is not supported`);
325
+ const opts = optsGen(target2 === targets[targets.length - 1]);
326
+ if (Array.isArray(opts))
327
+ return opts;
328
+ return [opts];
329
+ });
308
330
  };
309
331
 
310
332
  exports.template = template;
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.c?js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction watchProgress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n const maxLengthEntry = Math.max(...Object.values(exportsEntries).map(v => v.length))\n function paddingEntry(entry: string) {\n return entry.padEnd(maxLengthEntry)\n }\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const addBarsByEntries = (type: 'esm' | 'umd' | 'dts') => entries\n .reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type, entry: paddingEntry(entry), message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n const progressState = {\n esm: addBarsByEntries('esm'),\n umd: addBarsByEntries('umd'),\n dts: addBarsByEntries('dts')\n }\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n return watchProgress(\n Object.values(exportsEntries),\n entry => {\n const e = defaultEntry ?? entry\n const bar = group[e]\n if (!bar) return\n bar.update(0, { type, entry: paddingEntry(e), message: 'processing' })\n },\n (name, fileName) => {\n const e = defaultEntry ?? exportsEntries[name]\n const bar = group[e]\n if (!bar) return\n const endsReg = {\n esm: /\\.min\\.js$/,\n umd: /\\.min\\.c?js$/,\n dts: /\\.esm\\.d\\.ts$/\n }[type]\n if (!endsReg.test(fileName)) {\n bar.update(95, { type, entry: paddingEntry(e), message: 'processed' })\n } else {\n bar.update(100, { type, entry: paddingEntry(e), message: 'finished' })\n }\n if (type === 'dts') {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n return [\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n watchingProgress('esm'),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n watchingProgress('umd', input),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n watchingProgress('dts'),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["terser","getWorkspaceDir","resolve","json","MultiBar","Presets","entries","esbuild","postcss","autoprefixer","dts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,OAAO,CAAG,EAAA;AAChC,IAAO,OAAA,QAAA,CAAS,MAAM,CAAC,CAAA,CAAA;AAAA,GACzB;AACA,EAAO,OAAA,QAAA,CACJ,QAAQ,aAAe,EAAA,CAAC,GAAG,EAAO,KAAA,EAAA,CAAG,aAAa,CAAA,CAAA;AACvD;;ACJO,SAAS,oBAAuB,GAAA;AACrC,EAAA,IAAI,UAAU,EAAC,CAAA;AACf,EAAA,MAAM,YAAe,mBAAA,IAAI,GAAY,CAAA,EAAE,CAAA,CAAA;AACvC,EAAO,OAAA;AAAA,IACJ,C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AA,MACH,KAAO,EAAA,cAAA;AAAA,MACP,MAAQ,EAAA;AAAA,QACN;AAAA,UACE,GAAK,EAAA,MAAA;AAAA,SACP;AAAA,QACA;AAAA,UACE,GAAK,EAAA,MAAA;AAAA,UACL,cAAA,EAAgB,CAAC,EAAE,IAAK,EAAA,KAAM,GAAG,IAAK,CAAA,OAAA,CAAQ,QAAU,EAAA,EAAE,CAAC,CAAA,SAAA,CAAA;AAAA,UAC3D,eAAiB,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,QACzCG,oBAAI,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.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.c?js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst {\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":["terser","getWorkspaceDir","resolve","json","MultiBar","Presets","target","entries","esbuild","postcss","autoprefixer","dts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,OAAO,CAAG,EAAA;AAChC,IAAO,OAAA,QAAA,CAAS,MAAM,CAAC,CAAA,CAAA;AAAA,GACzB;AACA,EAAO,OAAA,QAAA,CACJ,QAAQ,aAAe,EAAA,CAAC,GAAG,EAAO,KAAA,EAAA,CAAG,aAAa,CAAA,CAAA;AACvD;;ACJO,SAAS,oBAAuB,GAAA;AACrC,EAAA,IAAI,UAAU,EAAC,CAAA;AACf,EAAA,MAAM,YAAe,mBAAA,IAAI,GAAY,CAAA,EAAE,CAAA,CAAA;AACvC,EAAO,OAAA;AAAA,IACJ,CAAC,EAAE,QAAS,EAAA,GAAI,EAAO,KAAA;AACtB,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,SAAA;AAAA,QACN,UAAU,EAAI,EAAA;AACZ,UAAI,IAAA,QAAA,EAAU,IAAK,CAAA,CAAA,GAAA,KAAO,GAAe,YAAA,MAAA,GAAS,GAAI,CAAA,IAAA,CAAK,EAAE,CAAA,GAAI,GAAQ,KAAA,EAAE,CAAG,EAAA;AAC5E,YAAA,YAAA,CAAa,IAAI,EAAE,CAAA,CAAA;AACnB,YAAO,OAAA,EAAE,EAAI,EAAA,QAAA,EAAU,IAAK,EAAA,CAAA;AAAA,WAC9B;AACA,UAAO,OAAA,IAAA,CAAA;AAAA,SACT;AAAA,QACA,cAAc,OAAS,EAAA;AACrB,UAAA,OAAA,GAAU,CAAC,GAAG,YAAY,EAAE,MAAO,CAAA,CAAC,KAAK,KAAW,MAAA;AAAA,YAClD,GAAG,GAAA;AAAA,YACH,CAAC,KAAK,GAAG,cAAA,CAAe,KAAK,CAAA;AAAA,WAC/B,CAAA,EAAI,EAAE,CAAA,CAAA;AAC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F,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,CAAAL,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;;;;"}
@@ -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 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
  }
@@ -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
- esm: addBarsByEntries("esm"),
84
- umd: addBarsByEntries("umd"),
85
- dts: addBarsByEntries("dts")
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 (type === "dts") {
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,120 @@ const template = ({
120
131
  }
121
132
  );
122
133
  };
123
- return [
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: exportsEntries,
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
- format: "esm",
131
- entryFileNames: "[name].esm.js",
132
- preserveModules: true
175
+ name: outputName,
176
+ format: "umd",
177
+ entryFileNames: `${name}.umd.js`
133
178
  })
134
179
  ],
135
180
  plugins: [
136
- watchingProgress("esm"),
181
+ watchingProgress("umd", isLast, input),
137
182
  commonPlugins,
138
- globalsRegister({ external }),
139
- styled && skip({ patterns: [/\.s?css$/] }),
183
+ globalsOutput,
184
+ styled && postcss({
185
+ plugins: [autoprefixer],
186
+ minimize: true,
187
+ sourceMap: true,
188
+ extract: `${name}.css`
189
+ }),
140
190
  esbuild(),
141
- indexPlugins
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({
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
+ });
226
248
  };
227
249
 
228
250
  export { template };