@reliverse/dler 1.2.5 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +36 -41
  2. package/bin/addons.d.ts +1 -0
  3. package/bin/addons.js +83 -0
  4. package/bin/app/agg/cmd.d.ts +35 -0
  5. package/bin/app/agg/cmd.js +49 -0
  6. package/bin/app/agg/impl.d.ts +36 -0
  7. package/bin/app/{tools → agg}/impl.js +1 -2
  8. package/bin/app/build/cmd.d.ts +7 -0
  9. package/bin/app/build/cmd.js +3 -1
  10. package/bin/app/cmds.d.ts +100 -0
  11. package/bin/app/cmds.js +11 -2
  12. package/bin/app/conv/cmd.d.ts +0 -0
  13. package/bin/app/deps/cmd.d.ts +28 -0
  14. package/bin/app/deps/cmd.js +62 -0
  15. package/bin/app/deps/impl/analyzer.d.ts +2 -0
  16. package/bin/app/deps/impl/analyzer.js +1 -1
  17. package/bin/app/deps/impl/filesystem.d.ts +4 -0
  18. package/bin/app/deps/impl/filesystem.js +2 -4
  19. package/bin/app/deps/impl/formatter.d.ts +2 -0
  20. package/bin/app/deps/impl/formatter.js +2 -2
  21. package/bin/app/deps/impl/parser.d.ts +5 -0
  22. package/bin/app/deps/impl/types.d.ts +21 -0
  23. package/bin/app/inject/README.md +3 -12
  24. package/bin/app/inject/cmd.d.ts +12 -0
  25. package/bin/app/inject/cmd.js +2 -2
  26. package/bin/app/inject/expect/cmd.d.ts +20 -0
  27. package/bin/app/inject/expect/impl.d.ts +5 -0
  28. package/bin/app/libs/cmd.d.ts +0 -0
  29. package/bin/app/merge/cmd.txt +1 -1
  30. package/bin/app/mono/cmd.d.ts +0 -0
  31. package/bin/app/pub/cmd.d.ts +7 -0
  32. package/bin/app/pub/cmd.js +3 -1
  33. package/bin/app/relifso/cmd.d.ts +12 -0
  34. package/bin/app/relifso/cmd.js +2 -2
  35. package/bin/app/relifso/init/cmd.d.ts +36 -0
  36. package/bin/app/relifso/init/impl/const.d.ts +34 -0
  37. package/bin/app/relifso/init/impl/const.js +1 -1
  38. package/bin/app/relifso/init/impl/mod.d.ts +17 -0
  39. package/bin/app/relifso/init/impl/templates/t-gitignore.d.ts +1 -0
  40. package/bin/app/relifso/init/impl/templates/t-license.d.ts +1 -0
  41. package/bin/app/relifso/init/impl/templates/t-readme.d.ts +1 -0
  42. package/bin/app/relifso/init/impl/types.d.ts +41 -0
  43. package/bin/app/relifso/init/impl/utils.d.ts +5 -0
  44. package/bin/app/relinka/cmd.d.ts +0 -0
  45. package/bin/app/rempts/init/cmd/cmd.d.ts +14 -0
  46. package/bin/app/rempts/init/cmd/cmd.js +3 -1
  47. package/bin/app/rempts/init/cmds/cmd.d.ts +19 -0
  48. package/bin/app/rempts/migrate/cmd.d.ts +14 -0
  49. package/bin/app/rempts/migrate/impl/commander.d.ts +4 -0
  50. package/bin/app/spell/cmd.d.ts +18 -0
  51. package/bin/app/spell/cmd.js +51 -0
  52. package/bin/app/split/cmd.d.ts +11 -0
  53. package/bin/app/split/impl.d.ts +25 -0
  54. package/bin/default.d.ts +5 -0
  55. package/bin/{libs/cfg/cfg-default.js → default.js} +6 -4
  56. package/bin/dler.d.ts +1 -0
  57. package/bin/dler.js +60 -0
  58. package/bin/impl.d.ts +10 -0
  59. package/bin/{cli.js → impl.js} +15 -27
  60. package/bin/info.d.ts +2 -0
  61. package/bin/info.js +21 -0
  62. package/bin/init.d.ts +1 -0
  63. package/bin/init.js +20 -27
  64. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +51 -0
  65. package/bin/libs/sdk/sdk-impl/build/build-library.js +45 -66
  66. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +26 -0
  67. package/bin/libs/sdk/sdk-impl/build/build-regular.js +28 -18
  68. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.d.ts +2 -0
  69. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +8 -3
  70. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +5 -0
  71. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +12 -7
  72. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.d.ts +2 -0
  73. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.js +2 -1
  74. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/types.d.ts +9 -0
  75. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.d.ts +2 -0
  76. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +22 -6
  77. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/types.d.ts +15 -0
  78. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.d.ts +2 -0
  79. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +2 -1
  80. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.d.ts +2 -0
  81. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/cjs.d.ts +4 -0
  82. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.d.ts +13 -0
  83. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/json.d.ts +3 -0
  84. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +8 -0
  85. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/shebang.d.ts +5 -0
  86. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.d.ts +2 -0
  87. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/types.d.ts +95 -0
  88. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.d.ts +5 -0
  89. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.d.ts +2 -0
  90. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/types.d.ts +176 -0
  91. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.d.ts +2 -0
  92. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.js +2 -2
  93. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/types.d.ts +23 -0
  94. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +20 -0
  95. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.d.ts +4 -0
  96. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +11 -0
  97. package/bin/libs/sdk/sdk-impl/library-flow.js +6 -1
  98. package/bin/libs/sdk/sdk-impl/pub/pub-library.d.ts +5 -0
  99. package/bin/libs/sdk/sdk-impl/pub/pub-library.js +6 -16
  100. package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +9 -0
  101. package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +12 -10
  102. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +12 -0
  103. package/bin/libs/sdk/sdk-impl/regular-flow.js +45 -51
  104. package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +10 -0
  105. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +7 -0
  106. package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +4 -0
  107. package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +4 -0
  108. package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +34 -0
  109. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.d.ts +14 -0
  110. package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +8 -6
  111. package/bin/libs/sdk/sdk-impl/utils/tools/tools-impl.d.ts +4 -0
  112. package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +28 -0
  113. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +3 -3
  114. package/bin/libs/sdk/sdk-impl/utils/utils-bump.d.ts +9 -0
  115. package/bin/libs/sdk/sdk-impl/utils/utils-bump.js +5 -7
  116. package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +5 -0
  117. package/bin/libs/sdk/sdk-impl/utils/utils-consts.d.ts +9 -0
  118. package/bin/libs/sdk/sdk-impl/utils/utils-cwd.d.ts +10 -0
  119. package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +5 -0
  120. package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +12 -0
  121. package/bin/libs/sdk/sdk-impl/utils/utils-error.d.ts +5 -0
  122. package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +24 -0
  123. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +4 -1
  124. package/bin/libs/sdk/sdk-impl/utils/utils-info.d.ts +6 -0
  125. package/bin/libs/sdk/sdk-impl/utils/utils-info.js +7 -14
  126. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +8 -0
  127. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -4
  128. package/bin/libs/sdk/sdk-impl/utils/utils-paths.d.ts +55 -0
  129. package/bin/libs/sdk/sdk-impl/utils/utils-paths.js +33 -24
  130. package/bin/libs/sdk/sdk-impl/utils/utils-perf.d.ts +9 -0
  131. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.d.ts +5 -0
  132. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.d.ts +8 -0
  133. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +36 -27
  134. package/bin/libs/sdk/sdk-impl/utils/utils-tsconfig.d.ts +4 -0
  135. package/bin/libs/sdk/sdk-mod.d.ts +56 -0
  136. package/bin/libs/sdk/sdk-mod.js +42 -9
  137. package/bin/libs/sdk/sdk-types.d.ts +469 -0
  138. package/bin/libs/sdk/sdk-types.js +0 -1
  139. package/bin/load.d.ts +6 -0
  140. package/bin/load.js +1 -1
  141. package/bin/mod.d.ts +48 -0
  142. package/bin/mod.js +4 -14
  143. package/bin/types.d.ts +469 -0
  144. package/package.json +6 -5
  145. package/bin/app/tools/cmd.js +0 -81
  146. package/bin/app/tools/tools.txt +0 -92
  147. package/bin/libs/cfg/cfg-mod.js +0 -4
  148. package/bin/libs/cfg/cfg-types.js +0 -1
