@sse-ui/builder 1.2.0 → 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.
@@ -2,8 +2,8 @@ import {
2
2
  build,
3
3
  cjsCopy,
4
4
  getVersionEnvVariables
5
- } from "./chunk-MBPIJFGX.js";
6
- import "./chunk-B6FMAT44.js";
5
+ } from "./chunk-6NNEV5YX.js";
6
+ import "./chunk-N46AJ2OI.js";
7
7
  import "./chunk-MLKGABMK.js";
8
8
  export {
9
9
  build,
@@ -127,7 +127,9 @@ function getBaseConfig({
127
127
  ],
128
128
  [presetTypescript]
129
129
  ],
130
- plugins
130
+ plugins,
131
+ minified: process.env.SSE_MINIFY === "true",
132
+ shouldPrintComment: (val) => process.env.SSE_MINIFY !== "true" || /[@#]__PURE__|license|copyright/i.test(val)
131
133
  };
132
134
  }
133
135
  function getBabelConfig(api) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BASE_IGNORES
3
- } from "./chunk-B6FMAT44.js";
3
+ } from "./chunk-N46AJ2OI.js";
4
4
 
5
5
  // src/utils/babel.ts
6
6
  import { findWorkspacesRoot } from "find-workspaces";
@@ -8,6 +8,7 @@ import { $ } from "execa";
8
8
  import { globby } from "globby";
9
9
  import * as fs from "fs/promises";
10
10
  import * as path from "path";
11
+ import chalk from "chalk";
11
12
  var TO_TRANSFORM_EXTENSIONS = [".js", ".ts", ".tsx"];
