@sudajs/cli 0.9.0 → 0.9.2

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.
package/dist/index.d.ts CHANGED
@@ -98,6 +98,7 @@ declare const __testUtils: {
98
98
  createThemeProjectRequire: typeof createThemeProjectRequire;
99
99
  createRemotePageDraft: typeof createRemotePageDraft;
100
100
  findAnchorTagByHref: typeof findAnchorTagByHref;
101
+ formatMissingSharpWarning: typeof formatMissingSharpWarning;
101
102
  loadThemeScopedRenderer: typeof loadThemeScopedRenderer;
102
103
  normalizePlaywrightModule: typeof normalizePlaywrightModule;
103
104
  normalizeSharpModule: typeof normalizeSharpModule;
@@ -195,6 +196,7 @@ type SharpOptimizer = (input: string) => {
195
196
  declare function createThemeProjectRequire(themeRoot: string): NodeJS.Require;
196
197
  declare function normalizePlaywrightModule(moduleValue: unknown): PlaywrightModule | null;
197
198
  declare function normalizeSharpModule(moduleValue: unknown): SharpOptimizer | null;
199
+ declare function formatMissingSharpWarning(): string;
198
200
  /**
199
201
  * 解析人机交互的 `key@version` 格式。允许仅 `key`,也允许带 version。
200
202
  * 注意:theme key 现行约束不含 `@`,所以从右侧第一个 `@` 之后视为 version。
package/dist/index.js CHANGED
@@ -396,6 +396,21 @@ function createThemeEngineRuntimeAliasPlugin() {
396
396
  }
397
397
  };
398
398
  }
399
+ function createThemeDependencyResolverPlugin(root) {
400
+ return {
401
+ name: "suda-theme-dependency-resolver",
402
+ setup(build) {
403
+ const themeRequire = createRequire(path2.join(root, "package.json"));
404
+ build.onResolve({ filter: /^lucide-react(?:\/.*)?$/ }, (args) => {
405
+ if (args.path === "lucide-react/dynamicIconImports") {
406
+ const packageRoot2 = path2.dirname(themeRequire.resolve("lucide-react/package.json"));
407
+ return { path: path2.join(packageRoot2, "dynamicIconImports.mjs") };
408
+ }
409
+ return { path: themeRequire.resolve(args.path) };
410
+ });
411
+ }
412
+ };
413
+ }
399
414
  function safeObjectKeyPart(value) {
400
415
  return value.replace(/[^a-zA-Z0-9._-]/g, "-");
401
416
  }
@@ -678,6 +693,7 @@ async function buildClientRuntime(root, minify) {
678
693
  await mkdir(path2.join(root, "dist"), { recursive: true });
679
694
  const hostReactShimPlugin = createHostReactShimPlugin();
680
695
  const themeEngineRuntimeAliasPlugin = createThemeEngineRuntimeAliasPlugin();
696
+ const themeDependencyResolverPlugin = createThemeDependencyResolverPlugin(root);
681
697
  await build({
682
698
  bundle: true,
683
699
  entryPoints: [entryPoint],
@@ -694,7 +710,7 @@ async function buildClientRuntime(root, minify) {
694
710
  minify,
695
711
  outfile: path2.join(root, "dist", "runtime.client.js"),
696
712
  platform: "browser",
697
- plugins: [hostReactShimPlugin, themeEngineRuntimeAliasPlugin],
713
+ plugins: [hostReactShimPlugin, themeEngineRuntimeAliasPlugin, themeDependencyResolverPlugin],
698
714
  sourcemap: false,
699
715
  target: "es2022",
700
716
  treeShaking: true
@@ -834,6 +850,7 @@ var __testUtils = {
834
850
  createThemeProjectRequire,
835
851
  createRemotePageDraft,
836
852
  findAnchorTagByHref,
853
+ formatMissingSharpWarning,
837
854
  loadThemeScopedRenderer,
838
855
  normalizePlaywrightModule,
839
856
  normalizeSharpModule,
@@ -1194,6 +1211,9 @@ async function loadPlaywright(themeRoot) {
1194
1211
  "Playwright is required for screenshot capture. Install it as a dev dependency: `pnpm add -D playwright && pnpm exec playwright install chromium`."
1195
1212
  );
1196
1213
  }
1214
+ function formatMissingSharpWarning() {
1215
+ return "warning: PNG optimization skipped because optional dependency `sharp` is not installed. Install it as a dev dependency in the theme project: `pnpm add -D sharp`.";
1216
+ }
1197
1217
  var warnedMissingSharp = false;
1198
1218
  var warnedSharpOptimizeFailure = false;
1199
1219
  async function loadOptionalSharp(themeRoot) {
@@ -1218,9 +1238,7 @@ async function optimizePngIfAvailable(themeRoot, filePath) {
1218
1238
  const sharp = await loadOptionalSharp(themeRoot);
1219
1239
  if (!sharp) {
1220
1240
  if (!warnedMissingSharp) {
1221
- console.warn(
1222
- "warning: PNG optimization skipped because optional dependency `sharp` is not installed. Install it in the theme project to enable preview compression."
1223
- );
1241
+ console.warn(formatMissingSharpWarning());
1224
1242
  warnedMissingSharp = true;
1225
1243
  }
1226
1244
  return;