@reliverse/dler 1.4.7 → 1.5.1

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 (48) hide show
  1. package/README.md +8 -8
  2. package/bin/{addons.js → app/agg/run.js} +1 -1
  3. package/bin/app/build/cmd.js +2 -2
  4. package/bin/app/build/impl.js +97 -0
  5. package/bin/app/cmds.d.ts +41 -0
  6. package/bin/app/cmds.js +3 -0
  7. package/bin/app/pub/cmd.js +2 -2
  8. package/bin/app/relifso/cmd.js +13 -1
  9. package/bin/app/relifso/rename/cmd.d.ts +27 -0
  10. package/bin/app/relifso/rename/cmd.js +126 -0
  11. package/bin/{dler.js → cli.js} +2 -2
  12. package/bin/{init.js → init/init.js} +22 -4
  13. package/bin/{load.d.ts → init/load.d.ts} +1 -1
  14. package/bin/{load.js → init/load.js} +1 -1
  15. package/bin/{default.d.ts → libs/sdk/default.d.ts} +1 -1
  16. package/bin/{default.js → libs/sdk/default.js} +21 -10
  17. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +20 -28
  18. package/bin/libs/sdk/sdk-impl/build/build-library.js +12 -21
  19. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +4 -11
  20. package/bin/libs/sdk/sdk-impl/build/build-regular.js +161 -118
  21. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +11 -4
  22. package/bin/libs/sdk/sdk-impl/library-flow.js +29 -29
  23. package/bin/libs/sdk/sdk-impl/pub/pub-library.d.ts +1 -1
  24. package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +1 -1
  25. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -9
  26. package/bin/libs/sdk/sdk-impl/regular-flow.js +91 -142
  27. package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +1 -2
  28. package/bin/libs/sdk/sdk-impl/utils/finalize.js +1 -3
  29. package/bin/libs/sdk/sdk-impl/utils/utils-build.js +8 -5
  30. package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +2 -2
  31. package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +31 -7
  32. package/bin/libs/sdk/sdk-impl/utils/utils-error.d.ts +1 -1
  33. package/bin/libs/sdk/sdk-impl/utils/utils-perf.d.ts +1 -5
  34. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.d.ts +2 -2
  35. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.js +72 -91
  36. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.d.ts +2 -2
  37. package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +19 -44
  38. package/bin/libs/sdk/sdk-mod.d.ts +0 -1
  39. package/bin/libs/sdk/sdk-types.d.ts +41 -20
  40. package/bin/mod.js +1 -1
  41. package/package.json +5 -19
  42. package/bin/impl.js +0 -219
  43. /package/bin/{addons.d.ts → app/agg/run.d.ts} +0 -0
  44. /package/bin/{impl.d.ts → app/build/impl.d.ts} +0 -0
  45. /package/bin/{dler.d.ts → cli.d.ts} +0 -0
  46. /package/bin/{info.d.ts → init/info.d.ts} +0 -0
  47. /package/bin/{info.js → init/info.js} +0 -0
  48. /package/bin/{init.d.ts → init/init.d.ts} +0 -0
@@ -6,15 +6,15 @@ import {
6
6
  } from "./build/build-regular.js";
7
7
  import { regular_pubToJsr, regular_pubToNpm } from "./pub/pub-regular.js";
8
8
  import { CONCURRENCY_DEFAULT } from "./utils/utils-consts.js";