12
13
  function getVersionEnvVariables(pkgVersion) {
13
14
  if (!pkgVersion) {
@@ -29,7 +30,7 @@ function getVersionEnvVariables(pkgVersion) {
29
30
  async function cjsCopy({ from, to }) {
30
31
  const exists = await fs.stat(to).then(() => true).catch(() => false);
31
32
  if (!exists) {
32
- console.warn(`path ${to} does not exists`);
33
+ console.warn(chalk.yellow(`\u26A0\uFE0F path ${to} does not exist`));
33
34
  return;
34
35
  }
35
36
  const files = await globby("**/*.cjs", { cwd: from });
@@ -51,11 +52,14 @@ async function build({
51
52
  removePropTypes = false,
52
53
  verbose = false,
53
54
  ignores = [],
54
- reactCompiler
55
+ reactCompiler,
56
+ minify = false
55
57
  }) {
56
58
  if (verbose) {
57
59
  console.log(
58
- `Transpiling files to "${path.relative(path.dirname(sourceDir), outDir)}" for "${bundle}" bundle.`
60
+ chalk.blue(
61
+ `Transpiling files to "${path.relative(path.dirname(sourceDir), outDir)}" for "${bundle}" bundle.`
62
+ )
59
63
  );
60
64
  }
61
65
  const workspaceDir = await findWorkspacesRoot(cwd);
@@ -76,9 +80,11 @@ async function build({
76
80
  SSE_OUT_FILE_EXTENSION: outExtension ?? ".js",
77
81
  ...getVersionEnvVariables(pkgVersion),
78
82
  SSE_REACT_COMPILER: reactVersion ? "1" : "0",
79
- SSE_REACT_COMPILER_REACT_VERSION: reactVersion
83
+ SSE_REACT_COMPILER_REACT_VERSION: reactVersion,
84
+ SSE_MINIFY: minify ? "true" : void 0
80
85
  };
81
86
  const resolvedOutExtension = outExtension ?? ".js";
87
+ const minifiedArgs = minify ? ["--minified"] : [];
82
88
  const res = await $({
83
89
  stdio: "inherit",
84
90
  preferLocal: true,
@@ -87,7 +93,7 @@ async function build({
87
93
  ...process.env,
88
94
  ...env
89
95
  }
90
- })`babel --config-file ${configFile} --extensions ${TO_TRANSFORM_EXTENSIONS.join(
96
+ })`babel --config-file ${configFile} ${minifiedArgs} --extensions ${TO_TRANSFORM_EXTENSIONS.join(
91
97
  ","
92
98
  )} ${sourceDir} --out-dir ${outDir} --ignore ${BASE_IGNORES.concat(
93
99
  ignores
@@ -99,10 +105,9 @@ ${res.stderr}`
99
105
  );
100
106
  }
101
107
  if (verbose) {
102
- console.log(
103
- `Command: '${res.escapedCommand}' succeeded with
104
- ${res.stdout}`
105
- );
108
+ const output = res.stdout ? `
109
+ ${res.stdout}` : "";
110
+ console.log(chalk.green(`\u2705 Babel compilation succeeded!${output}`));
106
111
  }
107
112
  }
108
113
 
@@ -4,6 +4,7 @@ import * as path from "path";
4
4
  import { globby } from "globby";
5
5
  import { minimatch } from "minimatch";
6
6
  import * as semver from "semver";
7
+ import chalk from "chalk";
7
8
  function getOutExtension(bundle, options = {}) {
8
9
  const { isType = false, isFlat = false, packageType = "commonjs" } = options;
9
10
  const normalizedPackageType = packageType === "module" ? "module" : "commonjs";
@@ -548,7 +549,8 @@ async function addLicense({
548
549
  ${content}`,
549
550
  { encoding: "utf8" }
550
551
  );
551
- if (process.env.SSE_BUILD_VERBOSE) console.log(`License added to ${file}`);
552
+ if (process.env.SSE_BUILD_VERBOSE)
553
+ console.log(chalk.gray(`License added to ${file}`));
552
554
  }
553
555
  async function writePackageJson({
554
556
  packageJson,
package/dist/cli.js CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  getVersionEnvVariables
4
- } from "./chunk-MBPIJFGX.js";
4
+ } from "./chunk-6NNEV5YX.js";
5
5
  import {
6
6
  addLicense,
7
7
  getOutExtension,
8
8
  mapConcurrently,
9
9
  validatePkgJson,
10
10
  writePackageJson
11
- } from "./chunk-B6FMAT44.js";
11
+ } from "./chunk-N46AJ2OI.js";
12
12
  import "./chunk-MLKGABMK.js";
13
13
 
14
14
  // src/cli.ts
15
- import chalk2 from "chalk";
15
+ import chalk11 from "chalk";
16
16
  import { Command as Command11 } from "commander";
17
17
 
18
18
  // src/core/build.ts
@@ -102,7 +102,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
102
102
  "--exportExtensions <exts...>",
103
103
  "Available extensions for generating exports wildcards.",
104
104
  [".js", ".mjs", ".cjs"]
105
- ).action(async (cliOptions) => {
105
+ ).option("--minify", "Minify the generated output.").action(async (cliOptions) => {
106
106
  const fileConfig = await loadConfig();
107
107
  const isVerbose = cliOptions.verbose || fileConfig.verbose || process.env.SSE_BUILD_VERBOSE === "true";
108
108
  if (isVerbose) process.env.SSE_BUILD_VERBOSE = "true";
@@ -110,6 +110,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
110
110
  const builder = isEsbuild ? "esbuild" : "babel";
111
111
  const bundles = cliOptions.bundle || fileConfig.bundle || ["esm", "cjs"];
112
112
  const isFlat = cliOptions.flat ?? fileConfig.flat ?? false;
113
+ const minify = cliOptions.minify ?? fileConfig.minify ?? false;
113
114
  const buildTypes = cliOptions.buildTypes ?? fileConfig.buildTypes ?? true;
114
115
  const skipTsc = cliOptions.skipTsc ?? fileConfig.skipTsc ?? false;
115
116
  const skipBundlePackageJson = cliOptions.skipBundlePackageJson ?? fileConfig.skipBundlePackageJson ?? false;
@@ -132,8 +133,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
132
133
  const buildDir = path.join(cwd, buildDirBase);
133
134
  const packageType = packageJson.type === "module" ? "module" : "commonjs";
134
135
  if (isVerbose) {
135
- console.log(`Selected output directory: "${buildDirBase}"`);
136
- if (isFlat) console.log("Building package in flat structure.");
136
+ console.log(chalk.blue(`Selected output directory: "${buildDirBase}"`));
137
+ if (isFlat)
138
+ console.log(chalk.blue("Building package in flat structure."));
137
139
  }
138
140
  await fs.rm(buildDir, { recursive: true, force: true });
139
141
  const pm = getPackageManager();
@@ -168,7 +170,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
168
170
  }
169
171
  if (!bundles || bundles.length === 0) {
170
172
  console.error(
171
- "No bundles specified. Use --bundle to specify which bundles to build."
173
+ chalk.red(
174
+ "No bundles specified. Use --bundle to specify which bundles to build."
175
+ )
172
176
  );
173
177
  return;
174
178
  }
@@ -183,12 +187,16 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
183
187
  }
184
188
  if (builder === "esbuild") {
185
189
  if (isVerbose)
186
- console.log("\u{1F4E6} Bundling package into single files via esbuild...");
190
+ console.log(
191
+ chalk.green("\u{1F4E6} Bundling package into single files via esbuild...")
192
+ );
187
193
  const esbuildConfig = fileConfig.esbuild || { entry: "src/index.ts" };
188
194
  let rawEntryPoints = cliOptions.entry || esbuildConfig.entry;
189
195
  if (!rawEntryPoints) {
190
196
  throw new Error(
191
- "Esbuild requires an 'entry' point. Please define it in your config (esbuild.entry) or via --entry."
197
+ chalk.red(
198
+ "Esbuild requires an 'entry' point. Please define it in your config (esbuild.entry) or via --entry."
199
+ )
192
200
  );
193
201
  }
194
202
  const entryPoints = typeof rawEntryPoints === "string" ? [rawEntryPoints] : rawEntryPoints;
@@ -208,7 +216,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
208
216
  outdir: outputDir,
209
217
  format: bundle === "esm" ? "esm" : "cjs",
210
218
  target: esbuildConfig.target || ["es2020", "node14"],
211
- minify: esbuildConfig.minify ?? false,
219
+ minify,
212
220
  outExtension: { ".js": outExtension },
213
221
  // Forces the correct extension output
214
222
  external: [
@@ -238,8 +246,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
238
246
  })
239
247
  );
240
248
  } else {
241
- if (isVerbose) console.log("\u{1F4E6} Transpiling package via Babel...");
242
- const { build: babelBuild, cjsCopy } = await import("./babel-RJOLF3H5.js");
249
+ if (isVerbose)
250
+ console.log(chalk.green("\u{1F4E6} Transpiling package via Babel..."));
251
+ const { build: babelBuild, cjsCopy } = await import("./babel-6NHCDM3A.js");
243
252
  const hasLargeFiles = cliOptions.hasLargeFiles ?? fileConfig.babel?.hasLargeFiles ?? false;
244
253
  const extraIgnores = [
245
254
  ...fileConfig.babel?.ignore || [],
@@ -265,6 +274,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
265
274
  hasLargeFiles,
266
275
  bundle,
267
276
  verbose: isVerbose,
277
+ minify,
268
278
  optimizeClsx: packageJson.dependencies?.clsx !== void 0 || packageJson.dependencies?.classnames !== void 0,
269
279
  removePropTypes: packageJson.dependencies?.["prop-types"] !== void 0,
270
280
  pkgVersion: packageJson.version,
@@ -304,8 +314,9 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
304
314
  }
305
315
  }
306
316
  if (buildTypes === true) {
307
- if (isVerbose) console.log("\u{1F4DD} Generating TypeScript declarations...");
308
- const tsMod = await import("./typescript-6QWCIZ3Q.js");
317
+ if (isVerbose)
318
+ console.log(chalk.cyan("\u{1F4DD} Generating TypeScript declarations..."));
319
+ const tsMod = await import("./typescript-42L4XZEH.js");
309
320
  const bundleMap = bundles.map((type) => ({
310
321
  type,
311
322
  dir: relativeOutDirs[type]
@@ -356,6 +367,7 @@ var buildCommand = new Command("build").description(chalk.cyan("Builds the packa
356
367
  buildDir,
357
368
  verbose: isVerbose
358
369
  });
370
+ console.log(chalk.green.bold("\u2714 Build completed successfully"));
359
371
  });
360
372
  async function copyHandler({
361
373
  cwd,
@@ -456,7 +468,7 @@ async function recursiveCopy({
456
468
  try {
457
469
  await fs.cp(source, target, { recursive: true });
458
470
  if (verbose) {
459
- console.log(`Copied ${source} to ${target}`);
471
+ console.log(chalk.gray(`\u{1F4C4} Copied ${source} \u2192 ${target}`));
460
472
  }
461
473
  return true;
462
474
  } catch (err) {
@@ -464,7 +476,7 @@ async function recursiveCopy({
464
476
  throw err;
465
477
  }
466
478
  if (verbose) {
467
- console.warn(`Source does not exist: ${source}`);
479
+ console.warn(chalk.yellow(`\u26A0 Source does not exist: ${source}`));
468
480
  }
469
481
  throw err;
470
482
  }
@@ -475,6 +487,7 @@ import * as fs2 from "fs/promises";
475
487
  import * as path2 from "path";
476
488
  import { Command as Command2 } from "commander";
477
489
  import { $ as $2 } from "execa";
490
+ import chalk2 from "chalk";
478
491
  var publishCommand = new Command2("publish").description(
479
492
  "Automatically publishes the built package from the publishConfig.directory"
480
493
  ).option("--tag <tag>", "Registers the published package with the given tag").option(
@@ -514,7 +527,9 @@ var publishCommand = new Command2("publish").description(
514
527
  const pm = options.pm || getPackageManager();
515
528
  if (isVerbose) {
516
529
  console.log(
517
- `\u{1F680} Publishing via ${pm.toUpperCase()} from directory: ${publishDirBase}`
530
+ chalk2.blue(
531
+ `\u{1F680} Publishing via ${pm.toUpperCase()} from directory: ${publishDirBase}`
532
+ )
518
533
  );
519
534
  }
520
535
  const args = ["publish"];
@@ -528,11 +543,11 @@ var publishCommand = new Command2("publish").description(
528
543
  stdio: "inherit",
529
544
  cwd: publishDir
530
545
  })`${pm} ${args}`;
531
- console.log("\u2705 Successfully published!");
546
+ console.log(chalk2.green("\u2705 Successfully published!"));
532
547
  } catch (error) {
533
- console.error("\u274C Error executing publish command:");
548
+ console.error(chalk2.red("\u274C Error executing publish command:"));
534
549
  if (error instanceof Error) {
535
- console.error(error.message);
550
+ console.error(chalk2.red(error.message));
536
551
  }
537
552
  process.exit(1);
538
553
  }
@@ -542,6 +557,7 @@ var publishCommand = new Command2("publish").description(
542
557
  import * as fs3 from "fs/promises";
543
558
  import * as path3 from "path";
544
559
  import { Command as Command3 } from "commander";
560
+ import chalk3 from "chalk";
545
561
  var cleanCommand = new Command3("clean").description(
546
562
  "Removes the build directory specified in package.json to start fresh"
547
563
  ).action(async () => {
@@ -556,13 +572,15 @@ var cleanCommand = new Command3("clean").description(
556
572
  const buildDirBase = packageJson.publishConfig?.directory || "build";
557
573
  const buildDir = path3.join(cwd, buildDirBase);
558
574
  if (isVerbose)
559
- console.log(`\u{1F9F9} Cleaning build directory: ${buildDirBase}...`);
575
+ console.log(
576
+ chalk3.blue(`\u{1F9F9} Cleaning build directory: ${buildDirBase}...`)
577
+ );
560
578
  await fs3.rm(buildDir, { recursive: true, force: true });
561
- console.log("\u2728 Cleaned successfully!");
579
+ console.log(chalk3.green("\u2728 Cleaned successfully!"));
562
580
  } catch (error) {
563
- console.error("\u274C Error executing clean command:");
581
+ console.error(chalk3.red("\u274C Error executing clean command:"));
564
582
  if (error instanceof Error) {
565
- console.error(error.message);
583
+ console.error(chalk3.red(error.message));
566
584
  }
567
585
  process.exit(1);
568
586
  }
@@ -571,11 +589,12 @@ var cleanCommand = new Command3("clean").description(
571
589
  // src/core/typecheck.ts
572
590
  import { Command as Command4 } from "commander";
573
591
  import { $ as $3 } from "execa";
592
+ import chalk4 from "chalk";
574
593
  var typecheckCommand = new Command4("typecheck").description(
575
594
  "Runs TypeScript validation across the project without emitting files"
576
595
  ).option("--watch", "Run typechecking in watch mode").action(async (options) => {
577
596
  const isVerbose = process.env.SSE_BUILD_VERBOSE === "true";
578
- if (isVerbose) console.log("\u{1F50D} Running typecheck...");
597
+ if (isVerbose) console.log(chalk4.blue("\u{1F50D} Running typecheck..."));
579
598
  try {
580
599
  const args = ["tsc", "--noEmit"];
581
600
  if (options.watch) {
@@ -583,11 +602,13 @@ var typecheckCommand = new Command4("typecheck").description(
583
602
  }
584
603
  await $3({ stdio: "inherit" })`${args.join(" ")}`;
585
604
  if (!options.watch) {
586
- console.log("\u2705 Typecheck passed! No errors found.");
605
+ console.log(chalk4.green("\u2705 Typecheck passed! No errors found."));
587
606
  }
588
607
  } catch (error) {
589
608
  console.error(
590
- "\u274C Typecheck failed. Please fix the TypeScript errors above."
609
+ chalk4.red(
610
+ "\u274C Typecheck failed. Please fix the TypeScript errors above."
611
+ )
591
612
  );
592
613
  process.exit(1);
593
614
  }
@@ -598,6 +619,7 @@ import * as fs4 from "fs/promises";
598
619
  import * as path4 from "path";
599
620
  import { Command as Command5 } from "commander";
600
621
  import { $ as $4 } from "execa";
622
+ import chalk5 from "chalk";
601
623
  var packCommand = new Command5("pack").description(
602
624
  "Creates a tarball (.tgz) of the built package to inspect before publishing"
603
625
  ).action(async () => {
@@ -616,17 +638,21 @@ var packCommand = new Command5("pack").description(
616
638
  }
617
639
  const publishDir = path4.join(cwd, publishDirBase);
618
640
  if (isVerbose)
619
- console.log(`\u{1F4E6} Packing package from directory: ${publishDirBase}...`);
641
+ console.log(
642
+ chalk5.blue(`\u{1F4E6} Packing package from directory: ${publishDirBase}...`)
643
+ );
620
644
  await $4({
621
645
  stdio: "inherit",
622
646
  cwd: publishDir
623
647
  })`${pm} pack`;
624
648
  console.log(
625
- "\u2705 Pack successful! You can inspect the generated .tgz file."
649
+ chalk5.green(
650
+ "\u2705 Pack successful! You can inspect the generated .tgz file."
651
+ )
626
652
  );
627
653
  } catch (error) {
628
- console.error("\u274C Error executing pack command:");
629
- if (error instanceof Error) console.error(error.message);
654
+ console.error(chalk5.red("\u274C Error executing pack command:"));
655
+ if (error instanceof Error) console.error(chalk5.red(error.message));
630
656
  process.exit(1);
631
657
  }
632
658
  });
@@ -638,6 +664,7 @@ import { Command as Command6 } from "commander";
638
664
  import { $ as $5 } from "execa";
639
665
  import enquirer from "enquirer";
640
666
  import * as semver2 from "semver";
667
+ import chalk6 from "chalk";
641
668
  var versionCommand = new Command6("version").description("Bumps the package version interactively or manually").argument(
642
669
  "[type]",
643
670
  "Version update type (patch, minor, major, or specific version like 1.2.3). If omitted, an interactive prompt will appear."
@@ -664,7 +691,9 @@ var versionCommand = new Command6("version").description("Bumps the package vers
664
691
  } catch (err) {
665
692
  if (isVerbose)
666
693
  console.warn(
667
- "\u26A0\uFE0F Could not read current version from package.json. Defaulting to 0.0.0"
694
+ chalk6.yellow(
695
+ "\u26A0\uFE0F Could not read current version from package.json. Defaulting to 0.0.0"
696
+ )
668
697
  );
669
698
  }
670
699
  const choices = validTypes.map((bump) => {
@@ -699,22 +728,26 @@ var versionCommand = new Command6("version").description("Bumps the package vers
699
728
  } else {
700
729
  if (!validTypes.includes(selectedType) && !semver2.valid(selectedType)) {
701
730
  console.error(
702
- `\u274C Invalid version type: ${selectedType}. Use patch, minor, major, or a valid semver.`
731
+ chalk6.red(
732
+ `\u274C Invalid version type: ${selectedType}. Use patch, minor, major, or a valid semver.`
733
+ )
703
734
  );
704
735
  process.exit(1);
705
736
  }
706
737
  }
707
738
  if (isVerbose)
708
- console.log(`\u{1F4C8} Bumping version (${selectedType}) via ${pm}...`);
739
+ console.log(
740
+ chalk6.cyan(`\u{1F4C8} Bumping version (${selectedType}) via ${pm}...`)
741
+ );
709
742
  try {
710
743
  const args = ["version", selectedType];
711
744
  if (!options.gitTagVersion) {
712
745
  args.push("--no-git-tag-version");
713
746
  }
714
747
  await $5({ stdio: isVerbose ? "inherit" : "pipe" })`${pm} ${args}`;
715
- console.log("\u2705 Version bumped successfully!");
748
+ console.log(chalk6.green("\u2705 Version bumped successfully!"));
716
749
  } catch (error) {
717
- console.error("\u274C Failed to bump version.");
750
+ console.error(chalk6.red("\u274C Failed to bump version."));
718
751
  process.exit(1);
719
752
  }
720
753
  });
@@ -723,6 +756,7 @@ var versionCommand = new Command6("version").description("Bumps the package vers
723
756
  import * as fs6 from "fs/promises";
724
757
  import * as path6 from "path";
725
758
  import { Command as Command7 } from "commander";
759
+ import chalk7 from "chalk";
726
760
  async function getDirSize(dirPath) {
727
761
  let size = 0;
728
762
  const files = await fs6.readdir(dirPath, { withFileTypes: true });
@@ -754,24 +788,29 @@ var infoCommand = new Command7("info").description("Displays size and file stati
754
788
  const sizeBytes = await getDirSize(publishDir);
755
789
  const sizeKB = (sizeBytes / 1024).toFixed(2);
756
790
  const sizeMB = (sizeBytes / (1024 * 1024)).toFixed(2);
757
- if (isVerbose) console.log(`Gathering info from ${publishDir}...`);
758
- console.log(`
759
- \u{1F4CA} Package Info: ${packageJson.name}`);
760
- console.log(`================================`);
761
- console.log(`Version: ${packageJson.version}`);
762
- console.log(`Build Folder: ./${publishDirBase}`);
791
+ if (isVerbose)
792
+ console.log(chalk7.gray(`Gathering info from ${publishDir}...`));
793
+ console.log(
794
+ chalk7.cyan(`
795
+ \u{1F4CA} Package Info: `) + chalk7.bold(packageJson.name)
796
+ );
797
+ console.log(chalk7.gray(`================================`));
798
+ console.log(`Version: ${chalk7.white(packageJson.version)}`);
799
+ console.log(`Build Folder: ${chalk7.white(`./${publishDirBase}`)}`);
763
800
  if (sizeBytes > 1024 * 1024) {
764
801
  console.log(
765
- `Total Size: ${sizeMB} MB \u26A0\uFE0F (Consider keeping packages under 1MB)`
802
+ `Total Size: ${chalk7.yellow(`${sizeMB} MB`)} ${chalk7.red("\u26A0\uFE0F (Consider keeping packages under 1MB)")}`
766
803
  );
767
804
  } else {
768
- console.log(`Total Size: ${sizeKB} KB \u2705`);
805
+ console.log(`Total Size: ${chalk7.green(`${sizeKB} KB \u2705`)}`);
769
806
  }
770
- console.log(`================================
771
- `);
807
+ console.log(chalk7.gray(`================================
808
+ `));
772
809
  } catch (error) {
773
810
  console.error(
774
- "\u274C Error fetching package info. Did you build the project first?"
811
+ chalk7.red(
812
+ "\u274C Error fetching package info. Did you build the project first?"
813
+ )
775
814
  );
776
815
  process.exit(1);
777
816
  }
@@ -782,6 +821,7 @@ import * as fs7 from "fs/promises";
782
821
  import * as path7 from "path";
783
822
  import { Command as Command8 } from "commander";
784
823
  import { $ as $6 } from "execa";
824
+ import chalk8 from "chalk";
785
825
  var linkCommand = new Command8("link").description(
786
826
  "Symlinks the built package directory so it can be tested in other local projects"
787
827
  ).action(async () => {
@@ -800,20 +840,22 @@ var linkCommand = new Command8("link").description(
800
840
  }
801
841
  const publishDir = path7.join(cwd, publishDirBase);
802
842
  if (isVerbose)
803
- console.log(`\u{1F517} Linking package from: ./${publishDirBase}...`);
843
+ console.log(
844
+ chalk8.blue(`\u{1F517} Linking package from: ./${publishDirBase}...`)
845
+ );
804
846
  await $6({
805
847
  stdio: isVerbose ? "inherit" : "pipe",
806
848
  cwd: publishDir
807
849
  })`${pm} link`;
808
- console.log(`
809
- \u2705 Successfully linked!`);
850
+ console.log(chalk8.green(`
851
+ \u2705 Successfully linked!`));
810
852
  console.log(
811
853
  `To use this in another project, go to that project and run:`
812
854
  );
813
- console.log(`\u{1F449} ${pm} link ${packageJson.name}`);
855
+ console.log(chalk8.cyan(`\u{1F449} ${pm} link ${packageJson.name}`));
814
856
  } catch (error) {
815
- console.error("\u274C Error executing link command:");
816
- if (error instanceof Error) console.error(error.message);
857
+ console.error(chalk8.red("\u274C Error executing link command:"));
858
+ if (error instanceof Error) console.error(chalk8.red(error.message));
817
859
  process.exit(1);
818
860
  }
819
861
  });
@@ -822,6 +864,8 @@ var linkCommand = new Command8("link").description(
822
864
  import * as fs8 from "fs/promises";
823
865
  import * as path8 from "path";
824
866
  import { Command as Command9 } from "commander";
867
+ import chalk9 from "chalk";
868
+ import { globby as globby2 } from "globby";
825
869
  async function fileExists(filePath) {
826
870
  return fs8.stat(filePath).then(() => true).catch(() => false);
827
871
  }
@@ -859,32 +903,59 @@ var checkExportsCommand = new Command9("check-exports").description(
859
903
  });
860
904
  const buildPkg = JSON.parse(buildPkgContent);
861
905
  if (!buildPkg.exports) {
862
- if (isVerbose) console.log("\u26A0\uFE0F No 'exports' field found to check.");
906
+ if (isVerbose)
907
+ console.log(chalk9.yellow("\u26A0\uFE0F No 'exports' field found to check."));
863
908
  return;
864
909
  }
865
- console.log(`\u{1F575}\uFE0F Checking exports mapping in ./${publishDirBase}...`);
910
+ console.log(
911
+ chalk9.blue(`\u{1F575}\uFE0F Checking exports mapping in ./${publishDirBase}...`)
912
+ );
866
913
  const allPaths = extractPaths(buildPkg.exports);
914
+ const uniquePaths = Array.from(new Set(allPaths));
867
915
  let hasErrors = false;
868
- for (const relativePath of allPaths) {
869
- const absolutePath = path8.join(cwd, publishDirBase, relativePath);
870
- const exists = await fileExists(absolutePath);
871
- if (exists) {
872
- if (isVerbose) console.log(` \u2705 Found: ${relativePath}`);
916
+ const publishDirFullPath = path8.join(cwd, publishDirBase);
917
+ for (const relativePath of uniquePaths) {
918
+ if (relativePath.includes("*")) {
919
+ const matchedFiles = await globby2(relativePath, {
920
+ cwd: publishDirFullPath
921
+ });
922
+ if (matchedFiles.length > 0) {
923
+ if (isVerbose)
924
+ console.log(
925
+ chalk9.green(` \u2705 Found matches for pattern: ${relativePath}`)
926
+ );
927
+ } else {
928
+ console.error(
929
+ chalk9.red(` \u274C No files match pattern: ${relativePath}`)
930
+ );
931
+ hasErrors = true;
932
+ }
873
933
  } else {
874
- console.error(` \u274C Missing: ${relativePath}`);
875
- hasErrors = true;
934
+ const absolutePath = path8.join(publishDirFullPath, relativePath);
935
+ const exists = await fileExists(absolutePath);
936
+ if (exists) {
937
+ if (isVerbose)
938
+ console.log(chalk9.green(` \u2705 Found: ${relativePath}`));
939
+ } else {
940
+ console.error(chalk9.red(` \u274C Missing: ${relativePath}`));
941
+ hasErrors = true;
942
+ }
876
943
  }
877
944
  }
878
945
  if (hasErrors) {
879
946
  console.error(
880
- "\n\u274C Export check failed! Some files declared in package.json are missing."
947
+ chalk9.red(
948
+ "\n\u274C Export check failed! Some files declared in package.json are missing."
949
+ )
881
950
  );
882
951
  process.exit(1);
883
952
  } else {
884
- console.log("\n\u2728 All exported files are present and accounted for!");
953
+ console.log(
954
+ chalk9.green("\n\u2728 All exported files are present and accounted for!")
955
+ );
885
956
  }
886
957
  } catch (error) {
887
- if (error instanceof Error) console.error(error.message);
958
+ if (error instanceof Error) console.error(chalk9.red(error.message));
888
959
  process.exit(1);
889
960
  }
890
961
  });
@@ -2630,6 +2701,7 @@ var chokidar_default = { watch, FSWatcher };
2630
2701
  import { $ as $7 } from "execa";
2631
2702
  import { build as esbuild2 } from "esbuild";
2632
2703
  import { findWorkspacesRoot as findWorkspacesRoot2 } from "find-workspaces";
2704
+ import chalk10 from "chalk";
2633
2705
  var watchCommand = new Command10("watch").description(
2634
2706
  "Watches the src directory and incrementally rebuilds files on changes (Vite-style)"
2635
2707
  ).action(async () => {
@@ -2644,8 +2716,10 @@ var watchCommand = new Command10("watch").description(
2644
2716
  }
2645
2717
  const isVerbose = process.env.SSE_BUILD_VERBOSE === "true";
2646
2718
  if (isReload) {
2647
- console.log(`
2648
- \u{1F504} Configuration change detected. Reloading...`);
2719
+ console.log(
2720
+ chalk10.cyan(`
2721
+ \u{1F504} Configuration change detected. Reloading...`)
2722
+ );
2649
2723
  }
2650
2724
  const packageJsonContent = await fs9.readFile(pkgJsonPath, "utf8");
2651
2725
  const packageJson = JSON.parse(packageJsonContent);
@@ -2663,22 +2737,29 @@ var watchCommand = new Command10("watch").description(
2663
2737
  const pmExec = getPmExec();
2664
2738
  let babelRuntimeVersion = packageJson.dependencies?.["@babel/runtime"];
2665
2739
  const reactVersion = packageJson.peerDependencies?.react || "latest";
2666
- console.log(`\u{1F440} Watching for changes (Builder: ${builder})...`);
2740
+ console.log(
2741
+ chalk10.blue(`\u{1F440} Watching for changes (Builder: ${builder})...`)
2742
+ );
2667
2743
  try {
2668
2744
  await $7({
2669
2745
  stdio: "inherit",
2670
2746
  preferLocal: true
2671
2747
  })`${pmExec} sse-tools build`;
2672
2748
  } catch (err) {
2673
- console.error(`\u274C Initial build failed. Waiting for changes...
2674
- `);
2749
+ console.error(
2750
+ chalk10.red(`\u274C Initial build failed. Waiting for changes...
2751
+ `)
2752
+ );
2675
2753
  }
2676
2754
  const buildFile = async (filePath) => {
2677
2755
  const relativePath = path9.relative(srcDir, filePath);
2756
+ const minify = fileConfig.minify ?? false;
2678
2757
  if (builder === "esbuild") {
2679
2758
  if (isVerbose)
2680
2759
  console.log(
2681
- `\u{1F680} [esbuild] Incremental rebuild triggered by ${relativePath}...`
2760
+ chalk10.gray(
2761
+ `\u{1F680} [esbuild] Incremental rebuild triggered by ${relativePath}...`
2762
+ )
2682
2763
  );
2683
2764
  const esbuildConfig = fileConfig.esbuild;
2684
2765
  const entryPoints = typeof esbuildConfig.entry === "string" ? [esbuildConfig.entry] : esbuildConfig.entry;
@@ -2697,7 +2778,7 @@ var watchCommand = new Command10("watch").description(
2697
2778
  outdir: outputDir,
2698
2779
  format: bundle === "esm" ? "esm" : "cjs",
2699
2780
  target: esbuildConfig.target || ["es2020", "node14"],
2700
- minify: esbuildConfig.minify ?? false,
2781
+ minify,
2701
2782
  outExtension: { ".js": outExtension },
2702
2783
  external: [
2703
2784
  ...Object.keys(packageJson.dependencies || {}),
@@ -2707,9 +2788,13 @@ var watchCommand = new Command10("watch").description(
2707
2788
  });
2708
2789
  })
2709
2790
  );
2710
- if (isVerbose) console.log(`\u2705 [esbuild] Rebuild complete.`);
2791
+ if (isVerbose)
2792
+ console.log(chalk10.green(`\u2705 [esbuild] Rebuild complete.`));
2711
2793
  } catch (err) {
2712
- console.error(`\u274C [esbuild] Rebuild failed:`, err.message);
2794
+ console.error(
2795
+ chalk10.red(`\u274C [esbuild] Rebuild failed:`),
2796
+ err.message
2797
+ );
2713
2798
  }
2714
2799
  } else {
2715
2800
  const ext = path9.extname(filePath);
@@ -2736,6 +2821,7 @@ var watchCommand = new Command10("watch").description(
2736
2821
  NODE_ENV: "production",
2737
2822
  BABEL_ENV: bundle === "esm" ? "stable" : "node",
2738
2823
  SSE_OUT_FILE_EXTENSION: outExtension,
2824
+ SSE_MINIFY: minify ? "true" : void 0,
2739
2825
  SSE_BABEL_RUNTIME_VERSION: babelRuntimeVersion,
2740
2826
  ...getVersionEnvVariables(packageJson.version)
2741
2827
  };
@@ -2746,7 +2832,8 @@ var watchCommand = new Command10("watch").description(
2746
2832
  })`babel --config-file ${babelConfigFile} --extensions .js,.jsx,.ts,.tsx ${filePath} --out-file ${outFilePath}`;
2747
2833
  })
2748
2834
  );
2749
- if (isVerbose) console.log(`\u2705 [babel] Updated ${relativePath}`);
2835
+ if (isVerbose)
2836
+ console.log(chalk10.green(`\u2705 [babel] Updated ${relativePath}`));
2750
2837
  }
2751
2838
  };
2752
2839
  const updateExports = async () => {
@@ -2769,7 +2856,7 @@ var watchCommand = new Command10("watch").description(
2769
2856
  exportExtensions: fileConfig.exportExtensions
2770
2857
  });
2771
2858
  } catch (e) {
2772
- console.error(`\u274C Failed to update exports: ${e.message}`);
2859
+ console.error(chalk10.red(`\u274C Failed to update exports: ${e.message}`));
2773
2860
  }
2774
2861
  };
2775
2862
  let exportTimeout;
@@ -2842,7 +2929,7 @@ var watchCommand = new Command10("watch").description(
2842
2929
  async function main() {
2843
2930
  const program = new Command11();
2844
2931
  program.name("sse-tools").description(
2845
- chalk2.cyan("CLI utilities for managing and building SSE packages")
2932
+ chalk11.cyan("CLI utilities for managing and building SSE packages")
2846
2933
  ).version("1.0.0").option("-v, --verbose", "Enable verbose logging across all commands");
2847
2934
  program.hook("preAction", (thisCommand) => {
2848
2935
  if (thisCommand.opts().verbose) {
package/dist/config.d.ts CHANGED
@@ -13,8 +13,6 @@ interface EsbuildOptions {
13
13
  * Example: "src/index.ts" or ["src/index.ts"] or { main: "src/index.ts" }
14
14
  */
15
15
  entry: string | string[] | Record<string, string>;
16
- /** Minify the generated bundle. */
17
- minify?: boolean;
18
16
  /** Target environment for the generated JavaScript. */
19
17
  target?: string | string[];
20
18
  /** External dependencies to exclude from the bundle. */
@@ -39,6 +37,8 @@ interface BaseBuildConfig {
39
37
  copy?: string[];
40
38
  /** Skip generating a package.json file in the bundle output */
41
39
  skipBundlePackageJson?: boolean;
40
+ /** Minify the generated bundle. */
41
+ minify?: boolean;
42
42
  }
43
43
  /**
44
44
  * The user can define EITHER `babel` OR `esbuild` configuration.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getOutExtension,
3
3
  mapConcurrently
4
- } from "./chunk-B6FMAT44.js";
4
+ } from "./chunk-N46AJ2OI.js";
5
5
  import {
6
6
  __export
7
7
  } from "./chunk-MLKGABMK.js";
@@ -19674,6 +19674,7 @@ var debugApis = {
19674
19674
  };
19675
19675
 
19676
19676
  // src/utils/dts-bundler.ts
19677
+ import chalk from "chalk";
19677
19678
  var dtsExp = /\.d\.ts$/;
19678
19679
  var bomOptExp = /^\uFEFF?/;
19679
19680
  var externalExp = /^([ \t]*declare module )(['"])(.+?)(\2[ \t]*{?.*)$/;
@@ -19981,13 +19982,13 @@ async function bundle(options8) {
19981
19982
  return result;
19982
19983
  }
19983
19984
  function traceObject(obj) {
19984
- if (verbose) console.log(obj);
19985
+ if (verbose) console.dir(obj, { colors: true });
19985
19986
  }
19986
19987
  function trace(...args) {
19987
- if (verbose) console.log(util2.format.apply(null, args));
19988
+ if (verbose) console.log(chalk.gray(util2.format.apply(null, args)));
19988
19989
  }
19989
19990
  function warning(...args) {
19990
- console.log(util2.format.apply(null, args));
19991
+ console.log(chalk.yellow(util2.format.apply(null, args)));
19991
19992
  }
19992
19993
  function getModName(file) {
19993
19994
  return path15.relative(
@@ -20264,6 +20265,7 @@ function optValue(passed, def) {
20264
20265
  import * as fs5 from "fs/promises";
20265
20266
  import * as os2 from "os";
20266
20267
  import * as path16 from "path";
20268
+ import chalk2 from "chalk";
20267
20269
  var $$ = $({ stdio: "inherit" });
20268
20270
  async function findTsgo(cwd) {
20269
20271
  const workspaceDir = await findWorkspacesRoot(cwd);
@@ -20293,7 +20295,7 @@ async function emitDeclarations(tsconfig, outDir, options8 = {}) {
20293
20295
  );
20294
20296
  }
20295
20297
  if (tsgoPath) {
20296
- console.log("Using tsgo for declaration emit");
20298
+ console.log(chalk2.cyan("Using tsgo for declaration emit"));
20297
20299
  await $$`${tsgoPath}
20298
20300
  -p ${tsconfig}
20299
20301
  --rootDir ${rootDir}
@@ -20322,7 +20324,9 @@ async function copyDeclarations(sourceDirectory, destinationDirectory, options8
20322
20324
  const fullDestinationDirectory = path16.resolve(destinationDirectory);
20323
20325
  if (options8.verbose) {
20324
20326
  console.log(
20325
- `Copying declarations from ${fullSourceDirectory} to ${fullDestinationDirectory}`
20327
+ chalk2.gray(
20328
+ `Copying declarations from ${fullSourceDirectory} to ${fullDestinationDirectory}`
20329
+ )
20326
20330
  );
20327
20331
  }
20328
20332
  await fs5.cp(fullSourceDirectory, fullDestinationDirectory, {
@@ -20357,7 +20361,9 @@ async function moveAndTransformDeclarations({
20357
20361
  });
20358
20362
  if (dtsFiles.length === 0) {
20359
20363
  console.log(
20360
- `No d.ts files found in ${toCopyDir}. Skipping transformation.`
20364
+ chalk2.yellow(
20365
+ `No d.ts files found in ${toCopyDir}. Skipping transformation.`
20366
+ )
20361
20367
  );
20362
20368
  return;
20363
20369
  }
@@ -20407,7 +20413,10 @@ async function moveAndTransformDeclarations({
20407
20413
  await fs5.mkdir(path16.dirname(outFilePath), { recursive: true });
20408
20414
  await fs5.writeFile(outFilePath, result.code);
20409
20415
  } else {
20410
- console.error("failed to transform", dtsFile);
20416
+ console.error(
20417
+ chalk2.red("failed to transform"),
20418
+ chalk2.gray(dtsFile)
20419
+ );
20411
20420
  }
20412
20421
  })
20413
20422
  );
@@ -20432,10 +20441,7 @@ async function createTypes({
20432
20441
  entryPoints
20433
20442
  }) {
20434
20443
  if (builder === "esbuild" && entryPoints && !skipTsc) {
20435
- if (verbose)
20436
- console.log(
20437
- "\u{1F4E6} Bundling TypeScript declarations"
20438
- );
20444
+ if (verbose) console.log(chalk2.blue("\u{1F4E6} Bundling TypeScript declarations"));
20439
20445
  const tmpDir2 = await fs5.mkdtemp(path16.join(os2.tmpdir(), "sse-dts-bundle-"));
20440
20446
  try {
20441
20447
  const tsconfigPath = path16.join(cwd, "tsconfig.build.json");
@@ -20474,11 +20480,15 @@ async function createTypes({
20474
20480
  });
20475
20481
  if (verbose)
20476
20482
  console.log(
20477
- `\u2705 Generated bundled types for ${bundleItem.type}: ${outFilePath}`
20483
+ chalk2.green(
20484
+ `\u2705 Generated bundled types for ${bundleItem.type}: ${outFilePath}`
20485
+ )
20478
20486
  );
20479
20487
  } catch (err) {
20480
- console.error(`\u274C Failed to bundle types for ${entry}`);
20481
- console.error(err.message);
20488
+ console.error(
20489
+ chalk2.red(`\u274C Failed to bundle types for ${entry}`)
20490
+ );
20491
+ console.error(chalk2.red(err.message));
20482
20492
  }
20483
20493
  })
20484
20494
  );
@@ -20504,7 +20514,9 @@ async function createTypes({
20504
20514
  );
20505
20515
  }
20506
20516
  if (verbose)
20507
- console.log(`Building types for ${tsconfigPath} in ${tmpDir}`);
20517
+ console.log(
20518
+ chalk2.cyan(`Building types for ${tsconfigPath} in ${tmpDir}`)
20519
+ );
20508
20520
  await emitDeclarations(tsconfigPath, tmpDir, { useTsgo });
20509
20521
  }
20510
20522
  await moveAndTransformDeclarations({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sse-ui/builder",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Builder By SSE",
5
5
  "type": "module",
6
6
  "scripts": {