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":"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,QAAU,EAAA;AAC1B,MAAA,IAAI,OAAQ,CAAA,QAAA,CAAS,MAAM,CAAA,IAAK,QAAa,KAAA,KAAA,CAAA;AAC3C,QAAA,YAAA,CAAa,MAAM,CAAA,CAAA;AAAA,KACvB;AAAA,IACA,WAAA,CAAY,SAAS,MAAQ,EAAA;AAC3B,MAAO,MAAA,CAAA,OAAA,CAAQ,MAAM,CAAE,CAAA,OAAA,CAAQ,CAAC,CAAC,GAAA,EAAK,KAAK,CAAM,KAAA;AAC/C,QAAA,IAAI,KAAM,CAAA,IAAA,KAAS,KAAa,CAAA,IAAA,EAAE,SAAa,IAAA,KAAA,CAAA;AAAQ,UAAA,OAAA;AACvD,QAAY,WAAA,CAAA,KAAA,CAAM,IAAM,EAAA,KAAA,CAAM,QAAQ,CAAA,CAAA;AAAA,OACvC,CAAA,CAAA;AAAA,KAC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AAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,gBACpB,gCAAA;AAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,eAC7B,CAAA;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"rollup.esm.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst {\n JIEK_SILENT,\n JIEK_TARGET,\n JIEK_ROOT\n} = process.env\nconst silent = JIEK_SILENT === 'true'\nconst target = JIEK_TARGET ?? 'esm,umd,dts'\nconst ACCEPTED_TARGETS = ['esm', 'umd', 'dts']\nconst targets = (\n target\n .split(',')\n .filter(Boolean)\n .filter(t => ACCEPTED_TARGETS.includes(t))\n) as ('esm' | 'umd' | 'dts')[]\nconst workspaceRoot = JIEK_ROOT ?? getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction watchProgress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (targets.length === 0)\n throw new Error('no target specified')\n\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n const maxLengthEntry = Math.max(...Object.values(exportsEntries).map(v => v.length))\n function paddingEntry(entry: string) {\n return entry.padEnd(maxLengthEntry)\n }\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const addBarsByEntries = (type: 'esm' | 'umd' | 'dts') => entries\n .reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type, entry: paddingEntry(entry), message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n const progressState: Partial<Record<'esm' | 'umd' | 'dts', ReturnType<typeof addBarsByEntries>>> = {}\n targets.forEach(target => {\n progressState[target] = addBarsByEntries(target)\n })\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n isLast = false,\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n if (!group) throw new Error(`target ${type} found`)\n return watchProgress(\n Object.values(exportsEntries),\n entry => {\n const e = defaultEntry ?? entry\n const bar = group[e]\n if (!bar) return\n bar.update(0, { type, entry: paddingEntry(e), message: 'processing' })\n },\n (name, fileName) => {\n const e = defaultEntry ?? exportsEntries[name]\n const bar = group[e]\n if (!bar) return\n const endsReg = {\n esm: /\\.min\\.js$/,\n umd: /\\.min\\.c?js$/,\n dts: /\\.esm\\.d\\.ts$/\n }[type]\n if (!endsReg.test(fileName)) {\n bar.update(95, { type, entry: paddingEntry(e), message: 'processed' })\n } else {\n bar.update(100, { type, entry: paddingEntry(e), message: 'finished' })\n }\n if (isLast) {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n const esmOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n watchingProgress('esm', isLast),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n })\n const umdOpts: (isLast: boolean) => RollupOptions[] = isLast => Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n watchingProgress('umd', isLast, input),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n })\n const dtsOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n watchingProgress('dts', isLast),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({\n tsconfig: resolveWorkspacePath('tsconfig.dts.json'),\n compilerOptions: { outDir: outdir }\n }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n })\n const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts }\n return targets.flatMap(target => {\n const optsGen = optionsMap[target as 'esm' | 'umd' | 'dts']\n if (optsGen === undefined)\n throw new Error(`target ${target} is not supported`)\n const opts = optsGen(target === targets[targets.length - 1])\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,IAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;AAAG,MAAO,OAAA,IAAA,CAAA;AAChC,IAAA,OAAO,CAAC,IAAI,CAAA,CAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;"}
@@ -1,2 +1,2 @@
1
- import{resolve as e}from"node:path";import{getWorkspaceDir as s}from"@jiek/utils/getWorkspaceDir";import t from"@rollup/plugin-json";import r from"autoprefixer";import{MultiBar as n,Presets as o}from"cli-progress";import{dts as i}from"rollup-plugin-dts";import m from"rollup-plugin-esbuild";import p from"rollup-plugin-postcss";import{createGlobalsLinkage as l}from"./rollup/plugins/globals.esm.min.js";import a from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as u}from"./rollup/utils/commonOptions.esm.min.js";import c from"./rollup/utils/externalResolver.esm.min.js";import d from"./rollup/utils/withMinify.esm.min.js";const f=s();const g=({styled:s=!1,plugins:{index:g=[],entry:j=[],dts:y=[]}={}}={},$)=>{const{jiek:{noBrowser:b=!1,outdir:v="dist"}={}}=$,x={...u,dir:v};if(!$.name)throw new Error("pkg.name is required");const h=$.name.replace(/[@|/-](\w)/g,((e,s)=>s.toUpperCase())),O=Object.fromEntries(Object.entries($.exports??{}).filter((([e])=>!e.startsWith(`./${v}`)&&!e.startsWith(v))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,s])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof s?s:s["inner-src"]]))),w=Math.max(...Object.values(O).map((e=>e.length)));function N(e){return e.padEnd(w)}const[k,E]=l(),F=c(),M={},B=[t()],C=new n({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},o.shades_classic),W=Object.values(O),U=e=>W.reduce(((s,t)=>{const r=C.create(100,0);return r.update(0,{type:e,entry:N(t),message:"waiting"}),{...s,[t]:r}}),{}),q={esm:U("esm"),umd:U("umd"),dts:U("dts")},z=W.reduce(((e,s)=>({...e,[s]:!1})),{}),D=(e,s)=>{const t=q[e];return function(e,s,t){return{name:"progress",resolveId(t,r){(e.includes(t)||void 0===r)&&s(t)},writeBundle(e,s){Object.entries(s).forEach((([e,s])=>{void 0!==s.name&&"isEntry"in s&&t(s.name,s.fileName)}))}}}(Object.values(O),(r=>{const n=s??r,o=t[n];o&&o.update(0,{type:e,entry:N(n),message:"processing"})}),((r,n)=>{const o=s??O[r],i=t[o];if(!i)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(n)?i.update(100,{type:e,entry:N(o),message:"finished"}):i.update(95,{type:e,entry:N(o),message:"processed"}),"dts"===e&&(z[o]=!0,Object.values(z).every(Boolean)&&setTimeout((()=>C.stop()),200))}))};return[{...M,input:O,output:[...d({...x,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[D("esm"),B,k({external:F}),s&&a({patterns:[/\.s?css$/]}),m(),g]},...Object.entries(O).map((([e,t])=>{const n=h+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,s)=>s.toUpperCase())));return{...M,input:t,output:b?[...d({...x,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...d({...x,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...d({...x,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[D("umd",t),B,E,s&&p({plugins:[r],minimize:!0,sourceMap:!0,extract:`${e}.css`}),m(),j],external:F}})),{...M,input:O,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[D("dts"),B,s&&a({patterns:[/\.s?css$/]}),i({tsconfig:(I="tsconfig.dts.json",e(f,I))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,s){for(const e of Object.values(s))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${$.name}'`))}},y],external:F}];var I};export{g as template};
1
+ import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import t from"@rollup/plugin-json";import s from"autoprefixer";import{MultiBar as o,Presets as n}from"cli-progress";import{dts as i}from"rollup-plugin-dts";import m from"rollup-plugin-esbuild";import p from"rollup-plugin-postcss";import{createGlobalsLinkage as l}from"./rollup/plugins/globals.esm.min.js";import a from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as u}from"./rollup/utils/commonOptions.esm.min.js";import c from"./rollup/utils/externalResolver.esm.min.js";import d from"./rollup/utils/withMinify.esm.min.js";const{JIEK_SILENT:f,JIEK_TARGET:g,JIEK_ROOT:j}=process.env,y=["esm","umd","dts"],h=(g??"esm,umd,dts").split(",").filter(Boolean).filter((e=>y.includes(e))),v=j??r();const $=({styled:r=!1,plugins:{index:f=[],entry:g=[],dts:j=[]}={}}={},y)=>{if(0===h.length)throw new Error("no target specified");const{jiek:{noBrowser:$=!1,outdir:w="dist"}={}}=y,E={...u,dir:w};if(!y.name)throw new Error("pkg.name is required");const O=y.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),b=Object.fromEntries(Object.entries(y.exports??{}).filter((([e])=>!e.startsWith(`./${w}`)&&!e.startsWith(w))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,r])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof r?r:r["inner-src"]]))),x=Math.max(...Object.values(b).map((e=>e.length)));function N(e){return e.padEnd(x)}const[M,k]=l(),B=c(),F={},I=[t()],T=new o({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},n.shades_classic),C=Object.values(b),_={};h.forEach((e=>{var r;_[e]=(r=e,C.reduce(((e,t)=>{const s=T.create(100,0);return s.update(0,{type:r,entry:N(t),message:"waiting"}),{...e,[t]:s}}),{}))}));const A=C.reduce(((e,r)=>({...e,[r]:!1})),{}),J=(e,r=!1,t)=>{const s=_[e];if(!s)throw new Error(`target ${e} found`);return function(e,r,t){return{name:"progress",resolveId(t,s){(e.includes(t)||void 0===s)&&r(t)},writeBundle(e,r){Object.entries(r).forEach((([e,r])=>{void 0!==r.name&&"isEntry"in r&&t(r.name,r.fileName)}))}}}(Object.values(b),(r=>{const o=t??r,n=s[o];n&&n.update(0,{type:e,entry:N(o),message:"processing"})}),((o,n)=>{const i=t??b[o],m=s[i];if(!m)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(n)?m.update(100,{type:e,entry:N(i),message:"finished"}):m.update(95,{type:e,entry:N(i),message:"processed"}),r&&(A[i]=!0,Object.values(A).every(Boolean)&&setTimeout((()=>T.stop()),200))}))},K={esm:e=>({...F,input:b,output:[...d({...E,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[J("esm",e),I,M({external:B}),r&&a({patterns:[/\.s?css$/]}),m(),f]}),umd:e=>Object.entries(b).map((([t,o])=>{const n=O+("index"===t?"":t.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{...F,input:o,output:$?[...d({...E,name:n,format:"cjs",entryFileNames:`${t}.cjs`})]:[...d({...E,name:n,format:"iife",entryFileNames:`${t}.iife.js`}),...d({...E,name:n,format:"umd",entryFileNames:`${t}.umd.js`})],plugins:[J("umd",e,o),I,k,r&&p({plugins:[s],minimize:!0,sourceMap:!0,extract:`${t}.css`}),m(),g],external:B}})),dts:t=>{return{...F,input:b,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[J("dts",t),I,r&&a({patterns:[/\.s?css$/]}),i({tsconfig:(s="tsconfig.dts.json",e(v,s)),compilerOptions:{outDir:w}}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,r){for(const e of Object.values(r))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${y.name}'`))}},j],external:B};var s}};return h.flatMap((e=>{const r=K[e];if(void 0===r)throw new Error(`target ${e} is not supported`);const t=r(e===h[h.length-1]);return Array.isArray(t)?t:[t]}))};export{$ as template};
2
2
  //# sourceMappingURL=rollup.esm.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { 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,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ollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst {\n JIEK_SILENT,\n JIEK_TARGET,\n JIEK_ROOT\n} = process.env\nconst silent = JIEK_SILENT === 'true'\nconst target = JIEK_TARGET ?? 'esm,umd,dts'\nconst ACCEPTED_TARGETS = ['esm', 'umd', 'dts']\nconst targets = (\n target\n .split(',')\n .filter(Boolean)\n .filter(t => ACCEPTED_TARGETS.includes(t))\n) as ('esm' | 'umd' | 'dts')[]\nconst workspaceRoot = JIEK_ROOT ?? getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction watchProgress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (targets.length === 0)\n throw new Error('no target specified')\n\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n const maxLengthEntry = Math.max(...Object.values(exportsEntries).map(v => v.length))\n function paddingEntry(entry: string) {\n return entry.padEnd(maxLengthEntry)\n }\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const addBarsByEntries = (type: 'esm' | 'umd' | 'dts') => entries\n .reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type, entry: paddingEntry(entry), message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n const progressState: Partial<Record<'esm' | 'umd' | 'dts', ReturnType<typeof addBarsByEntries>>> = {}\n targets.forEach(target => {\n progressState[target] = addBarsByEntries(target)\n })\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n isLast = false,\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n if (!group) throw new Error(`target ${type} found`)\n return watchProgress(\n Object.values(exportsEntries),\n entry => {\n const e = defaultEntry ?? entry\n const bar = group[e]\n if (!bar) return\n bar.update(0, { type, entry: paddingEntry(e), message: 'processing' })\n },\n (name, fileName) => {\n const e = defaultEntry ?? exportsEntries[name]\n const bar = group[e]\n if (!bar) return\n const endsReg = {\n esm: /\\.min\\.js$/,\n umd: /\\.min\\.c?js$/,\n dts: /\\.esm\\.d\\.ts$/\n }[type]\n if (!endsReg.test(fileName)) {\n bar.update(95, { type, entry: paddingEntry(e), message: 'processed' })\n } else {\n bar.update(100, { type, entry: paddingEntry(e), message: 'finished' })\n }\n if (isLast) {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n const esmOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n watchingProgress('esm', isLast),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n })\n const umdOpts: (isLast: boolean) => RollupOptions[] = isLast => Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n watchingProgress('umd', isLast, input),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n })\n const dtsOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n watchingProgress('dts', isLast),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({\n tsconfig: resolveWorkspacePath('tsconfig.dts.json'),\n compilerOptions: { outDir: outdir }\n }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n })\n const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts }\n return targets.flatMap(target => {\n const optsGen = optionsMap[target as 'esm' | 'umd' | 'dts']\n if (optsGen === undefined)\n throw new Error(`target ${target} is not supported`)\n const opts = optsGen(target === targets[targets.length - 1])\n if (Array.isArray(opts)) return opts\n return [opts]\n })\n}\n"],"names":["JIEK_SILENT","JIEK_TARGET","JIEK_ROOT","process","env","ACCEPTED_TARGETS","targets","split","filter","Boolean","t","includes","workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","length","Error","jiek","noBrowser","outdir","outputOptions","commonOutputOptions","dir","name","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","key","startsWith","test","value","map","maxLengthEntry","Math","max","values","v","paddingEntry","padEnd","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","progressState","forEach","target","type","reduce","add","bar","create","update","message","resolved","watchingProgress","isLast","defaultEntry","group","onProcessing","onProcessed","resolveId","source","importer","writeBundle","options","bundle","fileName","watchProgress","e","esm","umd","every","setTimeout","stop","optionsMap","input","output","withMinify","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","compilerOptions","outDir","generateBundle","file","code","flatMap","optsGen","opts","Array","isArray"],"mappings":"+nBAkBA,MAAMA,YACJA,EAAAC,YACAA,EAAAC,UACAA,GACEC,QAAQC,IAGNC,EAAmB,CAAC,MAAO,MAAO,OAClCC,GAFSL,GAAe,eAIzBM,MAAM,KACNC,OAAOC,SACPD,QAAOE,GAAKL,EAAiBM,SAASD,KAErCE,EAAgBV,GAAaW,IAyB5B,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KASA,GAAuB,IAAnBjB,EAAQkB,OACJ,MAAA,IAAIC,MAAM,uBAElB,MAAQC,MAAMC,UACZA,GAAY,EAAAC,OACZA,EAAS,QACP,CAAA,GAAOL,EACLM,EAAgB,IACjBC,EACHC,IAAKH,GAEH,IAACL,EAAIS,KACD,MAAA,IAAIP,MAAM,wBAEZ,MAAAQ,EAAaV,EAChBS,KACAE,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQlB,EAAImB,SAAW,CAAA,GAE3BlC,QAAO,EAAEmC,MAAUA,EAAIC,WAAW,KAAKhB,OAAce,EAAIC,WAAWhB,KA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B,OAAS,IACrD,OAAAuG,MAAMC,QAAQF,GAAcA,EACzB,CAACA,EAAI,GACb"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),s=require("@rollup/plugin-json"),r=require("autoprefixer"),n=require("cli-progress"),i=require("rollup-plugin-dts"),a=require("rollup-plugin-esbuild"),o=require("rollup-plugin-postcss"),u=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var c=l(s),p=l(r),d=l(a),m=l(o),g=l(u);function f(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var j=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const y={exports:"named",interop:"auto",sourcemap:!0};function $(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.c?js)$/,".min$1"),plugins:[...e.plugins??[],g.default()]}]}const b=t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:s=[],entry:r=[],dts:a=[]}={}}={},o)=>{const{jiek:{noBrowser:u=!1,outdir:l="dist"}={}}=o,g={...y,dir:l};if(!o.name)throw new Error("pkg.name is required");const v=o.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),x=Object.fromEntries(Object.entries(o.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"]]))),O=Math.max(...Object.values(x).map((e=>e.length)));function w(e){return e.padEnd(O)}const[h,q]=function(){let e={};const t=new Set([]);return[({external:s}={})=>({name:"globals",resolveId:e=>s?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:s=>(e=[...t].reduce(((e,t)=>({...e,[t]:f(t)})),{}),{...s,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),k=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:s={},peerDependencies:r={},optionalDependencies:n={}}=t;return Object.keys(s).concat(Object.keys(r)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),N={},E=[c.default()],F=new n.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},n.Presets.shades_classic),M=Object.values(x),B=e=>M.reduce(((t,s)=>{const r=F.create(100,0);return r.update(0,{type:e,entry:w(s),message:"waiting"}),{...t,[s]:r}}),{}),C={esm:B("esm"),umd:B("umd"),dts:B("dts")},W=M.reduce(((e,t)=>({...e,[t]:!1})),{}),D=(e,t)=>{const s=C[e];return function(e,t,s){return{name:"progress",resolveId(s,r){(e.includes(s)||void 0===r)&&t(s)},writeBundle(e,t){Object.entries(t).forEach((([e,t])=>{void 0!==t.name&&"isEntry"in t&&s(t.name,t.fileName)}))}}}(Object.values(x),(r=>{const n=t??r,i=s[n];i&&i.update(0,{type:e,entry:w(n),message:"processing"})}),((r,n)=>{const i=t??x[r],a=s[i];if(!a)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(n)?a.update(100,{type:e,entry:w(i),message:"finished"}):a.update(95,{type:e,entry:w(i),message:"processed"}),"dts"===e&&(W[i]=!0,Object.values(W).every(Boolean)&&setTimeout((()=>F.stop()),200))}))};return[{...N,input:x,output:[...$({...g,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[D("esm"),E,h({external:k}),t&&j({patterns:[/\.s?css$/]}),d.default(),s]},...Object.entries(x).map((([e,s])=>{const n=v+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{...N,input:s,output:u?[...$({...g,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...$({...g,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...$({...g,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[D("umd",s),E,q,t&&m.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${e}.css`}),d.default(),r],external:k}})),{...N,input:x,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[D("dts"),E,t&&j({patterns:[/\.s?css$/]}),i.dts({tsconfig:(U="tsconfig.dts.json",e.resolve(b,U))}),{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 '${o.name}'`))}},a],external:k}];var U};
1
+ "use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),r=require("@rollup/plugin-json"),s=require("autoprefixer"),n=require("cli-progress"),i=require("rollup-plugin-dts"),o=require("rollup-plugin-esbuild"),a=require("rollup-plugin-postcss"),u=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var c=l(r),p=l(s),d=l(o),m=l(a),f=l(u);function g(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var y=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={exports:"named",interop:"auto",sourcemap:!0};function $(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.c?js)$/,".min$1"),plugins:[...e.plugins??[],f.default()]}]}const{JIEK_SILENT:v,JIEK_TARGET:b,JIEK_ROOT:w}=process.env,O=["esm","umd","dts"],h=(b??"esm,umd,dts").split(",").filter(Boolean).filter((e=>O.includes(e))),x=w??t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:o=[]}={}}={},a)=>{if(0===h.length)throw new Error("no target specified");const{jiek:{noBrowser:u=!1,outdir:l="dist"}={}}=a,f={...j,dir:l};if(!a.name)throw new Error("pkg.name is required");const v=a.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),b=Object.fromEntries(Object.entries(a.exports??{}).filter((([e])=>!e.startsWith(`./${l}`)&&!e.startsWith(l))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,t])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof t?t:t["inner-src"]]))),w=Math.max(...Object.values(b).map((e=>e.length)));function O(e){return e.padEnd(w)}const[E,q]=function(){let e={};const t=new Set([]);return[({external:r}={})=>({name:"globals",resolveId:e=>r?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:r=>(e=[...t].reduce(((e,t)=>({...e,[t]:g(t)})),{}),{...r,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),k=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:r={},peerDependencies:s={},optionalDependencies:n={}}=t;return Object.keys(r).concat(Object.keys(s)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),N={},F=[c.default()],M=new n.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},n.Presets.shades_classic),B=Object.values(b),I={};h.forEach((e=>{var t;I[e]=(t=e,B.reduce(((e,r)=>{const s=M.create(100,0);return s.update(0,{type:t,entry:O(r),message:"waiting"}),{...e,[r]:s}}),{}))}));const _=B.reduce(((e,t)=>({...e,[t]:!1})),{}),C=(e,t=!1,r)=>{const s=I[e];if(!s)throw new Error(`target ${e} found`);return function(e,t,r){return{name:"progress",resolveId(r,s){(e.includes(r)||void 0===s)&&t(r)},writeBundle(e,t){Object.entries(t).forEach((([e,t])=>{void 0!==t.name&&"isEntry"in t&&r(t.name,t.fileName)}))}}}(Object.values(b),(t=>{const n=r??t,i=s[n];i&&i.update(0,{type:e,entry:O(n),message:"processing"})}),((n,i)=>{const o=r??b[n],a=s[o];if(!a)return;({esm:/\.min\.js$/,umd:/\.min\.c?js$/,dts:/\.esm\.d\.ts$/})[e].test(i)?a.update(100,{type:e,entry:O(o),message:"finished"}):a.update(95,{type:e,entry:O(o),message:"processed"}),t&&(_[o]=!0,Object.values(_).every(Boolean)&&setTimeout((()=>M.stop()),200))}))},D={esm:e=>({...N,input:b,output:[...$({...f,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[C("esm",e),F,E({external:k}),t&&y({patterns:[/\.s?css$/]}),d.default(),r]}),umd:e=>Object.entries(b).map((([r,n])=>{const i=v+("index"===r?"":r.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{...N,input:n,output:u?[...$({...f,name:i,format:"cjs",entryFileNames:`${r}.cjs`})]:[...$({...f,name:i,format:"iife",entryFileNames:`${r}.iife.js`}),...$({...f,name:i,format:"umd",entryFileNames:`${r}.umd.js`})],plugins:[C("umd",e,n),F,q,t&&m.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${r}.css`}),d.default(),s],external:k}})),dts:r=>{return{...N,input:b,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[C("dts",r),F,t&&y({patterns:[/\.s?css$/]}),i.dts({tsconfig:(s="tsconfig.dts.json",e.resolve(x,s)),compilerOptions:{outDir:l}}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,t){for(const e of Object.values(t))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${a.name}'`))}},o],external:k};var s}};return h.flatMap((e=>{const t=D[e];if(void 0===t)throw new Error(`target ${e} is not supported`);const r=t(e===h[h.length-1]);return Array.isArray(r)?r:[r]}))};
2
2
  //# sourceMappingURL=rollup.min.cjs.map
@@ -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,OACZA,EAAS,QACP,CAAA,GAAOH,EACLI,EAAgB,IACjBtB,EACHuB,IAAKF,GAEH,IAACH,EAAI1B,KACD,MAAA,IAAIgC,MAAM,wBAEZ,MAAAC,EAAaP,EAChB1B,KACAN,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCqC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQX,EAAIjB,SAAW,CAAA,GAE3B6B,QAAO,EAAEC,MAAUA,EAAI/C,WAAW,KAAKqC,OAAcU,EAAI/C,WAAWqC,KAEpES,QAAO,EAAEC,MAAU,qBAAqBhC,KAAKgC,KAE7CD,QAAO,EAAC,CAAGE,KAA4B,iBAAVA,GAAsB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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 '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","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","compilerOptions","outDir","generateBundle","file","code","flatMap","optsGen","opts","Array","isArray"],"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,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,GAAaU,EAAAA,mCAyBX,EAEpBC,UAAS,EACTf,SACEgB,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KASA,GAAuB,IAAnBd,EAAQe,OACJ,MAAA,IAAIC,MAAM,uBAElB,MAAQC,MAAMC,UACZA,GAAY,EAAAC,OACZA,EAAS,QACP,CAAA,GAAOL,EACLM,EAAgB,IACjBnC,EACHoC,IAAKF,GAEH,IAACL,EAAIrC,KACD,MAAA,IAAIuC,MAAM,wBAEZ,MAAAM,EAAaR,EAChBrC,KACAN,QAAQ,eAAe,CAACC,EAA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AQ,MACRxE,eAAgB,GAAGd,cAGvBe,QAAS,CACPmF,EAAiB,MAAOC,EAAQkB,GAChCrC,EACAnB,EACA/B,GAAU2F,EAAAA,QAAQ,CAChB1G,QAAS,CAAC2G,EAAAA,SACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAG7H,UAEduH,YACArF,GAEF3C,WACF,IA4C+C4C,IA1CcgE,IAAA,UAC1DpB,EACHsC,MAAOvE,EACPjC,OAAQ,CACN,CACE+B,IAAK,QAEP,CACEA,IAAK,OACL9B,eAAgB,EAAGd,UAAW,GAAGA,EAAKN,QAAQ,SAAU,eACxD4H,iBAAiB,IAGrBvG,QAAS,CACPmF,EAAiB,MAAOC,GACxBnB,EACAlD,GAAUhC,EAAK,CAAEK,SAAU,CAAC,cAC5BgC,MAAI,CACF2F,UA5OsBC,EA4OS,oBA3O9BC,EAAAA,QAAQpG,EAAemG,IA4OxBE,gBAAiB,CAAEC,OAAQxF,KAE7B,CACE1C,KAAM,wCAKN,cAAAmI,CAAexI,EAAGgH,GAChB,IAAA,MAAWyB,KAAQrF,OAAOS,OAAOmD,GACzB,SAAUyB,IAEXA,EAAAC,KAAOD,EAAKC,KAAK3I,QACpB,iCACA,mBAAmB2C,EAAIrC,SAG7B,GAEFoC,GAEF7C,YAlQJ,IAA8BwI,CAmQ5B,GAEO,OAAAxG,EAAQ+G,SAAQ3C,IACf,MAAA4C,EAAUnB,EAAWzB,GAC3B,QAAgB,IAAZ4C,EACF,MAAM,IAAIhG,MAAM,UAAUoD,sBAC5B,MAAM6C,EAAOD,EAAQ5C,IAAWpE,EAAQA,EAAQe,OAAS,IACrD,OAAAmG,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.2",
3
+ "version": "0.4.3",
4
4
  "description": "YiJie's personal kits.",
5
5
  "bin": {
6
6
  "jiek": "bin/jiek.js",