jiek 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.cjs.map +1 -1
- package/dist/rollup.d.ts +2 -3
- package/dist/rollup.esm.d.ts +2 -3
- package/dist/rollup.esm.js +9 -9
- package/dist/rollup.esm.js.map +1 -1
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/package.json +6 -7
package/dist/rollup.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
"use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),r=require("@rollup/plugin-json"),s=require("autoprefixer"),n=require("rollup-plugin-dts"),i=require("rollup-plugin-esbuild"),o=require("rollup-plugin-postcss"),a=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r),p=l(s),c=l(i),d=l(o),m=l(a);function f(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var g=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};function x(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],m.default()]}]}const y=t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:i=[]}={}}={},o)=>{const{jiek:{
|
1
|
+
"use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),r=require("@rollup/plugin-json"),s=require("autoprefixer"),n=require("rollup-plugin-dts"),i=require("rollup-plugin-esbuild"),o=require("rollup-plugin-postcss"),a=require("@rollup/plugin-terser");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r),p=l(s),c=l(i),d=l(o),m=l(a);function f(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var g=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={dir:"dist",exports:"named",interop:"auto",sourcemap:!0};function x(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],m.default()]}]}const y=t.getWorkspaceDir();exports.template=({styled:t=!1,plugins:{index:r=[],entry:s=[],dts:i=[]}={}}={},o)=>{const{jiek:{noBrowser:a=!1}={}}=o;if(!o.name)throw new Error("pkg.name is required");const l=o.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),m=Object.fromEntries(Object.entries(o.exports??{}).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"]]))),[$,b]=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]:f(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:/])}(),q=[u.default()];return[{input:m,output:[...x({...j,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[q,$({external:k}),t&&g({patterns:[/\.s?css$/]}),c.default(),r]},...Object.entries(m).map((([e,r])=>{const n=l+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{input:r,output:a?[...x({...j,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...x({...j,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...x({...j,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[q,b,t&&d.default({plugins:[p.default],minimize:!0,sourceMap:!0,extract:`${e}.css`}),c.default(),s],external:k}})),{input:m,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[q,t&&g({patterns:[/\.s?css$/]}),n.dts({tsconfig:(v="tsconfig.dts.json",e.resolve(y,v))}),{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}'`))}},i],external:k}];var v};
|
2
2
|
//# sourceMappingURL=rollup.cjs.map
|
package/dist/rollup.cjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, 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\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?: {\n browser?: boolean\n }\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n browser = false\n } = {} } = pkg\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 static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\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 input: input,\n output: browser ? [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ] : [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ],\n plugins: [\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 input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\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","dir","exports","interop","sourcemap","withMinify","output","entryFileNames","plugins","terser","workspaceRoot","getWorkspaceDir","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","browser","Error","namePrefix","exportsEntries","Object","fromEntries","entries","filter","key","value","map","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","dep","RegExp","add","outputOptions","reduce","acc","createGlobalsLinkage","cwd","process","require","peerDependencies","optionalDependencies","keys","concat","externalResolver","commonPlugins","json","input","format","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"8WAAA,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,IAAK,OACLC,QAAS,QACTC,QAAS,OACTC,WAAW,GCLb,SAAAC,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBrB,QAAQ,UAAW,UAC1DsB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCCA,MAAMC,EAAgBC,EAAgBA,mCAKd,EAEpBC,UAAS,EACTJ,SACEK,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAWA,MAAQC,MAAMC,QACZA,GAAU,GACR,CAAA,GAAOF,EACP,IAACA,EAAI3B,KACD,MAAA,IAAI8B,MAAM,wBAEZ,MAAAC,EAAaJ,EAChB3B,KACAN,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCmC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQR,EAAIjB,SAAW,CAAA,GAE3B0B,QAAO,EAAEC,MAAU,qBAAqB9B,KAAK8B,KAE7CD,QAAO,EAAI,CAAAE,KAA4B,iBAAVA,GAAsBA,EAAM,cAAgBA,EAAc,SACvFC,KAAI,EAAEF,EAAKC,KAAW,CACrBD,EACG3C,QAAQ,OAAQ,SAChBA,QAAQ,QAAS,IACH,iBAAV4C,E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AGvC,MAAA,CACLkE,QACAjD,OAAQe,EAAU,IACbhB,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,OACRjD,eAAgB,GAAGf,iBAElBa,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,MACRjD,eAAgB,GAAGf,cAEnB,IACCa,EAAW,IACTL,EACHR,KAAMmE,EACNH,OAAQ,MACRjD,eAAgB,GAAGf,WAGvBgB,QAAS,CACP6C,EACApB,EACArB,GAAUgD,EAAAA,QAAQ,CAChBpD,QAAS,CAACqD,EAAAA,SACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGxE,UAEdkE,YACA1C,GAEFjC,WACF,IAEF,CACEwE,MAAO/B,EACPlB,OAAQ,CACN,CACEL,IAAK,OACLM,eAAgB,EAAGf,UAAW,GAAGA,EAAKN,QAAQ,SAAU,eACxDuE,iBAAiB,GAEnB,CACExD,IAAK,SAGTO,QAAS,CACP6C,EACAzC,GAAUtB,EAAK,CAAEK,SAAU,CAAC,cAC5BsB,EAAAA,IAAI,CAAEgD,UA7IgBC,EA6Ie,oBA5IpCC,EAAAA,QAAQzD,EAAewD,MA6IxB,CACE1E,KAAM,wCAKN,cAAA4E,CAAejF,EAAGkF,GAChB,IAAA,MAAWC,KAAQ7C,OAAO8C,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAKtF,QACpB,iCACA,mBAAmBiC,EAAI3B,SAG7B,GAEF0B,GAEFnC,aAjKN,IAA8BmF,CAmK5B"}
|
1
|
+
{"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n dir: 'dist',\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, 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\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 } = {} } = pkg\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 static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\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 input: input,\n output: noBrowser ? [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\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 input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\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","dir","exports","interop","sourcemap","withMinify","output","entryFileNames","plugins","terser","workspaceRoot","getWorkspaceDir","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","Error","namePrefix","exportsEntries","Object","fromEntries","entries","filter","key","value","map","globalsRegister","globalsOutput","globals","dependencies","Set","resolveId","dep","RegExp","add","outputOptions","reduce","acc","createGlobalsLinkage","cwd","process","require","peerDependencies","optionalDependencies","keys","concat","externalResolver","commonPlugins","json","input","format","preserveModules","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"8WAAA,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,IAAK,OACLC,QAAS,QACTC,QAAS,OACTC,WAAW,GCLb,SAAAC,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBrB,QAAQ,UAAW,UAC1DsB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCEA,MAAMC,EAAgBC,EAAgBA,mCAKd,EAEpBC,UAAS,EACTJ,SACEK,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,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,GAChB,IAAA,MAAWC,KAAQ7C,OAAO8C,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAKtF,QACpB,iCACA,mBAAmBiC,EAAI3B,SAG7B,GAEF0B,GAEFnC,aA/JN,IAA8BmF,CAiK5B"}
|
package/dist/rollup.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Options } from '@jiek/pkger';
|
1
2
|
import { InputPluginOption, RollupOptions } from 'rollup';
|
2
3
|
|
3
4
|
declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryPlugins, dts: dtsPlugins } }: {
|
@@ -12,9 +13,7 @@ declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryP
|
|
12
13
|
} | undefined;
|
13
14
|
} | undefined, pkg: {
|
14
15
|
name?: string;
|
15
|
-
jiek?:
|
16
|
-
browser?: boolean;
|
17
|
-
};
|
16
|
+
jiek?: Options;
|
18
17
|
exports?: Record<string, string | {
|
19
18
|
import: string;
|
20
19
|
'inner-src': string;
|
package/dist/rollup.esm.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Options } from '@jiek/pkger';
|
1
2
|
import { InputPluginOption, RollupOptions } from 'rollup';
|
2
3
|
|
3
4
|
declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryPlugins, dts: dtsPlugins } }: {
|
@@ -12,9 +13,7 @@ declare const template: ({ styled, plugins: { index: indexPlugins, entry: entryP
|
|
12
13
|
} | undefined;
|
13
14
|
} | undefined, pkg: {
|
14
15
|
name?: string;
|
15
|
-
jiek?:
|
16
|
-
browser?: boolean;
|
17
|
-
};
|
16
|
+
jiek?: Options;
|
18
17
|
exports?: Record<string, string | {
|
19
18
|
import: string;
|
20
19
|
'inner-src': string;
|
package/dist/rollup.esm.js
CHANGED
@@ -24,7 +24,7 @@ const template = ({
|
|
24
24
|
} = {}
|
25
25
|
} = {}, pkg) => {
|
26
26
|
const { jiek: {
|
27
|
-
|
27
|
+
noBrowser = false
|
28
28
|
} = {} } = pkg;
|
29
29
|
if (!pkg.name) {
|
30
30
|
throw new Error("pkg.name is required");
|
@@ -64,7 +64,14 @@ const template = ({
|
|
64
64
|
const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
|
65
65
|
return {
|
66
66
|
input,
|
67
|
-
output:
|
67
|
+
output: noBrowser ? [
|
68
|
+
...withMinify({
|
69
|
+
...commonOutputOptions,
|
70
|
+
name: outputName,
|
71
|
+
format: "cjs",
|
72
|
+
entryFileNames: `${name}.cjs`
|
73
|
+
})
|
74
|
+
] : [
|
68
75
|
...withMinify({
|
69
76
|
...commonOutputOptions,
|
70
77
|
name: outputName,
|
@@ -77,13 +84,6 @@ const template = ({
|
|
77
84
|
format: "umd",
|
78
85
|
entryFileNames: `${name}.umd.js`
|
79
86
|
})
|
80
|
-
] : [
|
81
|
-
...withMinify({
|
82
|
-
...commonOutputOptions,
|
83
|
-
name: outputName,
|
84
|
-
format: "cjs",
|
85
|
-
entryFileNames: `${name}.cjs`
|
86
|
-
})
|
87
87
|
],
|
88
88
|
plugins: [
|
89
89
|
commonPlugins,
|
package/dist/rollup.esm.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rollup.esm.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, 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\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?:
|
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 type { InputPluginOption, 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\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 } = {} } = pkg\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 static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\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 input: input,\n output: noBrowser ? [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\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 input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\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":[],"mappings":";;;;;;;;;;;;;AAiBA,MAAM,gBAAgB,eAAgB,EAAA,CAAA;AACtC,SAAS,qBAAqB,CAAW,EAAA;AACvC,EAAO,OAAA,OAAA,CAAQ,eAAe,CAAC,CAAA,CAAA;AACjC,CAAA;AAEO,MAAM,WAAW,CACtB;AAAA,EACE,MAAS,GAAA,KAAA;AAAA,EACT,OAAS,EAAA;AAAA,IACP,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB,KAAA,EAAO,eAAe,EAAC;AAAA,IACvB,GAAA,EAAK,aAAa,EAAC;AAAA,MACjB,EAAC;AACP,CAUI,GAAA,IACJ,GAQG,KAAA;AACH,EAAA,MAAM,EAAE,IAAM,EAAA;AAAA,IACZ,SAAY,GAAA,KAAA;AAAA,GACd,GAAI,EAAC,EAAM,GAAA,GAAA,CAAA;AACX,EAAI,IAAA,CAAC,IAAI,IAAM,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,sBAAsB,CAAA,CAAA;AAAA,GACxC;AACA,EAAM,MAAA,UAAA,GAAa,GAChB,CAAA,IAAA,CACA,OAAQ,CAAA,aAAA,EAAe,CAAC,CAAG,EAAA,EAAA,KAAO,EAAG,CAAA,WAAA,EAAa,CAAA,CAAA;AACrD,EAAA,MAAM,iBAAiB,MAAO,CAAA,WAAA;AAAA,IAC5B,OAAO,OAAQ,CAAA,GAAA,CAAI,OAAW,IAAA,EAAE,CAE7B,CAAA,MAAA,CAAO,CAAC,CAAC,GAAG,CAAM,KAAA,CAAC,qBAAqB,IAAK,CAAA,GAAG,CAAC,CAEjD,CAAA,MAAA,CAAO,CAAC,GAAG,KAAK,CAAA,K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K,EAAA,KAAM,GAAG,IAAK,CAAA,OAAA,CAAQ,QAAU,EAAA,EAAE,CAAC,CAAA,SAAA,CAAA;AAAA,UAC3D,eAAiB,EAAA,IAAA;AAAA,SACnB;AAAA,QACA;AAAA,UACE,GAAK,EAAA,MAAA;AAAA,SACP;AAAA,OACF;AAAA,MACA,OAAS,EAAA;AAAA,QACP,aAAA;AAAA,QACA,UAAU,IAAK,CAAA,EAAE,UAAU,CAAC,UAAU,GAAG,CAAA;AAAA,QACzC,IAAI,EAAE,QAAA,EAAU,oBAAqB,CAAA,mBAAmB,GAAG,CAAA;AAAA,QAC3D;AAAA,UACE,IAAM,EAAA,uCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKN,cAAA,CAAe,GAAG,MAAQ,EAAA;AACxB,YAAA,KAAA,MAAW,IAAQ,IAAA,MAAA,CAAO,MAAO,CAAA,MAAM,CAAG,EAAA;AACxC,cAAA,IAAI,EAAE,MAAU,IAAA,IAAA,CAAA;AAAO,gBAAA,SAAA;AAEvB,cAAK,IAAA,CAAA,IAAA,GAAO,KAAK,IAAK,CAAA,OAAA;AAAA,gBACpB,gCAAA;AAAA,gBACA,CAAA,gBAAA,EAAmB,IAAI,IAAI,CAAA,CAAA,CAAA;AAAA,eAC7B,CAAA;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,UAAA;AAAA,OACF;AAAA,MACA,QAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
package/dist/rollup.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"@rollup/plugin-json";import t from"autoprefixer";import{dts as o}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import n from"rollup-plugin-postcss";import{createGlobalsLinkage as p}from"./rollup/plugins/globals.esm.min.js";import l from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as m}from"./rollup/utils/commonOptions.esm.min.js";import u from"./rollup/utils/externalResolver.esm.min.js";import a from"./rollup/utils/withMinify.esm.min.js";const c=r();const f=({styled:r=!1,plugins:{index:f=[],entry:d=[],dts:g=[]}={}}={},j)=>{const{jiek:{
|
1
|
+
import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"@rollup/plugin-json";import t from"autoprefixer";import{dts as o}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import n from"rollup-plugin-postcss";import{createGlobalsLinkage as p}from"./rollup/plugins/globals.esm.min.js";import l from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as m}from"./rollup/utils/commonOptions.esm.min.js";import u from"./rollup/utils/externalResolver.esm.min.js";import a from"./rollup/utils/withMinify.esm.min.js";const c=r();const f=({styled:r=!1,plugins:{index:f=[],entry:d=[],dts:g=[]}={}}={},j)=>{const{jiek:{noBrowser:x=!1}={}}=j;if(!j.name)throw new Error("pkg.name is required");const y=j.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),$=Object.fromEntries(Object.entries(j.exports??{}).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"]]))),[b,w]=p(),k=u(),v=[s()];return[{input:$,output:[...a({...m,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[v,b({external:k}),r&&l({patterns:[/\.s?css$/]}),i(),f]},...Object.entries($).map((([e,s])=>{const o=y+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{input:s,output:x?[...a({...m,name:o,format:"cjs",entryFileNames:`${e}.cjs`})]:[...a({...m,name:o,format:"iife",entryFileNames:`${e}.iife.js`}),...a({...m,name:o,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[v,w,r&&n({plugins:[t],minimize:!0,sourceMap:!0,extract:`${e}.css`}),i(),d],external:k}})),{input:$,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[v,r&&l({patterns:[/\.s?css$/]}),o({tsconfig:(F="tsconfig.dts.json",e(c,F))}),{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 '${j.name}'`))}},g],external:k}];var F};export{f 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 { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, 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\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?:
|
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 type { InputPluginOption, 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\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 } = {} } = pkg\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 static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\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 input: input,\n output: noBrowser ? [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\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 input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\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","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","test","value","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonPlugins","json","input","output","withMinify","commonOutputOptions","format","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","dir","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"0kBAiBA,MAAMA,EAAgBC,IAKf,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KASA,MAAQC,MAAMC,UACZA,GAAY,GACV,CAAA,GAAOF,EACP,IAACA,EAAIG,KACD,MAAA,IAAIC,MAAM,wBAEZ,MAAAC,EAAaL,EAChBG,KACAG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,gBAClCC,EAAiBC,OAAOC,YAC5BD,OAAOE,QAAQb,EAAIc,SAAW,CAAA,GAE3BC,QAAO,EAAEC,MAAU,qBAAqBC,KAAKD,KAE7CD,QAAO,EAAI,CAAAG,KAA4B,iBAAVA,GAAsBA,EAAM,cAAgBA,EAAc,SACvFC,KAAI,EAAEH,EAAKE,KAAW,CACrBF,EACGV,QAAQ,OAAQ,SAChBA,QAAQ,QAAS,IACH,iBAAVY,EAAqBA,EAAQA,EAAM,kBAIzCE,EAAiBC,GAAiBC,IACnCC,EAAWC,IAEXC,EAAgB,CACpBC,KAEK,MAAA,CACL,CACEC,MAAOjB,EACPkB,OAAQ,IACHC,EAAW,IACTC,EACHC,OAAQ,MACRC,eAAgB,gBAChBC,iBAAiB,KAGrBxC,QAAS,CACPgC,EACAL,EAAgB,CAAEG,aAClB/B,GAAU0C,EAAK,CAAEC,SAAU,CAAC,cAC5BC,IACAzC,OAGDgB,OAAOE,QAAQH,GAAgBS,KAAI,EAAEhB,EAAMwB,MAC5C,MAAMU,EAAahC,GACR,UAATF,EAAmB,GACjBA,EAAKG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,iBAGvC,MAAA,CACLkB,QACAC,OAAQ1B,EAAY,IACf2B,EAAW,IACTC,EACH3B,KAAMkC,EACNN,OAAQ,MACRC,eAAgB,GAAG7B,WAEnB,IACC0B,EAAW,IACTC,EACH3B,KAAMkC,EACNN,OAAQ,OACRC,eAAgB,GAAG7B,iBAElB0B,EAAW,IACTC,EACH3B,KAAMkC,EACNN,OAAQ,MACRC,eAAgB,GAAG7B,cAGvBV,QAAS,CACPgC,EACAJ,EACA7B,GAAU8C,EAAQ,CAChB7C,QAAS,CAAC8C,GACVC,UAAU,EACVC,WAAW,EACXC,QAAS,GAAGvC,UAEdiC,IACAvC,GAEF0B,WACF,IAEF,CACEI,MAAOjB,EACPkB,OAAQ,CACN,CACEe,IAAK,OACLX,eAAgB,EAAG7B,UAAW,GAAGA,EAAKG,QAAQ,SAAU,eACxD2B,iBAAiB,GAEnB,CACEU,IAAK,SAGTlD,QAAS,CACPgC,EACAjC,GAAU0C,EAAK,CAAEC,SAAU,CAAC,cAC5BrC,EAAI,CAAE8C,UA3IgBC,EA2Ie,oBA1IpCC,EAAQzD,EAAewD,MA2IxB,CACE1C,KAAM,wCAKN,cAAA4C,CAAexC,EAAGyC,GAChB,IAAA,MAAWC,KAAQtC,OAAOuC,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAK7C,QACpB,iCACA,mBAAmBN,EAAIG,SAG7B,GAEFJ,GAEFwB,aA/JN,IAA8BsB,CAiK5B"}
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.9",
|
4
4
|
"description": "YiJie's personal kits.",
|
5
5
|
"bin": {
|
6
6
|
"jiek": "bin/jiek.js",
|
7
7
|
"jk": "bin/jiek.js"
|
8
8
|
},
|
9
9
|
"jiek": {
|
10
|
-
"
|
10
|
+
"noBrowser": true
|
11
11
|
},
|
12
12
|
"files": [
|
13
13
|
"dist"
|
@@ -17,19 +17,19 @@
|
|
17
17
|
".": {
|
18
18
|
"types": "./dist/index.d.ts",
|
19
19
|
"import": "./dist/index.esm.js",
|
20
|
-
"require": "./dist/index.
|
20
|
+
"require": "./dist/index.cjs",
|
21
21
|
"inner-src": "./src/index.ts"
|
22
22
|
},
|
23
23
|
"./cli": {
|
24
24
|
"types": "./dist/cli.d.ts",
|
25
25
|
"import": "./dist/cli.esm.js",
|
26
|
-
"require": "./dist/cli.
|
26
|
+
"require": "./dist/cli.cjs",
|
27
27
|
"inner-src": "./src/cli.ts"
|
28
28
|
},
|
29
29
|
"./rollup": {
|
30
30
|
"types": "./dist/rollup.d.ts",
|
31
31
|
"import": "./dist/rollup.esm.js",
|
32
|
-
"require": "./dist/rollup.
|
32
|
+
"require": "./dist/rollup.cjs",
|
33
33
|
"inner-src": "./src/rollup/index.ts"
|
34
34
|
}
|
35
35
|
},
|
@@ -68,9 +68,8 @@
|
|
68
68
|
"build": "jiek-dev build"
|
69
69
|
},
|
70
70
|
"types": "./dist/index.d.ts",
|
71
|
-
"main": "./dist/index.
|
71
|
+
"main": "./dist/index.cjs",
|
72
72
|
"module": "./dist/index.esm.js",
|
73
|
-
"browser": "./dist/index.umd.min.js",
|
74
73
|
"typesVersions": {
|
75
74
|
"<5.0": {
|
76
75
|
"*": [
|