jiek 0.4.7 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. package/README.md +22 -1
  2. package/bin/jiek.js +9 -5
  3. package/dist/cli.cjs +4703 -362
  4. package/dist/cli.d.cts +112 -0
  5. package/dist/cli.d.ts +111 -1
  6. package/dist/cli.js +5010 -0
  7. package/dist/cli.min.cjs +19 -2
  8. package/dist/cli.min.js +19 -0
  9. package/dist/index.cjs +0 -1
  10. package/dist/index.d.cts +73 -0
  11. package/dist/index.d.ts +62 -46
  12. package/dist/{index.esm.js → index.js} +0 -1
  13. package/dist/index.min.cjs +0 -1
  14. package/dist/index.min.js +1 -0
  15. package/dist/rollup/index.cjs +4688 -0
  16. package/dist/rollup/index.d.cts +53 -0
  17. package/dist/rollup/index.d.ts +53 -0
  18. package/dist/rollup/index.js +4673 -0
  19. package/dist/rollup/index.min.cjs +19 -0
  20. package/dist/rollup/index.min.js +19 -0
  21. package/package.json +42 -33
  22. package/src/cli.ts +9 -0
  23. package/src/commands/base.ts +8 -0
  24. package/src/commands/build.ts +158 -0
  25. package/src/commands/init.ts +373 -0
  26. package/src/commands/publish.ts +170 -0
  27. package/src/index.ts +8 -0
  28. package/src/inner.ts +11 -0
  29. package/src/merge-package-json.ts +75 -0
  30. package/src/rollup/base.ts +72 -0
  31. package/src/rollup/index.ts +422 -0
  32. package/src/rollup/plugins/globals.ts +34 -0
  33. package/src/rollup/plugins/progress.ts +26 -0
  34. package/src/rollup/plugins/skip.ts +23 -0
  35. package/src/rollup/utils/commonOptions.ts +9 -0
  36. package/src/rollup/utils/externalResolver.ts +21 -0
  37. package/src/rollup/utils/globalResolver.ts +13 -0
  38. package/src/rollup/utils/withMinify.ts +18 -0
  39. package/src/utils/filterSupport.ts +84 -0
  40. package/src/utils/getExports.ts +104 -0
  41. package/src/utils/getRoot.ts +16 -0
  42. package/src/utils/getWD.ts +31 -0
  43. package/src/utils/loadConfig.ts +93 -0
  44. package/src/utils/tsRegister.ts +26 -0
  45. package/dist/base.esm.d.ts +0 -55
  46. package/dist/cli.cjs.map +0 -1
  47. package/dist/cli.esm.d.ts +0 -2
  48. package/dist/cli.esm.js +0 -9
  49. package/dist/cli.esm.js.map +0 -1
  50. package/dist/cli.esm.min.js +0 -2
  51. package/dist/cli.esm.min.js.map +0 -1
  52. package/dist/cli.min.cjs.map +0 -1
  53. package/dist/commands/base.esm.js +0 -5
  54. package/dist/commands/base.esm.js.map +0 -1
  55. package/dist/commands/base.esm.min.js +0 -2
  56. package/dist/commands/base.esm.min.js.map +0 -1
  57. package/dist/commands/build.esm.js +0 -58
  58. package/dist/commands/build.esm.js.map +0 -1
  59. package/dist/commands/build.esm.min.js +0 -2
  60. package/dist/commands/build.esm.min.js.map +0 -1
  61. package/dist/commands/init.esm.js +0 -271
  62. package/dist/commands/init.esm.js.map +0 -1
  63. package/dist/commands/init.esm.min.js +0 -2
  64. package/dist/commands/init.esm.min.js.map +0 -1
  65. package/dist/commands/publish.esm.js +0 -87
  66. package/dist/commands/publish.esm.js.map +0 -1
  67. package/dist/commands/publish.esm.min.js +0 -2
  68. package/dist/commands/publish.esm.min.js.map +0 -1
  69. package/dist/index.cjs.map +0 -1
  70. package/dist/index.esm.d.ts +0 -6
  71. package/dist/index.esm.js.map +0 -1
  72. package/dist/index.esm.min.js +0 -2
  73. package/dist/index.esm.min.js.map +0 -1
  74. package/dist/index.min.cjs.map +0 -1
  75. package/dist/inner.esm.js +0 -10
  76. package/dist/inner.esm.js.map +0 -1
  77. package/dist/inner.esm.min.js +0 -2
  78. package/dist/inner.esm.min.js.map +0 -1
  79. package/dist/merge-package-json.esm.js +0 -64
  80. package/dist/merge-package-json.esm.js.map +0 -1
  81. package/dist/merge-package-json.esm.min.js +0 -2
  82. package/dist/merge-package-json.esm.min.js.map +0 -1
  83. package/dist/pkg.esm.js +0 -4
  84. package/dist/pkg.esm.js.map +0 -1
  85. package/dist/pkg.esm.min.js +0 -2
  86. package/dist/pkg.esm.min.js.map +0 -1
  87. package/dist/rollup/plugins/globals.esm.js +0 -31
  88. package/dist/rollup/plugins/globals.esm.js.map +0 -1
  89. package/dist/rollup/plugins/globals.esm.min.js +0 -2
  90. package/dist/rollup/plugins/globals.esm.min.js.map +0 -1
  91. package/dist/rollup/plugins/skip.esm.js +0 -16
  92. package/dist/rollup/plugins/skip.esm.js.map +0 -1
  93. package/dist/rollup/plugins/skip.esm.min.js +0 -2
  94. package/dist/rollup/plugins/skip.esm.min.js.map +0 -1
  95. package/dist/rollup/utils/commonOptions.esm.js +0 -9
  96. package/dist/rollup/utils/commonOptions.esm.js.map +0 -1
  97. package/dist/rollup/utils/commonOptions.esm.min.js +0 -2
  98. package/dist/rollup/utils/commonOptions.esm.min.js.map +0 -1
  99. package/dist/rollup/utils/externalResolver.esm.js +0 -12
  100. package/dist/rollup/utils/externalResolver.esm.js.map +0 -1
  101. package/dist/rollup/utils/externalResolver.esm.min.js +0 -2
  102. package/dist/rollup/utils/externalResolver.esm.min.js.map +0 -1
  103. package/dist/rollup/utils/globalResolver.esm.js +0 -9
  104. package/dist/rollup/utils/globalResolver.esm.js.map +0 -1
  105. package/dist/rollup/utils/globalResolver.esm.min.js +0 -2
  106. package/dist/rollup/utils/globalResolver.esm.min.js.map +0 -1
  107. package/dist/rollup/utils/withMinify.esm.js +0 -15
  108. package/dist/rollup/utils/withMinify.esm.js.map +0 -1
  109. package/dist/rollup/utils/withMinify.esm.min.js +0 -2
  110. package/dist/rollup/utils/withMinify.esm.min.js.map +0 -1
  111. package/dist/rollup.cjs +0 -330
  112. package/dist/rollup.cjs.map +0 -1
  113. package/dist/rollup.d.ts +0 -23
  114. package/dist/rollup.esm.d.ts +0 -23
  115. package/dist/rollup.esm.js +0 -248
  116. package/dist/rollup.esm.js.map +0 -1
  117. package/dist/rollup.esm.min.js +0 -2
  118. package/dist/rollup.esm.min.js.map +0 -1
  119. package/dist/rollup.min.cjs +0 -2
  120. package/dist/rollup.min.cjs.map +0 -1
  121. package/dist/utils/commondir.esm.js +0 -25
  122. package/dist/utils/commondir.esm.js.map +0 -1
  123. package/dist/utils/commondir.esm.min.js +0 -2
  124. package/dist/utils/commondir.esm.min.js.map +0 -1
  125. package/dist/utils/filterSupport.esm.js +0 -67
  126. package/dist/utils/filterSupport.esm.js.map +0 -1
  127. package/dist/utils/filterSupport.esm.min.js +0 -2
  128. package/dist/utils/filterSupport.esm.min.js.map +0 -1
  129. package/dist/utils/getRoot.esm.js +0 -14
  130. package/dist/utils/getRoot.esm.js.map +0 -1
  131. package/dist/utils/getRoot.esm.min.js +0 -2
  132. package/dist/utils/getRoot.esm.min.js.map +0 -1
  133. package/dist/utils/getWD.esm.js +0 -31
  134. package/dist/utils/getWD.esm.js.map +0 -1
  135. package/dist/utils/getWD.esm.min.js +0 -2
  136. package/dist/utils/getWD.esm.min.js.map +0 -1
  137. package/dist/utils/loadConfig.esm.js +0 -75
  138. package/dist/utils/loadConfig.esm.js.map +0 -1
  139. package/dist/utils/loadConfig.esm.min.js +0 -2
  140. package/dist/utils/loadConfig.esm.min.js.map +0 -1
  141. package/dist/utils/tsRegister.esm.js +0 -24
  142. package/dist/utils/tsRegister.esm.js.map +0 -1
  143. package/dist/utils/tsRegister.esm.min.js +0 -2
  144. package/dist/utils/tsRegister.esm.min.js.map +0 -1