9
- export async function processRegularFlow(timer, isDev, coreIsCLI, libsActMode, commonPubRegistry, coreEntrySrcDir, distNpmDirName, distNpmBuilder, coreEntryFile, distJsrDryRun, distJsrFailOnWarn, commonPubPause, distJsrDirName, distJsrBuilder, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, distJsrAllowDirty, distJsrSlowTypes, distNpmOutFilesExt, rmDepsMode, transpileStub, transpileWatch, distJsrGenTsconfig, coreDeclarations, config) {
10
- if (libsActMode === "libs-only") {
9
+ export async function processRegularFlow(timer, isDev, config) {
10
+ if (config.libsActMode === "libs-only") {
11
11
  relinka(
12
12
  "log",
13
13
  "Skipping main project build/publish as libsActMode is set to 'libs-only'"
14
14
  );
15
15
  return;
16
16
  }
17
- switch (commonPubRegistry) {
17
+ switch (config.commonPubRegistry) {
18
18
  case "jsr":
19
19
  relinka(
20
20
  "log",
@@ -23,34 +23,33 @@ export async function processRegularFlow(timer, isDev, coreIsCLI, libsActMode, c
23
23
  await regular_buildJsrDist(
24
24
  isDev,
25
25
  true,
26
- coreIsCLI,
27
- coreEntrySrcDir,
28
- distJsrDirName,
29
- distJsrBuilder,
30
- coreEntryFile,
31
- transpileTarget,
32
- transpileFormat,
33
- transpileSplitting,
34
- transpileMinify,
35
- transpileSourcemap,
36
- transpilePublicPath,
37
- distNpmOutFilesExt,
38
- rmDepsMode,
26
+ config.coreIsCLI,
27
+ config.coreEntrySrcDir,
28
+ config.distJsrDirName,
29
+ config.distJsrBuilder,
30
+ config.coreEntryFile,
31
+ config.transpileTarget,
32
+ config.transpileFormat,
33
+ config.transpileSplitting,
34
+ config.transpileMinify,
35
+ config.transpileSourcemap,
36
+ config.transpilePublicPath,
37
+ config.distNpmOutFilesExt,
38
+ config,
39
39
  timer,
40
- transpileStub,
41
- transpileWatch,
42
- distJsrGenTsconfig,
43
- coreDeclarations,
44
- config
40
+ config.transpileStub,
41
+ config.transpileWatch,
42
+ config.distJsrGenTsconfig,
43
+ config.coreDeclarations
45
44
  );
46
45
  await regular_pubToJsr(
47
- distJsrDryRun,
48
- distJsrFailOnWarn,
46
+ config.distJsrDryRun,
47
+ config.distJsrFailOnWarn,
49
48
  isDev,
50
- commonPubPause,
51
- distJsrDirName,
52
- distJsrAllowDirty,
53
- distJsrSlowTypes,
49
+ config.commonPubPause,
50
+ config.distJsrDirName,
51
+ config.distJsrAllowDirty,
52
+ config.distJsrSlowTypes,
54
53
  timer
55
54
  );
56
55
  break;
@@ -61,30 +60,29 @@ export async function processRegularFlow(timer, isDev, coreIsCLI, libsActMode, c
61
60
  );
62
61
  await regular_buildNpmDist(
63
62
  isDev,
64
- coreEntrySrcDir,
65
- distNpmDirName,
66
- distNpmBuilder,
67
- coreEntryFile,
68
- distNpmOutFilesExt,
69
- rmDepsMode,
70
- coreIsCLI,
71
- transpileTarget,
72
- transpileFormat,
73
- transpileSplitting,
74
- transpileMinify,
75
- transpileSourcemap,
76
- transpilePublicPath,
77
- transpileStub,
78
- transpileWatch,
63
+ config.coreEntrySrcDir,
64
+ config.distNpmDirName,
65
+ config.distNpmBuilder,
66
+ config.coreEntryFile,
67
+ config.distNpmOutFilesExt,
68
+ config,
69
+ config.coreIsCLI,
70
+ config.transpileTarget,
71
+ config.transpileFormat,
72
+ config.transpileSplitting,
73
+ config.transpileMinify,
74
+ config.transpileSourcemap,
75
+ config.transpilePublicPath,
76
+ config.transpileStub,
77
+ config.transpileWatch,
79
78
  timer,
80
- coreDeclarations,
81
- config
79
+ config.coreDeclarations
82
80
  );
83
81
  await regular_pubToNpm(
84
- distJsrDryRun,
82
+ config.distJsrDryRun,
85
83
  isDev,
86
- commonPubPause,
87
- distNpmDirName,
84
+ config.commonPubPause,
85
+ config.distNpmDirName,
88
86
  timer
89
87
  );
90
88
  break;
@@ -97,123 +95,74 @@ export async function processRegularFlow(timer, isDev, coreIsCLI, libsActMode, c
97
95
  () => regular_buildJsrDist(
98
96
  isDev,
99
97
  true,
100
- coreIsCLI,
101
- coreEntrySrcDir,
102
- distJsrDirName,
103
- distJsrBuilder,
104
- coreEntryFile,
105
- transpileTarget,
106
- transpileFormat,
107
- transpileSplitting,
108
- transpileMinify,
109
- transpileSourcemap,
110
- transpilePublicPath,
111
- distNpmOutFilesExt,
112
- rmDepsMode,
98
+ config.coreIsCLI,
99
+ config.coreEntrySrcDir,
100
+ config.distJsrDirName,
101
+ config.distJsrBuilder,
102
+ config.coreEntryFile,
103
+ config.transpileTarget,
104
+ config.transpileFormat,
105
+ config.transpileSplitting,
106
+ config.transpileMinify,
107
+ config.transpileSourcemap,
108
+ config.transpilePublicPath,
109
+ config.distNpmOutFilesExt,
110
+ config,
113
111
  timer,
114
- transpileStub,
115
- transpileWatch,
116
- distJsrGenTsconfig,
117
- coreDeclarations,
118
- config
112
+ config.transpileStub,
113
+ config.transpileWatch,
114
+ config.distJsrGenTsconfig,
115
+ config.coreDeclarations
119
116
  ),
120
117
  () => regular_buildNpmDist(
121
118
  isDev,
122
- coreEntrySrcDir,
123
- distNpmDirName,
124
- distNpmBuilder,
125
- coreEntryFile,
126
- distNpmOutFilesExt,
127
- rmDepsMode,
128
- coreIsCLI,
129
- transpileTarget,
130
- transpileFormat,
131
- transpileSplitting,
132
- transpileMinify,
133
- transpileSourcemap,
134
- transpilePublicPath,
135
- transpileStub,
136
- transpileWatch,
119
+ config.coreEntrySrcDir,
120
+ config.distNpmDirName,
121
+ config.distNpmBuilder,
122
+ config.coreEntryFile,
123
+ config.distNpmOutFilesExt,
124
+ config,
125
+ config.coreIsCLI,
126
+ config.transpileTarget,
127
+ config.transpileFormat,
128
+ config.transpileSplitting,
129
+ config.transpileMinify,
130
+ config.transpileSourcemap,
131
+ config.transpilePublicPath,
132
+ config.transpileStub,
133
+ config.transpileWatch,
137
134
  timer,
138
- coreDeclarations,
139
- config
135
+ config.coreDeclarations
140
136
  )
141
137
  ];
142
138
  await pAll(buildTasks, { concurrency: CONCURRENCY_DEFAULT });
143
139
  const publishTasks = [
144
140
  () => regular_pubToJsr(
145
- distJsrDryRun,
146
- distJsrFailOnWarn,
141
+ config.distJsrDryRun,
142
+ config.distJsrFailOnWarn,
147
143
  isDev,
148
- commonPubPause,
149
- distJsrDirName,
150
- distJsrAllowDirty,
151
- distJsrSlowTypes,
144
+ config.commonPubPause,
145
+ config.distJsrDirName,
146
+ config.distJsrAllowDirty,
147
+ config.distJsrSlowTypes,
152
148
  timer
153
149
  ),
154
150
  () => regular_pubToNpm(
155
- distJsrDryRun,
151
+ config.distJsrDryRun,
156
152
  isDev,
157
- commonPubPause,
158
- distNpmDirName,
153
+ config.commonPubPause,
154
+ config.distNpmDirName,
159
155
  timer
160
156
  )
161
157
  ];
162
158
  await pAll(publishTasks, { concurrency: CONCURRENCY_DEFAULT });
163
159
  break;
164
160
  }
165
- default: {
161
+ default:
166
162
  relinka(
167
- "warn",
168
- `Registry "${commonPubRegistry}" not recognized. Building main project only...`
163
+ "error",
164
+ `Invalid commonPubRegistry: ${config.commonPubRegistry}`
169
165
  );
170
- const fallbackBuildTasks = [
171
- () => regular_buildNpmDist(
172
- isDev,
173
- coreEntrySrcDir,
174
- distNpmDirName,
175
- distNpmBuilder,
176
- coreEntryFile,
177
- distNpmOutFilesExt,
178
- rmDepsMode,
179
- coreIsCLI,
180
- transpileTarget,
181
- transpileFormat,
182
- transpileSplitting,
183
- transpileMinify,
184
- transpileSourcemap,
185
- transpilePublicPath,
186
- transpileStub,
187
- transpileWatch,
188
- timer,
189
- coreDeclarations,
190
- config
191
- ),
192
- () => regular_buildJsrDist(
193
- isDev,
194
- true,
195
- coreIsCLI,
196
- coreEntrySrcDir,
197
- distJsrDirName,
198
- distJsrBuilder,
199
- coreEntryFile,
200
- transpileTarget,
201
- transpileFormat,
202
- transpileSplitting,
203
- transpileMinify,
204
- transpileSourcemap,
205
- transpilePublicPath,
206
- distNpmOutFilesExt,
207
- rmDepsMode,
208
- timer,
209
- transpileStub,
210
- transpileWatch,
211
- distJsrGenTsconfig,
212
- coreDeclarations,
213
- config
214
- )
215
- ];
216
- await pAll(fallbackBuildTasks, { concurrency: CONCURRENCY_DEFAULT });
217
- }
166
+ throw new Error(`Invalid commonPubRegistry: ${config.commonPubRegistry}`);
218
167
  }
219
168
  }
@@ -1,5 +1,4 @@
1
- import type { LibConfig } from "../../sdk-types.js";
2
- import { type PerfTimer } from "./utils-perf.js";
1
+ import type { LibConfig, PerfTimer } from "../../sdk-types.js";
3
2
  /**
4
3
  * Finalizes the build process and reports completion.
5
4
  */
@@ -2,9 +2,7 @@ import { setBumpDisabledValueTo } from "@reliverse/bleump";
2
2
  import { relinka } from "@reliverse/relinka";
3
3
  import prettyMilliseconds from "pretty-ms";
4
4
  import { removeDistFolders } from "./utils-clean.js";
5
- import {
6
- getElapsedPerfTime
7
- } from "./utils-perf.js";
5
+ import { getElapsedPerfTime } from "./utils-perf.js";
8
6
  export async function finalizeBuildPub(timer, commonPubPause, libsList, distNpmDirName, distJsrDirName, libsDirDist) {
9
7
  if (!commonPubPause) {
10
8
  await removeDistFolders(
@@ -77,11 +77,14 @@ export async function renameEntryFile(isJsr, outDirBin, originalEntryFileBasenam
77
77
  );
78
78
  if (sourceDeclarationPath && targetDeclarationPath) {
79
79
  if (await fs.pathExists(sourceDeclarationPath)) {
80
- relinka(
81
- "verbose",
82
- `Renaming declaration ${sourceDeclarationPath} to ${targetDeclarationPath}`
83
- );
84
- await fs.rename(sourceDeclarationPath, targetDeclarationPath);
80
+ if (sourceDeclarationPath !== targetDeclarationPath) {
81
+ relinka(
82
+ "verbose",
83
+ `Renaming declaration ${sourceDeclarationPath} to ${targetDeclarationPath}`
84
+ );
85
+ await fs.rename(sourceDeclarationPath, targetDeclarationPath);
86
+ } else {
87
+ }
85
88
  } else {
86
89
  relinka(
87
90
  "verbose",
@@ -1,5 +1,5 @@
1
- import type { ExcludeMode } from "../../sdk-types.js";
1
+ import type { BuildPublishConfig } from "../../sdk-types.js";
2
2
  /**
3
3
  * Filters out development dependencies from a dependency record.
4
4
  */
5
- export declare function filterDeps(deps: Record<string, string> | undefined, clearUnused: boolean, outDirBin: string, isJsr: boolean, rmDepsMode: ExcludeMode, rmDepsPatterns: string[]): Promise<Record<string, string>>;
5
+ export declare function filterDeps(deps: Record<string, string> | undefined, clearUnused: boolean, outDirBin: string, isJsr: boolean, config: BuildPublishConfig, libName?: string): Promise<Record<string, string>>;
@@ -3,23 +3,47 @@ import { readPackageJSON } from "pkg-types";
3
3
  import { glob } from "tinyglobby";
4
4
  import { readFileSafe } from "./utils-fs.js";
5
5
  import { extractPackageName } from "./utils-misc.js";
6
- export async function filterDeps(deps, clearUnused, outDirBin, isJsr, rmDepsMode, rmDepsPatterns) {
6
+ export async function filterDeps(deps, clearUnused, outDirBin, isJsr, config, libName) {
7
7
  relinka("verbose", `Filtering dependencies (clearUnused=${clearUnused})`);
8
8
  if (!deps) return {};
9
+ const patterns = /* @__PURE__ */ new Set();
10
+ for (const pattern of config.removeDepsPatterns.global) {
11
+ patterns.add(pattern);
12
+ }
13
+ if (!isJsr) {
14
+ for (const pattern of config.removeDepsPatterns["dist-npm"]) {
15
+ patterns.add(pattern);
16
+ }
17
+ }
18
+ if (isJsr) {
19
+ for (const pattern of config.removeDepsPatterns["dist-jsr"]) {
20
+ patterns.add(pattern);
21
+ }
22
+ }
23
+ if (libName && config.removeDepsPatterns["dist-libs"][libName]) {
24
+ const libPatterns = config.removeDepsPatterns["dist-libs"][libName];
25
+ if (!isJsr) {
26
+ for (const pattern of libPatterns.npm) {
27
+ patterns.add(pattern);
28
+ }
29
+ }
30
+ if (isJsr) {
31
+ for (const pattern of libPatterns.jsr) {
32
+ patterns.add(pattern);
33
+ }
34
+ }
35
+ }
9
36
  const shouldExcludeByPattern = (depName) => {
10
- return rmDepsPatterns.some(
37
+ return Array.from(patterns).some(
11
38
  (pattern) => depName.toLowerCase().includes(pattern.toLowerCase())
12
39
  );
13
40
  };
14
41
  const originalPkg = await readPackageJSON();
15
42
  const shouldExcludeDep = (depName, isDev) => {
16
- if (rmDepsMode === "patterns-only") {
43
+ if (isJsr && config.coreIsCLI.enabled) {
17
44
  return shouldExcludeByPattern(depName);
18
45
  }
19
- if (rmDepsMode === "patterns-and-devdeps") {
20
- return isDev || shouldExcludeByPattern(depName);
21
- }
22
- return shouldExcludeByPattern(depName);
46
+ return isDev || shouldExcludeByPattern(depName);
23
47
  };
24
48
  const devDeps = deps === originalPkg.devDependencies;
25
49
  if (!clearUnused) {
@@ -1,4 +1,4 @@
1
- import { type PerfTimer } from "./utils-perf.js";
1
+ import type { PerfTimer } from "../../sdk-types.js";
2
2
  /**
3
3
  * Handles errors during the build process.
4
4
  */
@@ -1,8 +1,4 @@
1
- export type PerfTimer = {
2
- pausedAt: null | number;
3
- pausedDuration: number;
4
- startTime: number;
5
- };
1
+ import type { PerfTimer } from "../../sdk-types.js";
6
2
  export declare function createPerfTimer(): PerfTimer;
7
3
  export declare function getElapsedPerfTime(timer: PerfTimer): number;
8
4
  export declare function pausePerfTimer(timer: PerfTimer): void;
@@ -1,5 +1,5 @@
1
- import type { ExcludeMode, LibConfig, NpmOutExt } from "../../sdk-types.js";
1
+ import type { NpmOutExt, BuildPublishConfig, LibConfig } from "../../sdk-types.js";
2
2
  /**
3
3
  * Creates a package.json for a lib distribution.
4
4
  */
5
- export declare function library_createPackageJSON(libName: string, npmOutDirRoot: string, jsrOutDirRoot: string, effectivePubRegistry: "jsr" | "npm" | "npm-jsr" | undefined, libsList: Record<string, LibConfig>, rmDepsMode: ExcludeMode, rmDepsPatterns: string[], unifiedBundlerOutExt: NpmOutExt): Promise<void>;
5
+ export declare function library_createPackageJSON(libName: string, npmOutDir: string, jsrOutDir: string, effectivePubRegistry: "npm" | "jsr" | "npm-jsr" | undefined, libsList: Record<string, LibConfig>, config: BuildPublishConfig, unifiedBundlerOutExt: NpmOutExt): Promise<void>;
@@ -6,14 +6,36 @@ import {
6
6
  readPackageJSON
7
7
  } from "pkg-types";
8
8
  import { filterDeps } from "./utils-deps.js";
9
- export async function library_createPackageJSON(libName, npmOutDirRoot, jsrOutDirRoot, effectivePubRegistry, libsList, rmDepsMode, rmDepsPatterns, unifiedBundlerOutExt) {
10
- relinka(
11
- "verbose",
12
- `Generating package.json for lib ${libName} (registry: ${effectivePubRegistry})...`
13
- );
14
- if (!libsList) {
15
- throw new Error("libsList is empty or not provided");
9
+ export async function library_createPackageJSON(libName, npmOutDir, jsrOutDir, effectivePubRegistry, libsList, config, unifiedBundlerOutExt) {
10
+ relinka("verbose", `Creating package.json for library ${libName}`);
11
+ const originalPkg = await readPackageJSON();
12
+ const commonPkg = await library_createCommonPackageFields(libName, libsList);
13
+ if (effectivePubRegistry === "npm" || effectivePubRegistry === "npm-jsr") {
14
+ await library_writeNpmLibPackageJSON(
15
+ libName,
16
+ npmOutDir,
17
+ npmOutDir,
18
+ originalPkg,
19
+ commonPkg,
20
+ libsList,
21
+ config,
22
+ unifiedBundlerOutExt
23
+ );
16
24
  }
25
+ if (effectivePubRegistry === "jsr" || effectivePubRegistry === "npm-jsr") {
26
+ await library_writeJsrPackageJSON(
27
+ libName,
28
+ jsrOutDir,
29
+ jsrOutDir,
30
+ originalPkg,
31
+ commonPkg,
32
+ libsList,
33
+ config
34
+ );
35
+ }
36
+ }
37
+ async function library_createCommonPackageFields(libName, libsList) {
38
+ relinka("verbose", `Generating common package fields for ${libName}`);
17
39
  const originalPkg = await readPackageJSON();
18
40
  let { description } = originalPkg;
19
41
  const { author, keywords, license, version } = originalPkg;
@@ -55,68 +77,9 @@ export async function library_createPackageJSON(libName, npmOutDirRoot, jsrOutDi
55
77
  } else if (keywords && keywords.length > 0 && !commonPkg.keywords) {
56
78
  commonPkg.keywords = keywords;
57
79
  }
58
- switch (effectivePubRegistry) {
59
- case "jsr":
60
- relinka("verbose", `Creating JSR package.json for lib ${libName}...`);
61
- await library_writeJsrPackageJSON(
62
- libName,
63
- jsrOutDirRoot,
64
- jsrOutDirRoot,
65
- originalPkg,
66
- commonPkg,
67
- libsList,
68
- rmDepsMode,
69
- rmDepsPatterns
70
- );
71
- break;
72
- case "npm":
73
- relinka("verbose", `Creating NPM package.json for lib ${libName}...`);
74
- await library_writeNpmLibPackageJSON(
75
- libName,
76
- npmOutDirRoot,
77
- npmOutDirRoot,
78
- originalPkg,
79
- commonPkg,
80
- libsList,
81
- rmDepsMode,
82
- rmDepsPatterns,
83
- unifiedBundlerOutExt
84
- );
85
- break;
86
- case "npm-jsr":
87
- relinka("verbose", `Creating JSR package.json for lib ${libName}...`);
88
- await library_writeJsrPackageJSON(
89
- libName,
90
- jsrOutDirRoot,
91
- jsrOutDirRoot,
92
- originalPkg,
93
- commonPkg,
94
- libsList,
95
- rmDepsMode,
96
- rmDepsPatterns
97
- );
98
- relinka("verbose", `Creating NPM package.json for lib ${libName}...`);
99
- await library_writeNpmLibPackageJSON(
100
- libName,
101
- npmOutDirRoot,
102
- npmOutDirRoot,
103
- originalPkg,
104
- commonPkg,
105
- libsList,
106
- rmDepsMode,
107
- rmDepsPatterns,
108
- unifiedBundlerOutExt
109
- );
110
- break;
111
- default:
112
- relinka(
113
- "warn",
114
- `Unknown registry "${effectivePubRegistry}" for lib ${libName}. Skipping package.json generation.`
115
- );
116
- }
117
- relinka("verbose", `Completed creation of package.json for lib: ${libName}`);
80
+ return commonPkg;
118
81
  }
119
- async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr, libConfig, rmDepsMode, rmDepsPatterns) {
82
+ async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr, libConfig, config) {
120
83
  relinka("verbose", `Getting lib dependencies for: ${libName}`);
121
84
  if (!originalDeps) return {};
122
85
  if (!libConfig) {
@@ -125,8 +88,8 @@ async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr
125
88
  true,
126
89
  outDirBin,
127
90
  isJsr,
128
- rmDepsMode,
129
- rmDepsPatterns
91
+ config,
92
+ libName
130
93
  );
131
94
  relinka(
132
95
  "verbose",
@@ -140,16 +103,36 @@ async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr
140
103
  const devDeps = originalDeps === originalPkg.devDependencies;
141
104
  const result2 = Object.entries(originalDeps).reduce(
142
105
  (acc, [k, v]) => {
143
- let shouldExclude = false;
144
- if (rmDepsMode === "patterns-only") {
145
- shouldExclude = rmDepsPatterns.some(
146
- (pattern) => k.toLowerCase().includes(pattern.toLowerCase())
147
- );
148
- } else if (rmDepsMode === "patterns-and-devdeps") {
149
- shouldExclude = devDeps || rmDepsPatterns.some(
150
- (pattern) => k.toLowerCase().includes(pattern.toLowerCase())
151
- );
106
+ const patterns = /* @__PURE__ */ new Set();
107
+ for (const pattern of config.removeDepsPatterns.global) {
108
+ patterns.add(pattern);
109
+ }
110
+ if (!isJsr) {
111
+ for (const pattern of config.removeDepsPatterns["dist-npm"]) {
112
+ patterns.add(pattern);
113
+ }
114
+ }
115
+ if (isJsr) {
116
+ for (const pattern of config.removeDepsPatterns["dist-jsr"]) {
117
+ patterns.add(pattern);
118
+ }
119
+ }
120
+ if (libName && config.removeDepsPatterns["dist-libs"][libName]) {
121
+ const libPatterns = config.removeDepsPatterns["dist-libs"][libName];
122
+ if (!isJsr) {
123
+ for (const pattern of libPatterns.npm) {
124
+ patterns.add(pattern);
125
+ }
126
+ }
127
+ if (isJsr) {
128
+ for (const pattern of libPatterns.jsr) {
129
+ patterns.add(pattern);
130
+ }
131
+ }
152
132
  }
133
+ const shouldExclude = devDeps || Array.from(patterns).some(
134
+ (pattern) => k.toLowerCase().includes(pattern.toLowerCase())
135
+ );
153
136
  if (!shouldExclude) {
154
137
  acc[k] = v;
155
138
  }
@@ -180,8 +163,8 @@ async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr
180
163
  true,
181
164
  outDirBin,
182
165
  isJsr,
183
- rmDepsMode,
184
- rmDepsPatterns
166
+ config,
167
+ libName
185
168
  );
186
169
  relinka(
187
170
  "verbose",
@@ -189,7 +172,7 @@ async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr
189
172
  );
190
173
  return result;
191
174
  }
192
- async function library_writeJsrPackageJSON(libName, outDirBin, pkgJsonDir, originalPkg, commonPkg, libsList, rmDepsMode, rmDepsPatterns) {
175
+ async function library_writeJsrPackageJSON(libName, outDirBin, pkgJsonDir, originalPkg, commonPkg, libsList, config) {
193
176
  relinka("verbose", `Writing package.json for JSR lib: ${libName}`);
194
177
  if (!libsList) {
195
178
  throw new Error("libsList is empty or not provided");
@@ -225,16 +208,15 @@ async function library_writeJsrPackageJSON(libName, outDirBin, pkgJsonDir, origi
225
208
  libPkgKeepDeps: false,
226
209
  libTranspileMinify: true
227
210
  },
228
- rmDepsMode,
229
- rmDepsPatterns
211
+ config
230
212
  ),
231
213
  devDependencies: await filterDeps(
232
214
  originalPkg.devDependencies,
233
215
  true,
234
216
  outDirBin,
235
217
  true,
236
- rmDepsMode,
237
- rmDepsPatterns
218
+ config,
219
+ libName
238
220
  ),
239
221
  exports: {
240
222
  ".": "./bin/mod.ts"
@@ -245,7 +227,7 @@ async function library_writeJsrPackageJSON(libName, outDirBin, pkgJsonDir, origi
245
227
  await fs.writeJson(pkgPath, jsrPkg, { spaces: 2 });
246
228
  relinka("verbose", `Completed writing package.json for JSR lib: ${libName}`);
247
229
  }
248
- async function library_writeNpmLibPackageJSON(libName, outDirBin, pkgJsonDir, originalPkg, commonPkg, libsList, rmDepsMode, rmDepsPatterns, unifiedBundlerOutExt) {
230
+ async function library_writeNpmLibPackageJSON(libName, outDirBin, pkgJsonDir, originalPkg, commonPkg, libsList, config, unifiedBundlerOutExt) {
249
231
  relinka("verbose", `Writing package.json for NPM lib: ${libName}`);
250
232
  if (!libsList) {
251
233
  throw new Error("libsList is empty or not provided");
@@ -265,16 +247,15 @@ async function library_writeNpmLibPackageJSON(libName, outDirBin, pkgJsonDir, or
265
247
  libPkgKeepDeps: true,
266
248
  libTranspileMinify: true
267
249
  },
268
- rmDepsMode,
269
- rmDepsPatterns
250
+ config
270
251
  ),
271
252
  devDependencies: await filterDeps(
272
253
  originalPkg.devDependencies,
273
254
  true,
274
255
  outDirBin,
275
256
  false,
276
- rmDepsMode,
277
- rmDepsPatterns
257
+ config,
258
+ libName
278
259
  ),
279
260
  exports: {
280
261
  ".": `./bin/mod.${unifiedBundlerOutExt}`