@reliverse/dler 1.7.16 → 1.7.17

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 (165) hide show
  1. package/README.md +134 -206
  2. package/bin/app/agg/run.js +2 -8
  3. package/bin/app/build/cmd.js +4 -4
  4. package/bin/app/build/impl.d.ts +2 -6
  5. package/bin/app/build/impl.js +2 -46
  6. package/bin/app/conv/cmd.d.ts +8 -33
  7. package/bin/app/conv/cmd.js +185 -163
  8. package/bin/app/copy/cmd.js +1 -1
  9. package/bin/app/init/init-impl.js +3 -3
  10. package/bin/app/init/init-types.d.ts +8 -8
  11. package/bin/app/merge/cmd.d.ts +10 -24
  12. package/bin/app/merge/cmd.js +47 -464
  13. package/bin/app/migrate/codemods/anything-bun.js +1 -1
  14. package/bin/app/migrate/codemods/fs-relifso.d.ts +2 -2
  15. package/bin/app/migrate/codemods/fs-relifso.js +1 -1
  16. package/bin/app/migrate/codemods/nodenext-bundler.d.ts +2 -2
  17. package/bin/app/migrate/codemods/nodenext-bundler.js +1 -1
  18. package/bin/app/migrate/codemods/path-pathkit.d.ts +2 -2
  19. package/bin/app/migrate/codemods/path-pathkit.js +1 -1
  20. package/bin/app/migrate/codemods/readdir-glob.d.ts +2 -2
  21. package/bin/app/migrate/codemods/readdir-glob.js +1 -1
  22. package/bin/app/mkdist/cmd.js +4 -2
  23. package/bin/app/pack/cmd.d.ts +44 -0
  24. package/bin/app/pack/cmd.js +313 -0
  25. package/bin/app/pub/cmd.js +4 -4
  26. package/bin/app/pub/impl.d.ts +7 -0
  27. package/bin/app/pub/impl.js +97 -0
  28. package/bin/app/rename/cmd.js +1 -1
  29. package/bin/app/spell/cmd.d.ts +14 -5
  30. package/bin/app/spell/cmd.js +33 -33
  31. package/bin/app/spell/old.js +0 -0
  32. package/bin/app/{mock → unpack}/cmd.d.ts +10 -14
  33. package/bin/app/unpack/cmd.js +200 -0
  34. package/bin/cli.js +2 -2
  35. package/bin/libs/cfg/cfg-mod.d.ts +69 -0
  36. package/bin/libs/cfg/cfg-mod.js +61 -0
  37. package/bin/libs/cfg/rse/rse-impl/rse-biome.d.ts +2 -0
  38. package/bin/libs/cfg/rse/rse-impl/rse-biome.js +34 -0
  39. package/bin/libs/cfg/rse/rse-impl/rse-consts.d.ts +35 -0
  40. package/bin/libs/cfg/rse/rse-impl/rse-consts.js +37 -0
  41. package/bin/libs/cfg/rse/rse-impl/rse-content.d.ts +14 -0
  42. package/bin/libs/cfg/rse/rse-impl/rse-content.js +15 -0
  43. package/bin/libs/cfg/rse/rse-impl/rse-core.d.ts +14 -0
  44. package/bin/libs/cfg/rse/rse-impl/rse-core.js +63 -0
  45. package/bin/libs/cfg/rse/rse-impl/rse-create.d.ts +36 -0
  46. package/bin/libs/cfg/rse/rse-impl/rse-create.js +254 -0
  47. package/bin/libs/cfg/rse/rse-impl/rse-def-utils.d.ts +6 -0
  48. package/bin/libs/cfg/rse/rse-impl/rse-def-utils.js +225 -0
  49. package/bin/libs/cfg/rse/rse-impl/rse-default.d.ts +3 -0
  50. package/bin/libs/cfg/rse/rse-impl/rse-default.js +155 -0
  51. package/bin/libs/cfg/rse/rse-impl/rse-define.d.ts +125 -0
  52. package/bin/libs/cfg/rse/rse-impl/rse-define.js +4 -0
  53. package/bin/libs/cfg/rse/rse-impl/rse-detect.d.ts +23 -0
  54. package/bin/libs/cfg/rse/rse-impl/rse-detect.js +347 -0
  55. package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.d.ts +3 -0
  56. package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.js +186 -0
  57. package/bin/libs/cfg/rse/rse-impl/rse-inject.d.ts +1 -0
  58. package/bin/libs/cfg/rse/rse-impl/rse-inject.js +57 -0
  59. package/bin/libs/cfg/rse/rse-impl/rse-migrate.d.ts +5 -0
  60. package/bin/libs/cfg/rse/rse-impl/rse-migrate.js +56 -0
  61. package/bin/libs/cfg/rse/rse-impl/rse-path.d.ts +11 -0
  62. package/bin/libs/cfg/rse/rse-impl/rse-path.js +33 -0
  63. package/bin/libs/cfg/rse/rse-impl/rse-prompts.d.ts +5 -0
  64. package/bin/libs/cfg/rse/rse-impl/rse-prompts.js +12 -0
  65. package/bin/libs/cfg/rse/rse-impl/rse-read.d.ts +11 -0
  66. package/bin/libs/cfg/rse/rse-impl/rse-read.js +84 -0
  67. package/bin/libs/cfg/rse/rse-impl/rse-repair.d.ts +16 -0
  68. package/bin/libs/cfg/rse/rse-impl/rse-repair.js +137 -0
  69. package/bin/libs/cfg/rse/rse-impl/rse-schema.d.ts +130 -0
  70. package/bin/libs/cfg/rse/rse-impl/rse-schema.js +444 -0
  71. package/bin/libs/cfg/rse/rse-impl/rse-types.d.ts +75 -0
  72. package/bin/libs/cfg/rse/rse-impl/rse-types.js +0 -0
  73. package/bin/libs/cfg/rse/rse-impl/rse-unstable.d.ts +11 -0
  74. package/bin/libs/cfg/rse/rse-impl/rse-unstable.js +41 -0
  75. package/bin/libs/cfg/rse/rse-impl/rse-update.d.ts +10 -0
  76. package/bin/libs/cfg/rse/rse-impl/rse-update.js +152 -0
  77. package/bin/libs/cfg/rse/rse-impl/rse-utils.d.ts +17 -0
  78. package/bin/libs/cfg/rse/rse-impl/rse-utils.js +86 -0
  79. package/bin/libs/cfg/rse/rse-mod.d.ts +20 -0
  80. package/bin/libs/cfg/rse/rse-mod.js +20 -0
  81. package/bin/libs/cfg/types.d.ts +533 -0
  82. package/bin/libs/cfg/types.js +0 -0
  83. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +5 -5
  84. package/bin/libs/sdk/sdk-impl/build/build-library.js +1 -174
  85. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -1
  86. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +287 -240
  87. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +4 -4
  88. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -5
  89. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +199 -119
  90. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.d.ts +99 -0
  91. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.js +206 -0
  92. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +92 -46
  93. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +2 -2
  94. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +2 -2
  95. package/bin/libs/sdk/sdk-impl/config/default.d.ts +6 -0
  96. package/bin/libs/sdk/sdk-impl/{cfg → config}/default.js +8 -18
  97. package/bin/libs/sdk/sdk-impl/{cfg → config}/info.js +1 -1
  98. package/bin/libs/sdk/sdk-impl/{cfg → config}/init.js +53 -43
  99. package/bin/libs/sdk/sdk-impl/{cfg → config}/load.d.ts +2 -2
  100. package/bin/libs/sdk/sdk-impl/{cfg → config}/load.js +6 -6
  101. package/bin/libs/sdk/sdk-impl/config/types.d.ts +533 -0
  102. package/bin/libs/sdk/sdk-impl/config/types.js +0 -0
  103. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +2 -1
  104. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -1
  105. package/bin/libs/sdk/sdk-impl/rules/reliverse/dler-config-health/dler-config-health.js +2 -2
  106. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/deps-types.d.ts +6 -6
  107. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/filesystem.js +1 -1
  108. package/bin/libs/sdk/sdk-impl/rules/reliverse/no-index-files/no-index-files.js +1 -1
  109. package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +2 -2
  110. package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.d.ts +38 -0
  111. package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.js +474 -0
  112. package/bin/libs/sdk/sdk-impl/spell/spells.d.ts +31 -0
  113. package/bin/libs/sdk/sdk-impl/spell/spells.js +85 -0
  114. package/bin/libs/sdk/sdk-impl/utils/binary.js +1 -1
  115. package/bin/libs/sdk/sdk-impl/utils/comments.d.ts +6 -0
  116. package/bin/libs/sdk/sdk-impl/utils/comments.js +41 -0
  117. package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +2 -1
  118. package/bin/libs/sdk/sdk-impl/utils/finalize.js +1 -0
  119. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.d.ts +6 -0
  120. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.js +7 -0
  121. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.d.ts +5 -0
  122. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.js +40 -0
  123. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.d.ts +24 -0
  124. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.js +0 -0
  125. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.d.ts +17 -0
  126. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.js +46 -0
  127. package/bin/libs/sdk/sdk-impl/utils/replacements.d.ts +0 -0
  128. package/bin/libs/sdk/sdk-impl/utils/replacements.js +0 -0
  129. package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.d.ts +3 -0
  130. package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.js +194 -0
  131. package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +1 -2
  132. package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +1 -1
  133. package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +1 -1
  134. package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +1 -1
  135. package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.d.ts +4 -0
  136. package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.js +1 -0
  137. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +1 -1
  138. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.d.ts +1 -1
  139. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.d.ts +1 -1
  140. package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +1 -3
  141. package/bin/libs/sdk/sdk-impl/utils/utils-security.js +11 -10
  142. package/bin/libs/sdk/sdk-mod.d.ts +1 -6
  143. package/bin/libs/sdk/sdk-mod.js +0 -31
  144. package/bin/libs/sdk/sdk-types.d.ts +39 -582
  145. package/bin/mod.d.ts +1 -1
  146. package/bin/mod.js +1 -1
  147. package/package.json +11 -4
  148. package/bin/app/mock/cmd.js +0 -284
  149. package/bin/app/mock/mock.d.ts +0 -11
  150. package/bin/app/mock/mock.js +0 -97
  151. package/bin/libs/sdk/sdk-impl/cfg/default.d.ts +0 -5
  152. package/bin/libs/sdk/sdk-impl/cfg/define.d.ts +0 -2
  153. package/bin/libs/sdk/sdk-impl/cfg/define.js +0 -4
  154. package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +0 -10
  155. package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +0 -307
  156. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +0 -7
  157. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +0 -74
  158. package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +0 -4
  159. package/bin/libs/sdk/sdk-impl/spell/spell-mod.js +0 -87
  160. package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +0 -4
  161. package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +0 -58
  162. package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +0 -60
  163. /package/bin/{libs/sdk/sdk-impl/spell/spell-types.js → app/spell/old.d.ts} +0 -0
  164. /package/bin/libs/sdk/sdk-impl/{cfg → config}/info.d.ts +0 -0
  165. /package/bin/libs/sdk/sdk-impl/{cfg → config}/init.d.ts +0 -0