@@ -1,64 +0,0 @@
1
- import path from 'node:path';
2
- import { pkger } from '@jiek/pkger';
3
- import { commondir } from './utils/commondir.esm.js';
4
-
5
- function mergePackageJson(manifest, cwd, options = {}) {
6
- const {
7
- excludeDistInExports = false
8
- } = options;
9
- const {
10
- jiek: { cwd: _, ...jiek } = {}
11
- } = manifest;
12
- const { outdir = "dist" } = jiek;
13
- let { exports } = manifest;
14
- let includeIndex = false;
15
- if (typeof exports === "string") {
16
- includeIndex = true;
17
- exports = { ".": exports };
18
- }
19
- if (exports === void 0) {
20
- exports = { ".": "./src/index.ts" };
21
- }
22
- if (typeof exports === "object") {
23
- if (Array.isArray(exports) && exports.length > 0) {
24
- includeIndex = true;
25
- } else {
26
- includeIndex = !!exports["."];
27
- }
28
- }
29
- let inputs = Array.isArray(exports) ? exports : Object.entries(exports).reduce((acc, [key, value]) => {
30
- if (typeof value === "string")
31
- return key === "." ? [value, ...acc] : acc.concat(value);
32
- if (Array.isArray(value))
33
- return acc.concat(value);
34
- throw new TypeError(`Unexpected value type for key "${key}" in exports, expected string, got ${typeof value}`);
35
- }, []);
36
- if (excludeDistInExports) {
37
- inputs = inputs.filter((input) => !input.startsWith(`./${outdir}`) && !input.startsWith(outdir));
38
- }
39
- if (inputs.length === 0)
40
- throw new Error("No inputs found");
41
- const absoluteInputs = inputs.map(
42
- (input) => path.isAbsolute(input) ? input : path.resolve(cwd, input)
43
- );
44
- let cDir = path.dirname(absoluteInputs[0]);
45
- if (absoluteInputs.length > 1) {
46
- cDir = commondir(absoluteInputs, cwd);
47
- }
48
- const resolvedInputs = absoluteInputs.map((input) => {
49
- return path.relative(cDir, input);
50
- });
51
- return {
52
- ...manifest,
53
- ...pkger({
54
- cwd,
55
- noIndex: !includeIndex,
56
- source: path.relative(cwd, cDir),
57
- inputs: resolvedInputs,
58
- ...jiek
59
- })
60
- };
61
- }
62
-
63
- export { mergePackageJson };
64
- //# sourceMappingURL=merge-package-json.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-package-json.esm.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nimport { commondir } from './utils/commondir'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string, options: {\n excludeDistInExports?: boolean\n} = {}) {\n const {\n excludeDistInExports = false\n } = options\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n const { outdir = 'dist' } = jiek\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n let inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (excludeDistInExports) {\n inputs = inputs.filter(input => !input.startsWith(`./${outdir}`) && !input.startsWith(outdir))\n }\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import t from"node:path";import{pkger as r}from"@jiek/pkger";import{commondir as e}from"./utils/commondir.esm.min.js";function o(o,i,n={}){const{excludeDistInExports:s=!1}=n,{jiek:{cwd:p,...c}={}}=o,{outdir:a="dist"}=c;let{exports:d}=o,f=!1;"string"==typeof d&&(f=!0,d={".":d}),void 0===d&&(d={".":"./src/index.ts"}),"object"==typeof d&&(f=!!(Array.isArray(d)&&d.length>0)||!!d["."]);let l=Array.isArray(d)?d:Object.entries(d).reduce(((t,[r,e])=>{if("string"==typeof e)return"."===r?[e,...t]:t.concat(e);if(Array.isArray(e))return t.concat(e);throw new TypeError(`Unexpected value type for key "${r}" in exports, expected string, got ${typeof e}`)}),[]);if(s&&(l=l.filter((t=>!t.startsWith(`./${a}`)&&!t.startsWith(a)))),0===l.length)throw new Error("No inputs found");const u=l.map((r=>t.isAbsolute(r)?r:t.resolve(i,r)));let m=t.dirname(u[0]);u.length>1&&(m=e(u,i));const y=u.map((r=>t.relative(m,r)));return{...o,...r({cwd:i,noIndex:!f,source:t.relative(i,m),inputs:y,...c})}}export{o as mergePackageJson};
2
- //# sourceMappingURL=merge-package-json.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge-package-json.esm.min.js","sources":["../src/merge-package-json.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nimport { commondir } from './utils/commondir'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string, options: {\n excludeDistInExports?: boolean\n} = {}) {\n const {\n excludeDistInExports = false\n } = options\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n const { outdir = 'dist' } = jiek\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n let inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (excludeDistInExports) {\n inputs = inputs.filter(input => !input.startsWith(`./${outdir}`) && !input.startsWith(outdir))\n }\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n"],"names":["mergePackageJson","manifest","cwd","options","excludeDistInExports","jiek","_","outdir","exports","includeIndex","Array","isArray","length","inputs","Object","entries","reduce","acc","key","value","concat","TypeError","filter","input","startsWith","Error","absoluteInputs","map","path","isAbsolute","resolve","cDir","dirname","commondir","resolvedInputs","relative","pkger","noIndex","source"],"mappings":"sHAOO,SAASA,EAAiBC,EAG9BC,EAAaC,EAEZ,CAAA,GACI,MAAAC,qBACJA,GAAuB,GACrBD,GAEFE,MAAQH,IAAKI,KAAMD,GAAS,CAAC,GAC3BJ,GACEM,OAAEA,EAAS,QAAWF,EACxB,IAAAG,QAAEA,GAAYP,EACdQ,GAAe,EACI,iBAAZD,IACMC,GAAA,EACLD,EAAA,CAAE,IAAKA,SAEH,IAAZA,IACQA,EAAA,CAAE,IAAK,mBAEI,iBAAZA,IAEQC,KADbC,MAAMC,QAAQH,IAAYA,EAAQI,OAAS,MAGFJ,EAAS,MAGxD,IAAIK,EAASH,MAAMC,QAAQH,GACvBA,EACAM,OACCC,QAAiCP,GACjCQ,QAAO,CAACC,GAAMC,EAAKC,MAClB,GAAqB,iBAAVA,EAA2B,MAAQ,MAARD,EAClC,CAACC,KAAUF,GACXA,EAAIG,OAAOD,GACX,GAAAT,MAAMC,QAAQQ,GAAe,OAAAF,EAAIG,OAAOD,GAE5C,MAAM,IAAIE,UAAU,kCAAkCH,8CAAgDC,IAAO,GAC5G,IAIP,GAHIf,IACFS,EAASA,EAAOS,QAAgBC,IAACA,EAAMC,WAAW,KAAKjB,OAAcgB,EAAMC,WAAWjB,MAElE,IAAlBM,EAAOD,OACH,MAAA,IAAIa,MAAM,mBAElB,MAAMC,EAAiBb,EAAOc,KAAIJ,GAASK,EAAKC,WAAWN,GACvDA,EACAK,EAAKE,QAAQ5B,EAAKqB,KAEtB,IAAIQ,EAAOH,EAAKI,QAAQN,EAAe,IACnCA,EAAed,OAAS,IACnBmB,EAAAE,EAAUP,EAAgBxB,IAE7B,MAAAgC,EAAiBR,EAAeC,KAAaJ,GAC1CK,EAAKO,SAASJ,EAAMR,KAEtB,MAAA,IACFtB,KACAmC,EAAM,CACPlC,MACAmC,SAAU5B,EACV6B,OAAQV,EAAKO,SAASjC,EAAK6B,GAC3BlB,OAAQqB,KACL7B,IAGT"}
package/dist/pkg.esm.js DELETED
@@ -1,4 +0,0 @@
1
- var pkg = require("../package.json");
2
-
3
- export { pkg as default };
4
- //# sourceMappingURL=pkg.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkg.esm.js","sources":["../src/pkg.ts"],"sourcesContent":["export default require('../package.json')\n"],"names":[],"mappings":"AAAA,UAAe,QAAQ,iBAAiB,CAAA;;;;"}
@@ -1,2 +0,0 @@
1
- var a=require("../package.json");export{a as default};
2
- //# sourceMappingURL=pkg.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkg.esm.min.js","sources":["../src/pkg.ts"],"sourcesContent":["export default require('../package.json')\n"],"names":["pkg","require"],"mappings":"AAAA,IAAeA,EAAAC,QAAQ"}
@@ -1,31 +0,0 @@
1
- import globalResolver from '../utils/globalResolver.esm.js';
2
-
3
- function createGlobalsLinkage() {
4
- let globals = {};
5
- const dependencies = /* @__PURE__ */ new Set([]);
6
- return [
7
- ({ external } = {}) => {
8
- return {
9
- name: "globals",
10
- resolveId(id) {
11
- if (external?.some((dep) => dep instanceof RegExp ? dep.test(id) : dep === id)) {
12
- dependencies.add(id);
13
- return { id, external: true };
14
- }
15
- return null;
16
- },
17
- outputOptions(options) {
18
- globals = [...dependencies].reduce((acc, value) => ({
19
- ...acc,
20
- [value]: globalResolver(value)
21
- }), {});
22
- return { ...options, globals };
23
- }
24
- };
25
- },
26
- { outputOptions: (options) => ({ ...options, globals }) }
27
- ];
28
- }
29
-
30
- export { createGlobalsLinkage };
31
- //# sourceMappingURL=globals.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.esm.js","sources":["../../../src/rollup/plugins/globals.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAQO,SAAS,oBAAuB,GAAA;AACrC,EAAA,IAAI,UAAU,EAAC,CAAA;AACf,EAAA,MAAM,YAAe,mBAAA,IAAI,GAAY,CAAA,EAAE,CAAA,CAAA;AACvC,EAAO,OAAA;AAAA,IACJ,CAAC,EAAE,QAAS,EAAA,GAAI,EAAO,KAAA;AACtB,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,SAAA;AAAA,QACN,UAAU,EAAI,EAAA;AACZ,UAAI,IAAA,QAAA,EAAU,IAAK,CAAA,CAAA,GAAA,KAAO,GAAe,YAAA,MAAA,GAAS,GAAI,CAAA,IAAA,CAAK,EAAE,CAAA,GAAI,GAAQ,KAAA,EAAE,CAAG,EAAA;AAC5E,YAAA,YAAA,CAAa,IAAI,EAAE,CAAA,CAAA;AACnB,YAAO,OAAA,EAAE,EAAI,EAAA,QAAA,EAAU,IAAK,EAAA,CAAA;AAAA,WAC9B;AACA,UAAO,OAAA,IAAA,CAAA;AAAA,SACT;AAAA,QACA,cAAc,OAAS,EAAA;AACrB,UAAA,OAAA,GAAU,CAAC,GAAG,YAAY,EAAE,MAAO,CAAA,CAAC,KAAK,KAAW,MAAA;AAAA,YAClD,GAAG,GAAA;AAAA,YACH,CAAC,KAAK,GAAG,cAAA,CAAe,KAAK,CAAA;AAAA,WAC/B,CAAA,EAAI,EAAE,CAAA,CAAA;AACN,UAAO,OAAA,EAAE,GAAG,OAAA,EAAS,OAAQ,EAAA,CAAA;AAAA,SAC/B;AAAA,OACF,CAAA;AAAA,KACF;AAAA,IACA,EAAE,aAAe,EAAA,CAAA,OAAA,MAAY,EAAE,GAAG,OAAA,EAAS,SAAW,CAAA,EAAA;AAAA,GACxD,CAAA;AACF;;;;"}
@@ -1,2 +0,0 @@
1
- import e from"../utils/globalResolver.esm.min.js";function t(){let t={};const o=new Set([]);return[({external:l}={})=>({name:"globals",resolveId:e=>l?.some((t=>t instanceof RegExp?t.test(e):t===e))?(o.add(e),{id:e,external:!0}):null,outputOptions:l=>(t=[...o].reduce(((t,o)=>({...t,[o]:e(o)})),{}),{...l,globals:t})}),{outputOptions:e=>({...e,globals:t})}]}export{t as createGlobalsLinkage};
2
- //# sourceMappingURL=globals.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globals.esm.min.js","sources":["../../../src/rollup/plugins/globals.ts"],"sourcesContent":["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"],"names":["createGlobalsLinkage","globals","dependencies","Set","external","name","resolveId","id","some","dep","RegExp","test","add","outputOptions","options","reduce","acc","value","globalResolver"],"mappings":"kDAQO,SAASA,IACd,IAAIC,EAAU,CAAA,EACd,MAAMC,EAAe,IAAIC,IAAY,IAC9B,MAAA,CACJ,EAAGC,YAAa,MACR,CACLC,KAAM,UACNC,UAAUC,GACJH,GAAUI,MAAKC,GAAOA,aAAeC,OAASD,EAAIE,KAAKJ,GAAME,IAAQF,KACvEL,EAAaU,IAAIL,GACV,CAAEA,KAAIH,UAAU,IAElB,KAETS,cAAcC,IACZb,EAAU,IAAIC,GAAca,QAAO,CAACC,EAAKC,KAAW,IAC/CD,EACHC,CAACA,GAAQC,EAAeD,MACtB,CAAE,GACC,IAAKH,EAASb,cAI3B,CAAEY,cAAeC,IAAA,IAAiBA,EAASb,aAE/C"}
@@ -1,16 +0,0 @@
1
- var skip = (options = {}) => {
2
- return {
3
- name: "skip",
4
- // skip the specified files by `options.patterns`
5
- load(id) {
6
- if (options.patterns?.some(
7
- (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
8
- )) {
9
- return "";
10
- }
11
- }
12
- };
13
- };
14
-
15
- export { skip as default };
16
- //# sourceMappingURL=skip.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skip.esm.js","sources":["../../../src/rollup/plugins/skip.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAMA,WAAgB,CAAC,OAAU,GAAA,EAAO,KAAA;AAChC,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA;AAAA,IAEN,KAAK,EAAI,EAAA;AACP,MAAA,IACE,QAAQ,QAAU,EAAA,IAAA;AAAA,QAAK,CAAC,OACtB,KAAA,OAAO,OAAY,KAAA,QAAA,GACf,EAAG,CAAA,QAAA,CAAS,OAAO,CAAA,GACnB,OAAQ,CAAA,IAAA,CAAK,EAAE,CAAA;AAAA,OAErB,EAAA;AACA,QAAO,OAAA,EAAA,CAAA;AAAA,OACT;AAAA,KACF;AAAA,GACF,CAAA;AACF,CAAA;;;;"}
@@ -1,2 +0,0 @@
1
- var e=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});export{e as default};
2
- //# sourceMappingURL=skip.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skip.esm.min.js","sources":["../../../src/rollup/plugins/skip.ts"],"sourcesContent":["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"],"names":["skip","options","name","load","id","patterns","some","pattern","includes","test"],"mappings":"AAMA,IAAAA,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"}
@@ -1,9 +0,0 @@
1
- const defineOutput = (output) => output;
2
- const commonOutputOptions = defineOutput({
3
- exports: "named",
4
- interop: "auto",
5
- sourcemap: true
6
- });
7
-
8
- export { commonOutputOptions };
9
- //# sourceMappingURL=commonOptions.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commonOptions.esm.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["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"],"names":[],"mappings":"AAEA,MAAM,YAAA,GAAe,CAA0B,MAAc,KAAA,MAAA,CAAA;AAEtD,MAAM,sBAAsB,YAAa,CAAA;AAAA,EAC9C,OAAS,EAAA,OAAA;AAAA,EACT,OAAS,EAAA,MAAA;AAAA,EACT,SAAW,EAAA,IAAA;AACb,CAAC;;;;"}
@@ -1,2 +0,0 @@
1
- const o={exports:"named",interop:"auto",sourcemap:!0};export{o as commonOutputOptions};
2
- //# sourceMappingURL=commonOptions.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commonOptions.esm.min.js","sources":["../../../src/rollup/utils/commonOptions.ts"],"sourcesContent":["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"],"names":["commonOutputOptions","exports","interop","sourcemap"],"mappings":"AAEA,MAEaA,EAAmC,CAC9CC,QAAS,QACTC,QAAS,OACTC,WAAW"}
@@ -1,12 +0,0 @@
1
- function externalResolver() {
2
- const cwd = process.cwd();
3
- const pkg = require(`${cwd}/package.json`);
4
- const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
5
- const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
6
- return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
7
- /^node:/
8
- ]);
9
- }
10
-
11
- export { externalResolver as default };
12
- //# sourceMappingURL=externalResolver.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"externalResolver.esm.js","sources":["../../../src/rollup/utils/externalResolver.ts"],"sourcesContent":["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":[],"mappings":"AAA2B,yBAAA,GAAA;AACzB,EAAM,MAAA,GAAA,GAAM,QAAQ,GAAI,EAAA,CAAA;AAExB,EAAA,MAAM,GAAM,GAAA,OAAA,CAAQ,CAAG,EAAA,GAAG,CAAe,aAAA,CAAA,CAAA,CAAA;AACzC,EAAM,MAAA,EAAE,YAAe,GAAA,EAAI,EAAA,gBAAA,GAAmB,EAAI,EAAA,oBAAA,GAAuB,EAAC,EAAM,GAAA,GAAA,CAAA;AAChF,EAAA,MAAM,QAAgC,GAAA,MAAA,CACnC,IAAK,CAAA,YAAY,EACjB,MAAO,CAAA,MAAA,CAAO,IAAK,CAAA,gBAAgB,CAAC,CACpC,CAAA,MAAA,CAAO,MAAO,CAAA,IAAA,CAAK,oBAAoB,CAAC,CAAA,CAAA;AAC3C,EAAO,OAAA,QAAA,CACJ,GAAI,CAAA,CAAA,GAAA,KAAO,IAAI,MAAA,CAAO,IAAI,GAAG,CAAA,OAAA,CAAS,CAAC,CAAA,CACvC,MAAO,CAAA;AAAA,IACN,QAAA;AAAA,GACD,CAAA,CAAA;AACL;;;;"}
@@ -1,2 +0,0 @@
1
- function e(){const e=process.cwd(),c=require(`${e}/package.json`),{dependencies:n={},peerDependencies:t={},optionalDependencies:o={}}=c;return Object.keys(n).concat(Object.keys(t)).concat(Object.keys(o)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}export{e as default};
2
- //# sourceMappingURL=externalResolver.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"externalResolver.esm.min.js","sources":["../../../src/rollup/utils/externalResolver.ts"],"sourcesContent":["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":["externalResolver","cwd","process","pkg","require","dependencies","peerDependencies","optionalDependencies","Object","keys","concat","map","dep","RegExp"],"mappings":"AAA2B,SAAAA,IACnB,MAAAC,EAAMC,QAAQD,MAEdE,EAAMC,QAAQ,GAAGH,mBACjBI,aAAEA,EAAe,CAAA,EAAIC,iBAAAA,EAAmB,CAAI,EAAAC,qBAAAA,EAAuB,CAAA,GAAOJ,EAKzE,OAJ+BK,OACnCC,KAAKJ,GACLK,OAAOF,OAAOC,KAAKH,IACnBI,OAAOF,OAAOC,KAAKF,IAEnBI,KAAIC,GAAO,IAAIC,OAAO,IAAID,cAC1BF,OAAO,CACN,UAEN"}
@@ -1,9 +0,0 @@
1
- function globalResolver(external) {
2
- if (external.startsWith("node:")) {
3
- return external.slice(5);
4
- }
5
- return external.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
6
- }
7
-
8
- export { globalResolver as default };
9
- //# sourceMappingURL=globalResolver.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globalResolver.esm.js","sources":["../../../src/rollup/utils/globalResolver.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"],"names":[],"mappings":"AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EAAI,IAAA,QAAA,CAAS,UAAW,CAAA,OAAO,CAAG,EAAA;AAChC,IAAO,OAAA,QAAA,CAAS,MAAM,CAAC,CAAA,CAAA;AAAA,GACzB;AACA,EAAO,OAAA,QAAA,CACJ,QAAQ,aAAe,EAAA,CAAC,GAAG,EAAO,KAAA,EAAA,CAAG,aAAa,CAAA,CAAA;AACvD;;;;"}
@@ -1,2 +0,0 @@
1
- function e(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}export{e as default};
2
- //# sourceMappingURL=globalResolver.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"globalResolver.esm.min.js","sources":["../../../src/rollup/utils/globalResolver.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"],"names":["globalResolver","external","startsWith","slice","replace","_","$1","toUpperCase"],"mappings":"AAAA,SAAAA,EAAyBC,GAOnB,OAAAA,EAASC,WAAW,SACfD,EAASE,MAAM,GAEjBF,EACJG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,eAC1C"}
@@ -1,15 +0,0 @@
1
- import terser from '@rollup/plugin-terser';
2
-
3
- function withMinify(output) {
4
- return [
5
- output,
6
- {
7
- ...output,
8
- entryFileNames: output.entryFileNames?.replace(/(\.c?js)$/, ".min$1"),
9
- plugins: [...output.plugins ?? [], terser()]
10
- }
11
- ];
12
- }
13
-
14
- export { withMinify as default };
15
- //# sourceMappingURL=withMinify.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withMinify.esm.js","sources":["../../../src/rollup/utils/withMinify.ts"],"sourcesContent":["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"],"names":[],"mappings":";;AAGA,mBAAA,CAAyB,MAGL,EAAA;AAClB,EAAO,OAAA;AAAA,IACL,MAAA;AAAA,IACA;AAAA,MACE,GAAG,MAAA;AAAA,MACH,cAAgB,EAAA,MAAA,CAAO,cAAgB,EAAA,OAAA,CAAQ,aAAa,QAAQ,CAAA;AAAA,MACpE,OAAA,EAAS,CAAC,GAAI,MAAA,CAAO,WAAW,EAAC,EAAI,QAAQ,CAAA;AAAA,KAC/C;AAAA,GACF,CAAA;AACF;;;;"}
@@ -1,2 +0,0 @@
1
- import e from"@rollup/plugin-terser";function r(r){return[r,{...r,entryFileNames:r.entryFileNames?.replace(/(\.c?js)$/,".min$1"),plugins:[...r.plugins??[],e()]}]}export{r as default};
2
- //# sourceMappingURL=withMinify.esm.min.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withMinify.esm.min.js","sources":["../../../src/rollup/utils/withMinify.ts"],"sourcesContent":["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"],"names":["withMinify","output","entryFileNames","replace","plugins","terser"],"mappings":"qCAGA,SAAAA,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBC,QAAQ,YAAa,UAC5DC,QAAS,IAAKH,EAAOG,SAAW,GAAKC,MAG3C"}
package/dist/rollup.cjs DELETED
@@ -1,330 +0,0 @@
1
- 'use strict';
2
-
3
- var node_path = require('node:path');
4
- var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
5
- var json = require('@rollup/plugin-json');
6
- var autoprefixer = require('autoprefixer');
7
- var cliProgress = require('cli-progress');
8
- var rollupPluginDts = require('@jiek/rollup-plugin-dts');
9
- var esbuild = require('rollup-plugin-esbuild');
10
- var postcss = require('rollup-plugin-postcss');
11
- var terser = require('@rollup/plugin-terser');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
-
15
- var json__default = /*#__PURE__*/_interopDefault(json);
16
- var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
17
- var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
18
- var postcss__default = /*#__PURE__*/_interopDefault(postcss);
19
- var terser__default = /*#__PURE__*/_interopDefault(terser);
20
-
21
- function globalResolver(external) {
22
- if (external.startsWith("node:")) {
23
- return external.slice(5);
24
- }
25
- return external.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
26
- }
27
-
28
- function createGlobalsLinkage() {
29
- let globals = {};
30
- const dependencies = /* @__PURE__ */ new Set([]);
31
- return [
32
- ({ external } = {}) => {
33
- return {
34
- name: "globals",
35
- resolveId(id) {
36
- if (external?.some((dep) => dep instanceof RegExp ? dep.test(id) : dep === id)) {
37
- dependencies.add(id);
38
- return { id, external: true };
39
- }
40
- return null;
41
- },
42
- outputOptions(options) {
43
- globals = [...dependencies].reduce((acc, value) => ({
44
- ...acc,
45
- [value]: globalResolver(value)
46
- }), {});
47
- return { ...options, globals };
48
- }
49
- };
50
- },
51
- { outputOptions: (options) => ({ ...options, globals }) }
52
- ];
53
- }
54
-
55
- var skip = (options = {}) => {
56
- return {
57
- name: "skip",
58
- // skip the specified files by `options.patterns`
59
- load(id) {
60
- if (options.patterns?.some(
61
- (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
62
- )) {
63
- return "";
64
- }
65
- }
66
- };
67
- };
68
-
69
- const defineOutput = (output) => output;
70
- const commonOutputOptions = defineOutput({
71
- exports: "named",
72
- interop: "auto",
73
- sourcemap: true
74
- });
75
-
76
- function externalResolver() {
77
- const cwd = process.cwd();
78
- const pkg = require(`${cwd}/package.json`);
79
- const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
80
- const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
81
- return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
82
- /^node:/
83
- ]);
84
- }
85
-
86
- function withMinify(output) {
87
- return [
88
- output,
89
- {
90
- ...output,
91
- entryFileNames: output.entryFileNames?.replace(/(\.c?js)$/, ".min$1"),
92
- plugins: [...output.plugins ?? [], terser__default.default()]
93
- }
94
- ];
95
- }
96
-
97
- const {
98
- JIEK_SILENT,
99
- JIEK_TARGET,
100
- JIEK_ROOT
101
- } = process.env;
102
- const target = JIEK_TARGET ?? "esm,umd,dts";
103
- const ACCEPTED_TARGETS = ["esm", "umd", "dts"];
104
- const targets = target.split(",").filter(Boolean).filter((t) => ACCEPTED_TARGETS.includes(t));
105
- const workspaceRoot = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
106
- function resolveWorkspacePath(p) {
107
- return node_path.resolve(workspaceRoot, p);
108
- }
109
- function watchProgress(entries, onProcessing, onProcessed) {
110
- return {
111
- name: "progress",
112
- resolveId(source, importer) {
113
- if (entries.includes(source) || importer === void 0)
114
- onProcessing(source);
115
- },
116
- writeBundle(options, bundle) {
117
- Object.entries(bundle).forEach(([key, value]) => {
118
- if (value.name === void 0 || !("isEntry" in value))
119
- return;
120
- onProcessed(value.name, value.fileName);
121
- });
122
- }
123
- };
124
- }
125
- const template = ({
126
- styled = false,
127
- plugins: {
128
- index: indexPlugins = [],
129
- entry: entryPlugins = [],
130
- dts: dtsPlugins = []
131
- } = {}
132
- } = {}, pkg) => {
133
- if (targets.length === 0)
134
- throw new Error("no target specified");
135
- const { jiek: {
136
- noBrowser = false,
137
- outdir = "dist"
138
- } = {} } = pkg;
139
- const outputOptions = {
140
- ...commonOutputOptions,
141
- dir: outdir
142
- };
143
- if (!pkg.name) {
144
- throw new Error("pkg.name is required");
145
- }
146
- const namePrefix = pkg.name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
147
- const exportsEntries = Object.fromEntries(
148
- Object.entries(pkg.exports ?? {}).filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir)).filter(([key]) => !/\.(json|css|scss)$/.test(key)).filter(([, value]) => typeof value === "object" && value["inner-src"] && value["import"]).map(([key, value]) => [
149
- key.replace(/^\.$/, "index").replace(/^\.\//, ""),
150
- typeof value === "string" ? value : value["inner-src"]
151
- ])
152
- );
153
- const maxLengthEntry = Math.max(...Object.values(exportsEntries).map((v) => v.length));
154
- function paddingEntry(entry) {
155
- return entry.padEnd(maxLengthEntry);
156
- }
157
- const [globalsRegister, globalsOutput] = createGlobalsLinkage();
158
- const external = externalResolver();
159
- const commonOptions = {};
160
- const commonPlugins = [
161
- json__default.default()
162
- ];
163
- const multiBars = new cliProgress.MultiBar({
164
- clearOnComplete: false,
165
- hideCursor: true,
166
- format: "- {bar} | {type} | {entry} | {message}"
167
- }, cliProgress.Presets.shades_classic);
168
- const entries = Object.values(exportsEntries);
169
- const addBarsByEntries = (type) => entries.reduce((add, entry) => {
170
- const bar = multiBars.create(100, 0);
171
- bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
172
- return { ...add, [entry]: bar };
173
- }, {});
174
- const progressState = {};
175
- targets.forEach((target2) => {
176
- progressState[target2] = addBarsByEntries(target2);
177
- });
178
- const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
179
- const watchingProgress = (type, isLast = false, defaultEntry) => {
180
- const group = progressState[type];
181
- if (!group)
182
- throw new Error(`target ${type} found`);
183
- return watchProgress(
184
- Object.values(exportsEntries),
185
- (entry) => {
186
- const e = defaultEntry ?? entry;
187
- const bar = group[e];
188
- if (!bar)
189
- return;
190
- bar.update(0, { type, entry: paddingEntry(e), message: "processing" });
191
- },
192
- (name, fileName) => {
193
- const e = defaultEntry ?? exportsEntries[name];
194
- const bar = group[e];
195
- if (!bar)
196
- return;
197
- const endsReg = {
198
- esm: /\.min\.js$/,
199
- umd: /\.min\.c?js$/,
200
- dts: /\.esm\.d\.ts$/
201
- }[type];
202
- if (!endsReg.test(fileName)) {
203
- bar.update(95, { type, entry: paddingEntry(e), message: "processed" });
204
- } else {
205
- bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
206
- }
207
- if (isLast) {
208
- resolved[e] = true;
209
- if (Object.values(resolved).every(Boolean)) {
210
- setTimeout(() => multiBars.stop(), 200);
211
- }
212
- }
213
- }
214
- );
215
- };
216
- const esmOpts = (isLast) => ({
217
- ...commonOptions,
218
- input: exportsEntries,
219
- output: [
220
- ...withMinify({
221
- ...outputOptions,
222
- format: "esm",
223
- entryFileNames: "[name].esm.js",
224
- preserveModules: true
225
- })
226
- ],
227
- plugins: [
228
- watchingProgress("esm", isLast),
229
- commonPlugins,
230
- globalsRegister({ external }),
231
- styled && skip({ patterns: [/\.s?css$/] }),
232
- esbuild__default.default(),
233
- indexPlugins
234
- ]
235
- });
236
- const umdOpts = (isLast) => Object.entries(exportsEntries).map(([name, input]) => {
237
- const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
238
- return {
239
- ...commonOptions,
240
- input,
241
- output: noBrowser ? [
242
- ...withMinify({
243
- ...outputOptions,
244
- name: outputName,
245
- format: "cjs",
246
- entryFileNames: `${name}.cjs`
247
- })
248
- ] : [
249
- ...withMinify({
250
- ...outputOptions,
251
- name: outputName,
252
- format: "iife",
253
- entryFileNames: `${name}.iife.js`
254
- }),
255
- ...withMinify({
256
- ...outputOptions,
257
- name: outputName,
258
- format: "umd",
259
- entryFileNames: `${name}.umd.js`
260
- })
261
- ],
262
- plugins: [
263
- watchingProgress("umd", isLast, input),
264
- commonPlugins,
265
- globalsOutput,
266
- styled && postcss__default.default({
267
- plugins: [autoprefixer__default.default],
268
- minimize: true,
269
- sourceMap: true,
270
- extract: `${name}.css`
271
- }),
272
- esbuild__default.default(),
273
- entryPlugins
274
- ],
275
- external
276
- };
277
- });
278
- const dtsOpts = (isLast) => ({
279
- ...commonOptions,
280
- input: exportsEntries,
281
- output: [
282
- {
283
- dir: "dist"
284
- },
285
- {
286
- dir: "dist",
287
- entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
288
- preserveModules: true
289
- }
290
- ],
291
- plugins: [
292
- watchingProgress("dts", isLast),
293
- commonPlugins,
294
- styled && skip({ patterns: [/\.s?css$/] }),
295
- rollupPluginDts.dts({ tsconfig: resolveWorkspacePath("tsconfig.dts.json") }),
296
- {
297
- name: "rollup-plugin-declare-module-replacer",
298
- /**
299
- * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
300
- * in output file generated
301
- */
302
- generateBundle(_, bundle) {
303
- for (const file of Object.values(bundle)) {
304
- if (!("code" in file))
305
- continue;
306
- file.code = file.code.replace(
307
- /declare module ['|"]\..*['|"]/g,
308
- `declare module '${pkg.name}'`
309
- );
310
- }
311
- }
312
- },
313
- dtsPlugins
314
- ],
315
- external
316
- });
317
- const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts };
318
- return targets.flatMap((target2) => {
319
- const optsGen = optionsMap[target2];
320
- if (optsGen === void 0)
321
- throw new Error(`target ${target2} is not supported`);
322
- const opts = optsGen(target2 === targets[targets.length - 1]);
323
- if (Array.isArray(opts))
324
- return opts;
325
- return [opts];
326
- });
327
- };
328
-
329
- exports.template = template;
330
- //# sourceMappingURL=rollup.cjs.map