@@ -11,7 +11,12 @@ export const autoPreset = definePreset(() => {
11
11
  return;
12
12
  }
13
13
  const sourceFiles = listRecursively(join(ctx.options.rootDir, "src"));
14
- const res = inferEntries(ctx.pkg, sourceFiles, ctx.options.rootDir);
14
+ const res = inferEntries(
15
+ ctx.pkg,
16
+ sourceFiles,
17
+ ctx.options.isLib,
18
+ ctx.options.rootDir
19
+ );
15
20
  for (const message of res.warnings) {
16
21
  warn(ctx, message);
17
22
  }
@@ -38,7 +43,7 @@ const getEntrypointPaths = (path) => {
38
43
  const segments = normalize(path).split("/");
39
44
  return segments.map((_, index) => segments.slice(index).join("/")).filter(Boolean);
40
45
  };
41
- function inferEntries(pkg, sourceFiles, rootDir) {
46
+ function inferEntries(pkg, sourceFiles, isLib, rootDir) {
42
47
  const warnings = [];
43
48
  sourceFiles.sort((a, b) => a.split("/").length - b.split("/").length);
44
49
  const outputs = extractExportFilenames(pkg.exports);
@@ -97,7 +102,7 @@ function inferEntries(pkg, sourceFiles, rootDir) {
97
102
  if (output.type === "cjs") {
98
103
  cjs = true;
99
104
  }
100
- const entry = entries.find((i) => i.input === input) || entries[entries.push({ input }) - 1];
105
+ const entry = entries.find((i) => i.input === input) || entries[entries.push({ input, isLib }) - 1];
101
106
  if (/\.d\.(m|c)?ts$/.test(output.file)) {
102
107
  dts = true;
103
108
  }
@@ -0,0 +1,5 @@
1
+ import type { UnifiedBuildConfig } from "./types.js";
2
+ export declare function unifiedBuild(isLib: boolean, rootDir: string, inputConfig: UnifiedBuildConfig & {
3
+ config?: string;
4
+ showOutLog?: boolean;
5
+ }, outDir: string, transpileStub?: boolean): Promise<void>;
@@ -25,7 +25,7 @@ import {
25
25
  withTrailingSlash
26
26
  } from "./utils.js";
27
27
  import { validateDependencies, validatePackage } from "./validate.js";
28
- export async function build(rootDir, inputConfig, outDir, transpileStub = false) {
28
+ export async function unifiedBuild(isLib, rootDir, inputConfig, outDir, transpileStub = false) {
29
29
  const resolvedRootDir = resolve(process.cwd(), rootDir || ".");
30
30
  const jiti = createJiti(resolvedRootDir);
31
31
  const _buildConfig = await jiti.import(inputConfig?.config || ".config/dler.ts", {
@@ -53,11 +53,12 @@ export async function build(rootDir, inputConfig, outDir, transpileStub = false)
53
53
  _transpileStubMode,
54
54
  _transpileWatchMode,
55
55
  outDir,
56
- inputConfig.showOutLog || true
56
+ inputConfig.showOutLog || true,
57
+ isLib
57
58
  );
58
59
  }
59
60
  }
60
- async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _transpileStubMode, _transpileWatchMode, outDir, showOutLog) {
61
+ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _transpileStubMode, _transpileWatchMode, outDir, showOutLog, isLib) {
61
62
  const timer = createPerfTimer();
62
63
  const preset = await resolvePreset(
63
64
  buildConfig.preset || pkg.dler?.preset || pkg.build?.preset || inputConfig.preset || "auto",
@@ -143,7 +144,8 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
143
144
  transpileWatchOptions: _transpileWatchMode ? {
144
145
  exclude: "node_modules/**",
145
146
  include: "src/**"
146
- } : void 0
147
+ } : void 0,
148
+ isLib
147
149
  }
148
150
  );
149
151
  options.outDir = resolve(options.rootDir, options.outDir);
@@ -155,7 +157,8 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
155
157
  options,
156
158
  pkg,
157
159
  usedImports: /* @__PURE__ */ new Set(),
158
- warnings: /* @__PURE__ */ new Set()
160
+ warnings: /* @__PURE__ */ new Set(),
161
+ isLib
159
162
  };
160
163
  if (preset.hooks) {
161
164
  ctx.hooks.addHooks(preset.hooks);
@@ -168,7 +171,7 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
168
171
  }
169
172
  await ctx.hooks.callHook("build:prepare", ctx);
170
173
  options.entries = options.entries.map(
171
- (entry) => typeof entry === "string" ? { input: entry } : entry
174
+ (entry) => typeof entry === "string" ? { input: entry, isLib } : entry
172
175
  );
173
176
  for (const entry of options.entries) {
174
177
  if (typeof entry.name !== "string") {
@@ -189,6 +192,7 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
189
192
  }
190
193
  entry.input = resolve(options.rootDir, entry.input);
191
194
  entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
195
+ entry.isLib = isLib;
192
196
  }
193
197
  options.dependencies = Object.keys(pkg.dependencies || {});
194
198
  options.peerDependencies = Object.keys(pkg.peerDependencies || {});
@@ -253,7 +257,8 @@ ${options.entries.map((entry) => ` ${dumpObject(entry)}`).join("\n ")}
253
257
  if (!entry) {
254
258
  entry = {
255
259
  chunk: true,
256
- path: file
260
+ path: file,
261
+ isLib: ctx.options.isLib
257
262
  };
258
263
  ctx.buildEntries.push(entry);
259
264
  }
@@ -0,0 +1,2 @@
1
+ import type { BuildContext } from "../types.js";
2
+ export declare function copyBuild(ctx: BuildContext): Promise<void>;
@@ -48,7 +48,8 @@ export async function copyBuild(ctx) {
48
48
  p.value
49
49
  )
50
50
  ),
51
- path: distDir
51
+ path: distDir,
52
+ isLib: entry.isLib
52
53
  });