@@ -10,6 +10,7 @@ import prettyMilliseconds from "pretty-ms";
10
10
  import { glob } from "tinyglobby";
11
11
  import { createPerfTimer, getElapsedPerfTime } from "../../../utils/utils-perf.js";
12
12
  import { copyBuild } from "./copy/copy-mod.js";
13
+ import { useSpinner } from "./mkdist/mkdist-impl/utils/spinner.js";
13
14
  import { mkdistBuild } from "./mkdist/mkdist-mod.js";
14
15
  import { rollupBuild } from "./rollup/build.js";
15
16
  import { typesBuild } from "./untyped/untyped-mod.js";
@@ -72,259 +73,305 @@ export async function unifiedBuild(inputSourceDir, coreIsCLI, isLib, rootDir, in
72
73
  }
73
74
  }
74
75
  async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _transpileStubMode, _transpileWatchMode, outDir, showOutLog, isLib) {
75
- const timer = createPerfTimer();
76
- const preset = await resolvePreset(
77
- buildConfig.preset || pkg.dler?.preset || pkg.build?.preset || inputConfig.preset || "auto",
78
- rootDir
79
- );
80
- const options = defu(buildConfig, pkg.dler || pkg.build, inputConfig, preset, {
81
- alias: {},
82
- clean: false,
83
- declaration: void 0,
84
- dependencies: [],
85
- devDependencies: [],
86
- entries: [],
87
- externals: [...Module.builtinModules, ...Module.builtinModules.map((m) => `node:${m}`)],
88
- transpileFailOnWarn: true,
89
- name: (pkg?.name || "").split("/").pop() || "default",
90
- outDir,
91
- parallel: false,
92
- peerDependencies: [],
93
- replace: {},
94
- rollup: {
95
- alias: {},
96
- cjsBridge: false,
97
- commonjs: {
98
- ignoreTryCatch: true
99
- },
100
- dts: {
101
- compilerOptions: {
102
- /**
103
- * @see https://github.com/Swatinem/rollup-plugin-dts/issues/127
104
- */
105
- composite: false,
76
+ await useSpinner.withTiming(
77
+ async (buildSpinner) => {
78
+ const timer = createPerfTimer();
79
+ buildSpinner.setText("Resolving build configuration...");
80
+ const preset = await resolvePreset(
81
+ buildConfig.preset || pkg.dler?.preset || pkg.build?.preset || inputConfig.preset || "auto",
82
+ rootDir
83
+ );
84
+ const options = defu(buildConfig, pkg.dler || pkg.build, inputConfig, preset, {
85
+ alias: {},
86
+ clean: false,
87
+ declaration: void 0,
88
+ dependencies: [],
89
+ devDependencies: [],
90
+ entries: [],
91
+ externals: [...Module.builtinModules, ...Module.builtinModules.map((m) => `node:${m}`)],
92
+ transpileFailOnWarn: true,
93
+ name: (pkg?.name || "").split("/").pop() || "default",
94
+ outDir,
95
+ parallel: false,
96
+ peerDependencies: [],
97
+ replace: {},
98
+ rollup: {
99
+ alias: {},
100
+ cjsBridge: false,
101
+ commonjs: {
102
+ ignoreTryCatch: true
103
+ },
104
+ dts: {
105
+ compilerOptions: {
106
+ /**
107
+ * @see https://github.com/Swatinem/rollup-plugin-dts/issues/127
108
+ */
109
+ composite: false,
110
+ /**
111
+ * @see https://github.com/Swatinem/rollup-plugin-dts/issues/143
112
+ */
113
+ preserveSymlinks: false
114
+ },
115
+ respectExternal: true
116
+ },
117
+ emitCJS: false,
118
+ esbuild: { target: "esnext" },
119
+ inlineDependencies: false,
120
+ json: {
121
+ preferConst: true
122
+ },
123
+ output: {
124
+ /**
125
+ * @see https://v8.dev/features/import-attributes
126
+ */
127
+ importAttributesKey: "with"
128
+ },
129
+ preserveDynamicImports: true,
130
+ // Plugins
131
+ replace: {
132
+ preventAssignment: true
133
+ },
134
+ resolve: {
135
+ preferBuiltins: true
136
+ },
137
+ watch: false
138
+ },
139
+ rootDir,
140
+ showOutLog: true,
141
+ transpileSourcemap: false,
142
+ transpileStub: _transpileStubMode,
143
+ transpileStubOptions: {
106
144
  /**
107
- * @see https://github.com/Swatinem/rollup-plugin-dts/issues/143
145
+ * @see https://github.com/unjs/jiti#%EF%B8%8F-options
108
146
  */
109
- preserveSymlinks: false
147
+ jiti: {
148
+ alias: {},
149
+ interopDefault: true
150
+ }
110
151
  },
111
- respectExternal: true
112
- },
113
- emitCJS: false,
114
- esbuild: { target: "esnext" },
115
- inlineDependencies: false,
116
- json: {
117
- preferConst: true
118
- },
119
- output: {
120
- /**
121
- * @see https://v8.dev/features/import-attributes
122
- */
123
- importAttributesKey: "with"
124
- },
125
- preserveDynamicImports: true,
126
- // Plugins
127
- replace: {
128
- preventAssignment: true
129
- },
130
- resolve: {
131
- preferBuiltins: true
132
- },
133
- watch: false
134
- },
135
- rootDir,
136
- showOutLog: true,
137
- transpileSourcemap: false,
138
- transpileStub: _transpileStubMode,
139
- transpileStubOptions: {
140
- /**
141
- * @see https://github.com/unjs/jiti#%EF%B8%8F-options
142
- */
143
- jiti: {
144
- alias: {},
145
- interopDefault: true
152
+ transpileWatch: _transpileWatchMode,
153
+ transpileWatchOptions: _transpileWatchMode ? {
154
+ exclude: "node_modules/**",
155
+ include: "src/**"
156
+ } : void 0,
157
+ isLib
158
+ });
159
+ shouldStopAtStep(5);
160
+ relinka("log", "Build-specific configuration merged with defaults");
161
+ relinka("verbose", `Build options: clean=${options.clean}, parallel=${options.parallel}`);
162
+ relinka("verbose", `Declaration files: ${options.declaration ? "enabled" : "disabled"}`);
163
+ options.outDir = resolve(options.rootDir, options.outDir);
164
+ const jiti = createJiti(options.rootDir, { interopDefault: true });
165
+ buildSpinner.setText("Initializing build context...");
166
+ const ctx = {
167
+ buildEntries: [],
168
+ hooks: createHooks(),
169
+ jiti,
170
+ options,
171
+ pkg,
172
+ usedImports: /* @__PURE__ */ new Set(),
173
+ warnings: /* @__PURE__ */ new Set(),
174
+ isLib
175
+ };
176
+ if (preset.hooks) {
177
+ ctx.hooks.addHooks(preset.hooks);
146
178
  }
147
- },
148
- transpileWatch: _transpileWatchMode,
149
- transpileWatchOptions: _transpileWatchMode ? {
150
- exclude: "node_modules/**",
151
- include: "src/**"
152
- } : void 0,
153
- isLib
154
- });
155
- shouldStopAtStep(5);
156
- relinka("log", "Build-specific configuration merged with defaults");
157
- relinka("verbose", `Build options: clean=${options.clean}, parallel=${options.parallel}`);
158
- relinka("verbose", `Declaration files: ${options.declaration ? "enabled" : "disabled"}`);
159
- options.outDir = resolve(options.rootDir, options.outDir);
160
- const jiti = createJiti(options.rootDir, { interopDefault: true });
161
- const ctx = {
162
- buildEntries: [],
163
- hooks: createHooks(),
164
- jiti,
165
- options,
166
- pkg,
167
- usedImports: /* @__PURE__ */ new Set(),
168
- warnings: /* @__PURE__ */ new Set(),
169
- isLib
170
- };
171
- if (preset.hooks) {
172
- ctx.hooks.addHooks(preset.hooks);
173
- }
174
- if (inputConfig.hooks) {
175
- ctx.hooks.addHooks(inputConfig.hooks);
176
- }
177
- if (buildConfig.hooks) {
178
- ctx.hooks.addHooks(buildConfig.hooks);
179
- }
180
- await ctx.hooks.callHook("build:prepare", ctx);
181
- options.entries = options.entries.map(
182
- (entry) => typeof entry === "string" ? { input: entry, isLib } : entry
183
- );
184
- for (const entry of options.entries) {
185
- if (typeof entry.name !== "string") {
186
- let relativeInput = isAbsolute(entry.input) ? relative(rootDir, entry.input) : normalize(entry.input);
187
- if (relativeInput.startsWith("./")) {
188
- relativeInput = relativeInput.slice(2);
179
+ if (inputConfig.hooks) {
180
+ ctx.hooks.addHooks(inputConfig.hooks);
189
181
  }
190
- entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
191
- }
192
- if (!entry.input) {
193
- throw new Error(`Missing entry input: ${dumpObject(entry)}`);
194
- }
195
- if (!entry.builder) {
196
- entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
197
- }
198
- if (options.declaration !== void 0 && entry.declaration === void 0) {
199
- entry.declaration = options.declaration;
200
- }
201
- entry.input = resolve(options.rootDir, entry.input);
202
- entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
203
- entry.isLib = isLib;
204
- }
205
- options.dependencies = Object.keys(pkg.dependencies || {});
206
- options.peerDependencies = Object.keys(pkg.peerDependencies || {});
207
- options.devDependencies = Object.keys(pkg.devDependencies || {});
208
- options.externals.push(...inferPkgExternals(pkg));
209
- options.externals = [...new Set(options.externals)];
210
- await ctx.hooks.callHook("build:before", ctx);
211
- relinka(
212
- "verbose",
213
- `${options.transpileStub ? "Stubbing" : "[unified] Building"} ${options.name}`
214
- );
215
- if (process.env.DEBUG) {
216
- relinka(
217
- "log",
218
- `Root dir: ${options.rootDir}
182
+ if (buildConfig.hooks) {
183
+ ctx.hooks.addHooks(buildConfig.hooks);
184
+ }
185
+ await ctx.hooks.callHook("build:prepare", ctx);
186
+ buildSpinner.setText("Processing build entries...");
187
+ options.entries = options.entries.map(
188
+ (entry) => typeof entry === "string" ? { input: entry, isLib } : entry
189
+ );
190
+ for (const entry of options.entries) {
191
+ if (typeof entry.name !== "string") {
192
+ let relativeInput = isAbsolute(entry.input) ? relative(rootDir, entry.input) : normalize(entry.input);
193
+ if (relativeInput.startsWith("./")) {
194
+ relativeInput = relativeInput.slice(2);
195
+ }
196
+ entry.name = removeExtension(relativeInput.replace(/^src\//, ""));
197
+ }
198
+ if (!entry.input) {
199
+ throw new Error(`Missing entry input: ${dumpObject(entry)}`);
200
+ }
201
+ if (!entry.builder) {
202
+ entry.builder = entry.input.endsWith("/") ? "mkdist" : "rollup";
203
+ }
204
+ if (options.declaration !== void 0 && entry.declaration === void 0) {
205
+ entry.declaration = options.declaration;
206
+ }
207
+ entry.input = resolve(options.rootDir, entry.input);
208
+ entry.outDir = resolve(options.rootDir, entry.outDir || options.outDir);
209
+ entry.isLib = isLib;
210
+ }
211
+ options.dependencies = Object.keys(pkg.dependencies || {});
212
+ options.peerDependencies = Object.keys(pkg.peerDependencies || {});
213
+ options.devDependencies = Object.keys(pkg.devDependencies || {});
214
+ options.externals.push(...inferPkgExternals(pkg));
215
+ options.externals = [...new Set(options.externals)];
216
+ await ctx.hooks.callHook("build:before", ctx);
217
+ relinka(
218
+ "verbose",
219
+ `${options.transpileStub ? "Stubbing" : "[unified] Building"} ${options.name}`
220
+ );
221
+ if (process.env.DEBUG) {
222
+ relinka(
223
+ "log",
224
+ `Root dir: ${options.rootDir}
219
225
  Entries:
220
226
  ${options.entries.map((entry) => ` ${dumpObject(entry)}`).join("\n ")}
221
227
  `
222
- );
223
- }
224
- if (options.clean) {
225
- for (const dir of new Set(
226
- options.entries.map((e) => e.outDir).filter((p) => !!p).sort()
227
- )) {
228
- if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
229
- continue;
228
+ );
230
229
  }
231
- cleanedDirs.push(dir);
232
- relinka("log", `Cleaning dist directory: \`./${relative(process.cwd(), dir)}\``);
233
- await rmdir(dir);
234
- await fsp.mkdir(dir, { recursive: true });
235
- }
236
- }
237
- const buildTasks = [
238
- typesBuild,
239
- // untyped
240
- mkdistBuild,
241
- // mkdist
242
- rollupBuild,
243
- // rollup
244
- copyBuild
245
- // copy
246
- ];
247
- if (options.parallel) {
248
- await Promise.all(buildTasks.map((task) => task(ctx)));
249
- } else {
250
- for (const task of buildTasks) {
251
- await task(ctx);
252
- }
253
- }
254
- if (options.transpileStub || options.transpileWatch) {
255
- await ctx.hooks.callHook("build:done", ctx);
256
- return;
257
- }
258
- relinka("success", `Build succeeded for ${options.name}`);
259
- const outFiles = await glob(["**"], { cwd: options.outDir });
260
- for (const file of outFiles) {
261
- let entry = ctx.buildEntries.find((e) => e.path === file);
262
- if (!entry) {
263
- entry = {
264
- chunk: true,
265
- path: file,
266
- isLib: ctx.options.isLib
267
- };
268
- ctx.buildEntries.push(entry);
269
- }
270
- if (!entry.bytes) {
271
- const stat = await fsp.stat(resolve(options.outDir, file));
272
- entry.bytes = stat.size;
273
- }
274
- }
275
- const rPath = (p) => relative(process.cwd(), resolve(options.outDir, p));
276
- if (showOutLog) {
277
- for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
278
- let totalBytes = entry.bytes || 0;
279
- for (const chunk of entry.chunks || []) {
280
- totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
230
+ if (options.clean) {
231
+ buildSpinner.setText("Cleaning output directories...");
232
+ for (const dir of new Set(
233
+ options.entries.map((e) => e.outDir).filter((p) => !!p).sort()
234
+ )) {
235
+ if (dir === options.rootDir || options.rootDir.startsWith(withTrailingSlash(dir)) || cleanedDirs.some((c) => dir.startsWith(c))) {
236
+ continue;
237
+ }
238
+ cleanedDirs.push(dir);
239
+ relinka("log", `Cleaning dist directory: \`./${relative(process.cwd(), dir)}\``);
240
+ await rmdir(dir);
241
+ await fsp.mkdir(dir, { recursive: true });
242
+ }
281
243
  }
282
- let line = ` ${rPath(entry.path)} (${[
283
- totalBytes && `total size: ${prettyBytes(totalBytes)}`,
284
- entry.bytes && `chunk size: ${prettyBytes(entry.bytes)}`,
285
- entry.exports?.length && `exports: ${entry.exports.join(", ")}`
286
- ].filter(Boolean).join(", ")})`;
287
- if (entry.chunks?.length) {
288
- line += `
289
- ${entry.chunks.map((p) => {
290
- const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
291
- return ` \u2514\u2500 ${rPath(p)}${chunk.bytes ? ` (${prettyBytes(chunk.bytes)})` : ""}`;
292
- }).join("\n")}`;
244
+ const buildTasks = [
245
+ { name: "Type generation", task: typesBuild },
246
+ { name: "mkdist build", task: mkdistBuild },
247
+ { name: "Rollup build", task: rollupBuild },
248
+ { name: "Copy files", task: copyBuild }
249
+ ];
250
+ const activeTasks = buildTasks.filter(({ task }) => {
251
+ if (task === typesBuild) return options.entries.some((e) => e.builder === "untyped");
252
+ if (task === mkdistBuild) return options.entries.some((e) => e.builder === "mkdist");
253
+ if (task === rollupBuild) return options.entries.some((e) => e.builder === "rollup");
254
+ if (task === copyBuild) return options.entries.some((e) => e.builder === "copy");
255
+ return false;
256
+ });
257
+ if (activeTasks.length === 0) {
258
+ buildSpinner.setText("No build tasks to execute");
259
+ } else {
260
+ let completedTasks = 0;
261
+ if (options.parallel) {
262
+ buildSpinner.setText(`Running ${activeTasks.length} build tasks in parallel...`);
263
+ await Promise.all(
264
+ activeTasks.map(async ({ task }) => {
265
+ await task(ctx);
266
+ completedTasks++;
267
+ buildSpinner.setProgress({
268
+ current: completedTasks,
269
+ total: activeTasks.length
270
+ });
271
+ })
272
+ );
273
+ } else {
274
+ for (const { task, name } of activeTasks) {
275
+ completedTasks++;
276
+ buildSpinner.setProgress({
277
+ current: completedTasks,
278
+ total: activeTasks.length
279
+ });
280
+ buildSpinner.setText(`Running ${name}...`);
281
+ await task(ctx);
282
+ }
283
+ }
293
284
  }
294
- if (entry.modules?.length) {
295
- line += `
285
+ if (options.transpileStub || options.transpileWatch) {
286
+ await ctx.hooks.callHook("build:done", ctx);
287
+ return;
288
+ }
289
+ buildSpinner.setText("Finalizing build output...");
290
+ relinka("success", `Build succeeded for ${options.name}`);
291
+ const outFiles = await glob(["**"], { cwd: options.outDir });
292
+ for (const file of outFiles) {
293
+ let entry = ctx.buildEntries.find((e) => e.path === file);
294
+ if (!entry) {
295
+ entry = {
296
+ chunk: true,
297
+ path: file,
298
+ isLib: ctx.options.isLib
299
+ };
300
+ ctx.buildEntries.push(entry);
301
+ }
302
+ if (!entry.bytes) {
303
+ const stat = await fsp.stat(resolve(options.outDir, file));
304
+ entry.bytes = stat.size;
305
+ }
306
+ }
307
+ const rPath = (p) => relative(process.cwd(), resolve(options.outDir, p));
308
+ if (showOutLog) {
309
+ for (const entry of ctx.buildEntries.filter((e) => !e.chunk)) {
310
+ let totalBytes = entry.bytes || 0;
311
+ for (const chunk of entry.chunks || []) {
312
+ totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0;
313
+ }
314
+ let line = ` ${rPath(entry.path)} (${[
315
+ totalBytes && `total size: ${prettyBytes(totalBytes)}`,
316
+ entry.bytes && `chunk size: ${prettyBytes(entry.bytes)}`,
317
+ entry.exports?.length && `exports: ${entry.exports.join(", ")}`
318
+ ].filter(Boolean).join(", ")})`;
319
+ if (entry.chunks?.length) {
320
+ line += `
321
+ ${entry.chunks.map((p) => {
322
+ const chunk = ctx.buildEntries.find((e) => e.path === p) || {};
323
+ return ` \u2514\u2500 ${rPath(p)}${chunk.bytes ? ` (${prettyBytes(chunk.bytes)})` : ""}`;
324
+ }).join("\n")}`;
325
+ }
326
+ if (entry.modules?.length) {
327
+ line += `
296
328
  ${entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.bytes || 0) - (a.bytes || 0)).map((m) => {
297
- return ` \u{1F4E6} ${rPath(m.id)}${m.bytes ? ` (${prettyBytes(m.bytes)})` : ""}`;
298
- }).join("\n")}`;
329
+ return ` \u{1F4E6} ${rPath(m.id)}${m.bytes ? ` (${prettyBytes(m.bytes)})` : ""}`;
330
+ }).join("\n")}`;
331
+ }
332
+ relinka("log", entry.chunk ? line : line);
333
+ }
334
+ const elapsedTime = getElapsedPerfTime(timer);
335
+ const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
336
+ verbose: true
337
+ });
338
+ const totalSize = ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0);
339
+ buildSpinner.setText(
340
+ `Build complete! ${prettyBytes(totalSize)} in ${transpileFormattedTime}`
341
+ );
342
+ relinka(
343
+ "info",
344
+ `\u03A3 Total dist size: ${prettyBytes(totalSize)} (build time: ${transpileFormattedTime})`
345
+ );
299
346
  }
300
- relinka("log", entry.chunk ? line : line);
301
- }
302
- const elapsedTime = getElapsedPerfTime(timer);
303
- const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
304
- verbose: true
305
- });
306
- relinka(
307
- "info",
308
- `\u03A3 Total dist size: ${prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))} (build time: ${transpileFormattedTime})`
309
- );
310
- }
311
- validateDependencies(ctx);
312
- validatePackage(pkg, rootDir, ctx);
313
- await ctx.hooks.callHook("build:done", ctx);
314
- if (ctx.warnings.size > 0) {
315
- relinka(
316
- "warn",
317
- `Build is done with some warnings:
347
+ validateDependencies(ctx);
348
+ validatePackage(pkg, rootDir, ctx);
349
+ await ctx.hooks.callHook("build:done", ctx);
350
+ if (ctx.warnings.size > 0) {
351
+ const warningMessage = `Build completed with ${ctx.warnings.size} warnings`;
352
+ buildSpinner.warn(warningMessage);
353
+ relinka(
354
+ "warn",
355
+ `Build is done with some warnings:
318
356
  ${[...ctx.warnings].map((msg) => `- ${msg}`).join("\n")}`
319
- );
320
- if (ctx.options.transpileFailOnWarn) {
321
- relinka(
322
- "error",
323
- "Exiting with code (1). You can change this behavior by setting `transpileFailOnWarn: false` ."
324
- );
325
- process.exit(1);
357
+ );
358
+ if (ctx.options.transpileFailOnWarn) {
359
+ relinka(
360
+ "error",
361
+ "Exiting with code (1). You can change this behavior by setting `transpileFailOnWarn: false` ."
362
+ );
363
+ process.exit(1);
364
+ }
365
+ shouldStopAtStep(15);
366
+ relinka("info", `Build complete (with ${ctx.warnings.size} warnings)`);
367
+ }
368
+ },
369
+ {
370
+ text: _transpileStubMode ? `Stubbing ${pkg?.name || "project"}...` : `Building ${pkg?.name || "project"}...`,
371
+ color: "green",
372
+ successText: `${pkg?.name || "Project"} built successfully!`,
373
+ failText: `Build failed for ${pkg?.name || "project"}`,
374
+ prefixText: "[unified]"
326
375
  }
327
- shouldStopAtStep(15);
328
- relinka("info", `Build complete (with ${ctx.warnings.size} warnings)`);
329
- }
376
+ );
330
377
  }
@@ -1,17 +1,17 @@
1
1
  import type { SFCBlock } from "vue/compiler-sfc";
2
2
  import type { InputFile, Loader, LoaderContext, OutputFile } from "../../../../../../../sdk-types.js";
3
- export type DefineVueLoaderOptions = {
3
+ export interface DefineVueLoaderOptions {
4
4
  blockLoaders?: Record<string, VueBlockLoader | undefined>;
5
- };
5
+ }
6
6
  export type VueBlock = Pick<SFCBlock, "type" | "content" | "attrs">;
7
7
  export type VueBlockLoader = (block: VueBlock, context: LoaderContext & {
8
8
  rawInput: InputFile;
9
9
  addOutput: (...files: OutputFile[]) => void;
10
10
  }) => Promise<VueBlock | undefined>;
11
- export type DefaultBlockLoaderOptions = {
11
+ export interface DefaultBlockLoaderOptions {
12
12
  type: "script" | "style" | "template";
13
13
  outputLang: string;
14
14
  validExtensions?: string[];
15
- };
15
+ }
16
16
  export declare const fallbackVueLoader: Loader;
17
17
  export declare const vueLoader: Loader;
@@ -1,8 +1,11 @@
1
1
  import type { MkdistOptions } from "../../../../../../sdk-types.js";
2
2
  export declare function mkdist(options?: MkdistOptions): Promise<{
3
- errors: {
4
- filename: string;
5
- errors: TypeError[];
6
- }[];
7
- writtenFiles: string[];
3
+ result: {
4
+ errors: {
5
+ filename: string;
6
+ errors: TypeError[];
7
+ }[];
8
+ writtenFiles: string[];
9
+ };
10
+ duration: number;
8
11
  }>;