53
54
  }
54
55
  }
@@ -0,0 +1,9 @@
1
+ import type { BaseBuildEntry, BuildContext } from "../types.js";
2
+ export type CopyBuildEntry = BaseBuildEntry & {
3
+ builder: "copy";
4
+ pattern?: string | string[];
5
+ };
6
+ export type CopyHooks = {
7
+ "copy:done": (ctx: BuildContext) => Promise<void> | void;
8
+ "copy:entries": (ctx: BuildContext, entries: CopyBuildEntry[]) => Promise<void> | void;
9
+ };
@@ -0,0 +1,2 @@
1
+ import type { BuildContext } from "../types.js";
2
+ export declare function mkdistBuild(ctx: BuildContext): Promise<void>;
@@ -1,8 +1,7 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
2
  import { mkdist } from "mkdist";
3
- import { relative } from "pathe";
3
+ import { relative, dirname as pathDirname } from "pathe";
4
4
  import {
5
- ensuredir,
6
5
  rmdir,
7
6
  symlink,
8
7
  warn
@@ -14,18 +13,34 @@ export async function mkdistBuild(ctx) {
14
13
  await ctx.hooks.callHook("mkdist:entries", ctx, entries);
15
14
  for (const entry of entries) {
16
15
  const distDir = entry.outDir || entry.input;
17
- await ensuredir(distDir);
18
16
  if (ctx.options.transpileStub) {
19
17
  await rmdir(distDir);
20
18
  await symlink(entry.input, distDir);
21
19
  } else {
20
+ let srcDir;
21
+ if (typeof entry.input === "string" && !entry.input.endsWith("/")) {
22
+ srcDir = ctx.options.isLib ? pathDirname(entry.input) : entry.input;
23
+ relinka(
24
+ "verbose",
25
+ `[mkdist] Using directory from file path: ${srcDir} (from: ${entry.input})`
26
+ );
27
+ } else {
28
+ srcDir = entry.input;
29
+ relinka("verbose", `[mkdist] Using directory directly: ${srcDir}`);
30
+ }
22
31
  const mkdistOptions = {
23
- cleanDist: true,
32
+ cleanDist: false,
24
33
  distDir,
25
34
  rootDir: ctx.options.rootDir,
26
- srcDir: entry.input,
35
+ srcDir,
36
+ format: "esm",
37
+ ext: entry.ext || "js",
27
38
  ...entry
28
39
  };
40
+ relinka(
41
+ "verbose",
42
+ `[mkdist] Building with options: srcDir=${mkdistOptions.srcDir}, distDir=${mkdistOptions.distDir}, rootDir=${mkdistOptions.rootDir}`
43
+ );
29
44
  await ctx.hooks.callHook(
30
45
  "mkdist:entry:options",
31
46
  ctx,
@@ -35,7 +50,8 @@ export async function mkdistBuild(ctx) {
35
50
  const output = await mkdist(mkdistOptions);
36
51
  ctx.buildEntries.push({
37
52
  chunks: output.writtenFiles.map((p) => relative(ctx.options.outDir, p)),
38
- path: distDir
53
+ path: distDir,
54
+ isLib: ctx.options.isLib
39
55
  });
40
56
  await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
41
57
  if (output.errors) {
@@ -0,0 +1,15 @@
1
+ import type { MkdistOptions } from "mkdist";
2
+ import type { BaseBuildEntry, BuildContext } from "../types.js";
3
+ export type MkdistBuildEntry = _BaseAndMkdist & {
4
+ builder: "mkdist";
5
+ };
6
+ export type MkdistHooks = {
7
+ "mkdist:done": (ctx: BuildContext) => Promise<void> | void;
8
+ "mkdist:entries": (ctx: BuildContext, entries: MkdistBuildEntry[]) => Promise<void> | void;
9
+ "mkdist:entry:build": (ctx: BuildContext, entry: MkdistBuildEntry, output: {
10
+ writtenFiles: string[];
11
+ }) => Promise<void> | void;
12
+ "mkdist:entry:options": (ctx: BuildContext, entry: MkdistBuildEntry, options: MkdistOptions) => Promise<void> | void;
13
+ };
14
+ type _BaseAndMkdist = BaseBuildEntry & MkdistOptions;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { BuildContext } from "../types.js";
2
+ export declare function rollupBuild(ctx: BuildContext): Promise<void>;
@@ -43,7 +43,8 @@ export async function rollupBuild(ctx) {
43
43
  bytes: mod.renderedLength,
44
44
  id
45
45
  })),
46
- path: entry.fileName
46
+ path: entry.fileName,
47
+ isLib: ctx.options.isLib
47
48
  });
48
49
  }
49
50
  }
@@ -0,0 +1,2 @@
1
+ import type { BuildContext, RollupOptions } from "../types.js";
2
+ export declare function getRollupOptions(ctx: BuildContext): RollupOptions;
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "rollup";
2
+ import type { BuildContext } from "../../types.js";
3
+ export declare function cjsPlugin(): Plugin;
4
+ export declare function fixCJSExportTypePlugin(ctx: BuildContext): Plugin;
@@ -0,0 +1,13 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { CommonOptions, Loader } from "esbuild";
3
+ import type { Plugin } from "rollup";
4
+ export type EsbuildOptions = CommonOptions & {
5
+ exclude?: FilterPattern;
6
+ include?: FilterPattern;
7
+ /**
8
+ * Map extension to transpileEsbuild loader
9
+ * Note that each entry (the extension) needs to start with a dot
10
+ */
11
+ loaders?: Record<string, false | Loader>;
12
+ };
13
+ export declare function esbuild(options: EsbuildOptions): Plugin;
@@ -0,0 +1,3 @@
1
+ import type { RollupJsonOptions } from "@rollup/plugin-json";
2
+ import type { Plugin } from "rollup";
3
+ export declare function JSONPlugin(options: RollupJsonOptions): Plugin;
@@ -0,0 +1,8 @@
1
+ import type { FilterPattern } from "@rollup/pluginutils";
2
+ import type { Plugin } from "rollup";
3
+ type RawLoaderOptions = {
4
+ exclude?: FilterPattern;
5
+ include?: FilterPattern;
6
+ };
7
+ export declare function rawPlugin(opts?: RawLoaderOptions): Plugin;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Plugin } from "rollup";
2
+ export declare function getShebang(code: string, append?: string): string;
3
+ export declare function makeExecutable(filePath: string): Promise<void>;
4
+ export declare function removeShebangPlugin(): Plugin;
5
+ export declare function shebangPlugin(): Plugin;
@@ -0,0 +1,2 @@
1
+ import type { BuildContext } from "../types.js";
2
+ export declare function rollupStub(ctx: BuildContext): Promise<void>;
@@ -0,0 +1,95 @@
1
+ import type { RollupAliasOptions } from "@rollup/plugin-alias";
2
+ import type { RollupCommonJSOptions } from "@rollup/plugin-commonjs";
3
+ import type { RollupJsonOptions } from "@rollup/plugin-json";
4
+ import type { RollupNodeResolveOptions } from "@rollup/plugin-node-resolve";
5
+ import type { RollupReplaceOptions } from "@rollup/plugin-replace";
6
+ import type { RollupOptions as _RollupOptions, OutputOptions, Plugin, RollupBuild } from "rollup";
7
+ import type { Options as RollupDtsOptions } from "rollup-plugin-dts";
8
+ import type { BaseBuildEntry, BuildContext } from "../types.js";
9
+ import type { EsbuildOptions } from "./plugins/esbuild.js";
10
+ export type RollupBuildEntry = BaseBuildEntry & {
11
+ builder: "rollup";
12
+ };
13
+ export type RollupBuildOptions = {
14
+ /**
15
+ * Alias plugin options
16
+ * Set to `false` to disable the plugin.
17
+ * Read more: [@rollup/plugin-alias](https://npmjs.com/package/@rollup/plugin-alias)
18
+ */
19
+ alias: false | RollupAliasOptions;
20
+ /**
21
+ * If enabled, dler generates CommonJS polyfills for ESM builds.
22
+ */
23
+ cjsBridge?: boolean;
24
+ /**
25
+ * CommonJS plugin options
26
+ * Set to `false` to disable the plugin.
27
+ * Read more: [@rollup/plugin-commonjs](https://npmjs.com/package/@rollup/plugin-commonjs)
28
+ */
29
+ commonjs: false | RollupCommonJSOptions;
30
+ /**
31
+ * DTS plugin options
32
+ * Set to `false` to disable the plugin.
33
+ * Read more: [rollup-plugin-dts](https://npmjs.com/package/rollup-plugin-dts)
34
+ */
35
+ dts: RollupDtsOptions;
36
+ /**
37
+ * If enabled, dler generates a CommonJS build in addition to the ESM build.
38
+ */
39
+ emitCJS?: boolean;
40
+ /**
41
+ * ESBuild plugin options
42
+ * Set to `false` to disable the plugin.
43
+ * Read more: [transpileEsbuild](https://npmjs.com/package/transpileEsbuild)
44
+ */
45
+ esbuild: EsbuildOptions | false;
46
+ /**
47
+ * Whether to inline dependencies not explicitly set in "dependencies" or "peerDependencies" or as marked externals to the bundle.
48
+ *
49
+ * If set to true, all such dependencies will be inlined.
50
+ * If an array of string or regular expressions is passed, these will be used to determine whether to inline such a dependency.
51
+ */
52
+ inlineDependencies?: (RegExp | string)[] | boolean;
53
+ /**
54
+ * JSON plugin options
55
+ * Set to `false` to disable the plugin.
56
+ * Read more: [@rollup/plugin-json](https://npmjs.com/package/@rollup/plugin-json)
57
+ */
58
+ json: false | RollupJsonOptions;
59
+ /**
60
+ * Rollup [Output Options](https://rollupjs.org/configuration-options)
61
+ */
62
+ output?: OutputOptions;
63
+ /**
64
+ * Preserve dynamic imports as-is
65
+ */
66
+ preserveDynamicImports?: boolean;
67
+ /**
68
+ * Replace plugin options
69
+ * Set to `false` to disable the plugin.
70
+ * Read more: [@rollup/plugin-replace](https://npmjs.com/package/@rollup/plugin-replace)
71
+ */
72
+ replace: false | RollupReplaceOptions;
73
+ /**
74
+ * Resolve plugin options
75
+ * Set to `false` to disable the plugin.
76
+ * Read more: [@rollup/plugin-node-resolve](https://npmjs.com/package/@rollup/plugin-node-resolve)
77
+ */
78
+ resolve: false | RollupNodeResolveOptions;
79
+ /**
80
+ * Enable experimental active watcher
81
+ *
82
+ * @experimental
83
+ */
84
+ watch?: boolean;
85
+ };
86
+ export type RollupHooks = {
87
+ "rollup:build": (ctx: BuildContext, build: RollupBuild) => Promise<void> | void;
88
+ "rollup:done": (ctx: BuildContext) => Promise<void> | void;
89
+ "rollup:dts:build": (ctx: BuildContext, build: RollupBuild) => Promise<void> | void;
90
+ "rollup:dts:options": (ctx: BuildContext, options: RollupOptions) => Promise<void> | void;
91
+ "rollup:options": (ctx: BuildContext, options: RollupOptions) => Promise<void> | void;
92
+ };
93
+ export type RollupOptions = _RollupOptions & {
94
+ plugins: Plugin[];
95
+ };
@@ -0,0 +1,5 @@
1
+ import type { PreRenderedChunk } from "rollup";
2
+ import type { BuildContext } from "../types.js";
3
+ export declare const DEFAULT_EXTENSIONS: string[];
4
+ export declare function getChunkFilename(ctx: BuildContext, chunk: PreRenderedChunk, ext: string): string;
5
+ export declare function resolveAliases(ctx: BuildContext): Record<string, string>;
@@ -0,0 +1,2 @@
1
+ import type { RollupOptions } from "../types.js";
2
+ export declare function rollupWatch(rollupOptions: RollupOptions): void;
@@ -0,0 +1,176 @@
1
+ import type { Hookable } from "hookable";
2
+ import type { Jiti, JitiOptions } from "jiti";
3
+ import type { PackageJson } from "pkg-types";
4
+ import type { WatcherOptions } from "rollup";
5
+ import type { CopyBuildEntry, CopyHooks } from "./copy/types.js";
6
+ import type { MkdistBuildEntry, MkdistHooks } from "./mkdist/types.js";
7
+ import type { RollupBuildEntry, RollupBuildOptions, RollupHooks } from "./rollup/types.js";
8
+ import type { UntypedBuildEntry, UntypedHooks } from "./untyped/types.js";
9
+ export type BaseBuildEntry = {
10
+ builder?: "copy" | "mkdist" | "rollup" | "untyped";
11
+ declaration?: "compatible" | "node16" | boolean;
12
+ input: string;
13
+ name?: string;
14
+ outDir?: string;
15
+ isLib: boolean;
16
+ };
17
+ export type { CopyBuildEntry } from "./copy/types.js";
18
+ export type { MkdistBuildEntry } from "./mkdist/types.js";
19
+ /** Bundler types */
20
+ export type { RollupBuildEntry, RollupBuildOptions, RollupOptions, } from "./rollup/types.js";
21
+ export type { UntypedBuildEntry, UntypedOutput, UntypedOutputs, } from "./untyped/types.js";
22
+ export type BuildContext = {
23
+ buildEntries: {
24
+ bytes?: number;
25
+ chunk?: boolean;
26
+ chunks?: string[];
27
+ exports?: string[];
28
+ modules?: {
29
+ bytes: number;
30
+ id: string;
31
+ }[];
32
+ path: string;
33
+ isLib: boolean;
34
+ }[];
35
+ hooks: Hookable<BuildHooks>;
36
+ jiti: Jiti;
37
+ options: BuildOptions;
38
+ pkg: PackageJson;
39
+ usedImports: Set<string>;
40
+ warnings: Set<string>;
41
+ isLib: boolean;
42
+ };
43
+ export type BuildEntry = BaseBuildEntry | CopyBuildEntry | MkdistBuildEntry | RollupBuildEntry | UntypedBuildEntry;
44
+ export type BuildHooks = CopyHooks & MkdistHooks & RollupHooks & UntypedHooks & {
45
+ "build:before": (ctx: BuildContext) => Promise<void> | void;
46
+ "build:done": (ctx: BuildContext) => Promise<void> | void;
47
+ "build:prepare": (ctx: BuildContext) => Promise<void> | void;
48
+ };
49
+ export type BuildOptions = {
50
+ /**
51
+ * Create aliases for module imports to reference modules in code using more concise paths.
52
+ * Allow you to specify an alias for the module path.
53
+ */
54
+ alias: Record<string, string>;
55
+ /**
56
+ * Clean the output directory before building.
57
+ */
58
+ clean: boolean;
59
+ /**
60
+ * Whether to generate declaration files.
61
+ * * `compatible` means "src/index.ts" will generate "dist/index.d.mts", "dist/index.d.cts" and "dist/index.d.ts".
62
+ * * `node16` means "src/index.ts" will generate "dist/index.d.mts" and "dist/index.d.cts".
63
+ * * `true` is equivalent to `compatible`.
64
+ * * `false` will disable declaration generation.
65
+ * * `undefined` will auto detect based on "package.json". If "package.json" has "types" field, it will be `"compatible"`, otherwise `false`.
66
+ */
67
+ declaration?: "compatible" | "node16" | boolean;
68
+ dependencies: string[];
69
+ devDependencies: string[];
70
+ /**
71
+ * Build entries.
72
+ */
73
+ entries: BuildEntry[];
74
+ /**
75
+ * Used to specify which modules or libraries should be considered
76
+ * external dependencies and not included in the final build product.
77
+ */
78
+ externals: (RegExp | string)[];
79
+ /**
80
+ * Terminate the build process when a warning appears
81
+ */
82
+ failOnWarn?: boolean;
83
+ /**
84
+ * Whether the current build is for a library.
85
+ */
86
+ isLib: boolean;
87
+ /**
88
+ * The name of the project.
89
+ */
90
+ name: string;
91
+ /**
92
+ * Output directory.
93
+ */
94
+ outDir: string;
95
+ /**
96
+ * Run different types of builds (untyped, mkdist, Rollup, copy) simultaneously.
97
+ */
98
+ parallel: boolean;
99
+ peerDependencies: string[];
100
+ /**
101
+ * Replace the text in the source code with rules.
102
+ */
103
+ replace: Record<string, string>;
104
+ /**
105
+ * [Rollup](https://rollupjs.org/configuration-options) Build Options
106
+ */
107
+ rollup: RollupBuildOptions;
108
+ /**
109
+ * The root directory of the project.
110
+ */
111
+ rootDir: string;
112
+ /**
113
+ * Hide output logs during the build process.
114
+ * When true, suppresses non-essential console output.
115
+ */
116
+ showOutLog?: boolean;
117
+ /**
118
+ * @experimental
119
+ * Generate source mapping file.
120
+ */
121
+ transpileSourcemap: boolean;
122
+ /**
123
+ * Whether to build with JIT transpileStubs.
124
+ * Read more: [transpileStubbing](https://antfu.me/posts/publish-esm-and-cjs#transpileStubbing)
125
+ */
126
+ transpileStub: boolean;
127
+ /**
128
+ * Stub options, where [jiti](https://github.com/unjs/jiti)
129
+ * is an object of type `Omit<JitiOptions, "transform" | "onError">`.
130
+ */
131
+ transpileStubOptions: {
132
+ jiti: Omit<JitiOptions, "onError" | "transform">;
133
+ };
134
+ /**
135
+ * Whether to build and actively transpileWatch the file changes.
136
+ *
137
+ * @experimental This feature is experimental and incomplete.
138
+ */
139
+ transpileWatch: boolean;
140
+ /**
141
+ * Watch mode options.
142
+ */
143
+ transpileWatchOptions: undefined | WatcherOptions;
144
+ };
145
+ export type BuildPreset = (() => UnifiedBuildConfig) | UnifiedBuildConfig;
146
+ /**
147
+ * In addition to basic `entries`, `presets`, and `hooks`,
148
+ * there are also all the properties of `BuildOptions` except for BuildOptions's `entries`.
149
+ */
150
+ export type UnifiedBuildConfig = DeepPartial<Omit<BuildOptions, "entries">> & {
151
+ /**
152
+ * Specify the entry file or entry module during the construction process.
153
+ */
154
+ entries?: (BuildEntry | string)[];
155
+ /**
156
+ * Used to define hook functions during the construction process to perform custom operations during specific construction stages.
157
+ * This configuration allows you to insert custom logic during the build process to meet specific requirements or perform additional operations.
158
+ */
159
+ hooks?: Partial<BuildHooks>;
160
+ /**
161
+ * Used to specify the preset build configuration.
162
+ */
163
+ preset?: BuildPreset | string;
164
+ /**
165
+ * Used to create a stub for the build configuration.
166
+ * A stub is a simplified version of a mock object that is used to simulate the behavior of a real object.
167
+ * It is used to test the behavior of the object under test.
168
+ * @see https://turing.com/kb/stub-vs-mock#what-exactly-is-a-stub?
169
+ */
170
+ stub?: boolean;
171
+ };
172
+ type DeepPartial<T> = {
173
+ [P in keyof T]?: DeepPartial<T[P]>;
174
+ };
175
+ export declare function defineBuildConfig(config: UnifiedBuildConfig | UnifiedBuildConfig[]): UnifiedBuildConfig[];
176
+ export declare function definePreset(preset: BuildPreset): BuildPreset;
@@ -0,0 +1,2 @@
1
+ import type { BuildContext } from "../types.js";
2
+ export declare function typesBuild(ctx: BuildContext): Promise<void>;
@@ -69,8 +69,8 @@ export async function typesBuild(ctx) {
69
69
  declaration: entry.declaration ? {
70
70
  contents: generateTypes(schema, {
71
71
  interfaceName: pascalCase(`${entry.name}-schema`)
72
- // addDefaults: true, // TODO: Add JSDoc default values (allow to configure via .config/dler.ts)
73
- // addDescription: true, // TODO: Add JSDoc descriptions (allow to configure via .config/dler.ts)
72
+ // addDefaults: true, // TODO: Add JSDoc default values (allow to configure via dler.config.ts)
73
+ // addDescription: true, // TODO: Add JSDoc descriptions (allow to configure via dler.config.ts)
74
74
  }),
75
75
  fileName: `${entry.name}.d.ts`
76
76
  } : void 0,
@@ -0,0 +1,23 @@
1
+ import type { Schema } from "untyped";
2
+ import type { BaseBuildEntry, BuildContext } from "../types.js";
3
+ export type UntypedBuildEntry = BaseBuildEntry & {
4
+ builder: "untyped";
5
+ defaults?: Record<string, any>;
6
+ };
7
+ export type UntypedHooks = {
8
+ "untyped:done": (ctx: BuildContext) => Promise<void> | void;
9
+ "untyped:entries": (ctx: BuildContext, entries: UntypedBuildEntry[]) => Promise<void> | void;
10
+ "untyped:entry:options": (ctx: BuildContext, entry: UntypedBuildEntry, options: any) => Promise<void> | void;
11
+ "untyped:entry:outputs": (ctx: BuildContext, entry: UntypedBuildEntry, outputs: UntypedOutputs) => Promise<void> | void;
12
+ "untyped:entry:schema": (ctx: BuildContext, entry: UntypedBuildEntry, schema: Schema) => Promise<void> | void;
13
+ };
14
+ export type UntypedOutput = {
15
+ contents: string;
16
+ fileName: string;
17
+ };
18
+ export type UntypedOutputs = {
19
+ declaration?: UntypedOutput;
20
+ defaults: UntypedOutput;
21
+ markdown: UntypedOutput;
22
+ schema: UntypedOutput;
23
+ };
@@ -0,0 +1,20 @@
1
+ import type { PackageJson } from "pkg-types";
2
+ import type { BuildContext, BuildPreset, UnifiedBuildConfig } from "./types.js";
3
+ type OutputDescriptor = {
4
+ file: string;
5
+ type?: "cjs" | "esm";
6
+ };
7
+ export declare function arrayIncludes(arr: (RegExp | string)[], searchElement: string): boolean;
8
+ export declare function dumpObject(obj: Record<string, any>): string;
9
+ export declare function ensuredir(path: string): Promise<void>;
10
+ export declare function extractExportFilenames(exports: PackageJson["exports"], conditions?: string[]): OutputDescriptor[];
11
+ export declare function getpkg(id?: string): string;
12
+ export declare function inferPkgExternals(pkg: PackageJson): (RegExp | string)[];
13
+ export declare function listRecursively(path: string): string[];
14
+ export declare function removeExtension(filename: string): string;
15
+ export declare function resolvePreset(preset: BuildPreset | string, rootDir: string): Promise<UnifiedBuildConfig>;
16
+ export declare function rmdir(dir: string): Promise<void>;
17
+ export declare function symlink(from: string, to: string, force?: boolean): Promise<void>;
18
+ export declare function warn(ctx: BuildContext, message: string): void;
19
+ export declare function withTrailingSlash(path: string): string;
20
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { PackageJson } from "pkg-types";
2
+ import type { BuildContext } from "./types.js";
3
+ export declare function validateDependencies(ctx: BuildContext): void;
4
+ export declare function validatePackage(pkg: PackageJson, rootDir: string, ctx: BuildContext): void;
@@ -0,0 +1,11 @@
1
+ import type { BundlerName, Esbuild, ExcludeMode, LibConfig, NpmOutExt, Sourcemap, transpileFormat, transpileTarget } from "../sdk-types.js";
2
+ import type { PerfTimer } from "./utils/utils-perf.js";
3
+ /**
4
+ * Processes libraries based on build mode.
5
+ */
6
+ export declare function processLibraryFlow(timer: PerfTimer, isDev: boolean, libsActMode: string, libsList: Record<string, LibConfig>, distJsrDryRun: boolean, distJsrFailOnWarn: boolean, libsDirDist: string, libsDirSrc: string, commonPubPause: boolean, commonPubRegistry: string, unifiedBundlerOutExt: NpmOutExt, distNpmBuilder: BundlerName, coreEntrySrcDir: string, rmDepsMode: ExcludeMode, rmDepsPatterns: string[], transpileEsbuild: Esbuild, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, distJsrBuilder: BundlerName, transpileStub: boolean, transpileWatch: boolean, distJsrOutFilesExt: NpmOutExt): Promise<void>;
7
+ /**
8
+ * Processes all libs defined in config.libsList.
9
+ * Builds and optionally publishes each library based on configuration.
10
+ */
11
+ export declare function libraries_buildPublish(isDev: boolean, timer: PerfTimer, libsList: Record<string, LibConfig>, distJsrDryRun: boolean, distJsrFailOnWarn: boolean, libsDirDist: string, libsDirSrc: string, commonPubPause: boolean, commonPubRegistry: string, unifiedBundlerOutExt: NpmOutExt, distNpmBuilder: BundlerName, coreEntrySrcDir: string, rmDepsMode: ExcludeMode, rmDepsPatterns: string[], transpileEsbuild: Esbuild, transpileTarget: transpileTarget, transpileFormat: transpileFormat, transpileSplitting: boolean, transpileSourcemap: Sourcemap, transpilePublicPath: string, distJsrBuilder: BundlerName, transpileStub: boolean, transpileWatch: boolean, distJsrOutFilesExt: NpmOutExt): Promise<void>;