@mandujs/core 0.31.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +7 -1
  2. package/src/bundler/build.ts +29 -1
  3. package/src/bundler/generate-static-params.ts +302 -290
  4. package/src/bundler/prerender.ts +446 -368
  5. package/src/bundler/types.ts +20 -0
  6. package/src/config/mandu.ts +58 -1
  7. package/src/config/validate.ts +119 -1
  8. package/src/diagnose/__tests__/checks.test.ts +378 -0
  9. package/src/diagnose/checks.ts +599 -0
  10. package/src/diagnose/index.ts +15 -0
  11. package/src/diagnose/run.ts +87 -0
  12. package/src/diagnose/types.ts +53 -0
  13. package/src/filling/context.ts +60 -0
  14. package/src/guard/check.ts +225 -1
  15. package/src/guard/define-rule.ts +243 -0
  16. package/src/guard/graph.ts +898 -0
  17. package/src/guard/index.ts +40 -0
  18. package/src/guard/rule-presets.ts +379 -0
  19. package/src/i18n/define.ts +126 -0
  20. package/src/i18n/index.ts +52 -0
  21. package/src/i18n/locale-resolver.ts +214 -0
  22. package/src/i18n/message-registry.ts +173 -0
  23. package/src/i18n/types.ts +112 -0
  24. package/src/plugins/__tests__/lifecycle-integration.test.ts +272 -0
  25. package/src/plugins/__tests__/runner.test.ts +409 -0
  26. package/src/plugins/define.ts +124 -0
  27. package/src/plugins/examples/dep-check-plugin.ts +80 -0
  28. package/src/plugins/examples/prerender-cache-plugin.ts +111 -0
  29. package/src/plugins/examples/sitemap-plugin.ts +65 -0
  30. package/src/plugins/hooks.ts +297 -64
  31. package/src/plugins/index.ts +80 -41
  32. package/src/plugins/runner.ts +361 -0
  33. package/src/router/fs-routes.ts +64 -1
  34. package/src/router/fs-scanner.ts +101 -0
  35. package/src/router/index.ts +7 -1
  36. package/src/runtime/server.ts +409 -10
  37. package/src/runtime/ssr.ts +9 -0
  38. package/src/spec/schema.ts +25 -0
  39. package/src/testing/__tests__/reporter.test.ts +454 -0
  40. package/src/testing/index.ts +29 -0
  41. package/src/testing/reporter.ts +676 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/core",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -35,7 +35,10 @@
35
35
  "./middleware/rate-limit": "./src/middleware/rate-limit/index.ts",
36
36
  "./testing": "./src/testing/index.ts",
37
37
  "./plugins": "./src/plugins/index.ts",
38
+ "./plugins/define": "./src/plugins/define.ts",
39
+ "./plugins/runner": "./src/plugins/runner.ts",
38
40
  "./error": "./src/error/index.ts",
41
+ "./i18n": "./src/i18n/index.ts",
39
42
  "./id": "./src/id/index.ts",
40
43
  "./observability": "./src/observability/index.ts",
41
44
  "./perf": "./src/perf/index.ts",
@@ -43,6 +46,8 @@
43
46
  "./routes": "./src/routes/index.ts",
44
47
  "./scheduler": "./src/scheduler/index.ts",
45
48
  "./storage/s3": "./src/storage/s3/index.ts",
49
+ "./guard/define-rule": "./src/guard/define-rule.ts",
50
+ "./guard/rule-presets": "./src/guard/rule-presets.ts",
46
51
  "./bundler/prerender": "./src/bundler/prerender.ts",
47
52
  "./bundler/safe-build": "./src/bundler/safe-build.ts",
48
53
  "./bundler/hmr-types": "./src/bundler/hmr-types.ts",
@@ -53,6 +58,7 @@
53
58
  "./bundler/plugins": "./src/bundler/plugins/index.ts",
54
59
  "./bundler/plugins/block-generated-imports": "./src/bundler/plugins/block-generated-imports.ts",
55
60
  "./bundler/generate-static-params": "./src/bundler/generate-static-params.ts",
61
+ "./diagnose": "./src/diagnose/index.ts",
56
62
  "./dev-error-overlay": "./src/dev-error-overlay/index.ts",
57
63
  "./middleware/compose": "./src/middleware/compose.ts",
58
64
  "./middleware/define": "./src/middleware/define.ts",
@@ -20,6 +20,7 @@ import { defaultBundlerPlugins } from "./plugins";
20
20
  import type { BunPlugin } from "bun";
21
21
  import { mark, measure } from "../perf";
22
22
  import { HMR_PERF } from "../perf/hmr-markers";
23
+ import { runOnBundleComplete } from "../plugins/runner";
23
24
  import {
24
25
  readVendorCache,
25
26
  writeVendorCache,
@@ -40,13 +41,21 @@ import fs from "fs/promises";
40
41
  * sync as the default set grows.
41
42
  */
42
43
  function manduDefaultPlugins(options: BundlerOptions): BunPlugin[] {
43
- return defaultBundlerPlugins({
44
+ const defaults = defaultBundlerPlugins({
44
45
  config: {
45
46
  guard: {
46
47
  blockGeneratedImport: options.blockGeneratedImport,
47
48
  },
48
49
  },
49
50
  });
51
+ // Phase 18.τ — append consumer-supplied bundler plugins (from
52
+ // `defineBundlerPlugin()` hook, resolved by the CLI or library caller).
53
+ // Runs AFTER Mandu defaults so user transforms see already-resolved
54
+ // imports / aliases.
55
+ if (options.pluginBundlerPlugins && options.pluginBundlerPlugins.length > 0) {
56
+ return [...defaults, ...options.pluginBundlerPlugins];
57
+ }
58
+ return defaults;
50
59
  }
51
60
 
52
61
  /**
@@ -1795,6 +1804,22 @@ export async function buildClientBundles(
1795
1804
  const startTime = performance.now();
1796
1805
  const outputs: BundleOutput[] = [];
1797
1806
  const errors: string[] = [];
1807
+
1808
+ // Phase 18.τ — fire `onBundleComplete(stats)` before returning. Helper
1809
+ // is inlined here so every return path in this function can opt in
1810
+ // with a single `await fireOnBundleComplete(stats);` call without
1811
+ // leaking plugin plumbing into the hot path.
1812
+ const fireOnBundleComplete = async (stats: BundleStats): Promise<void> => {
1813
+ const plugins = options.plugins ?? [];
1814
+ if (plugins.length === 0 && !options.configHooks) return;
1815
+ const { errors: hookErrors } = await runOnBundleComplete(stats, {
1816
+ plugins,
1817
+ configHooks: options.configHooks,
1818
+ });
1819
+ for (const e of hookErrors) {
1820
+ errors.push(`onBundleComplete[${e.source}]: ${e.error.message}`);
1821
+ }
1822
+ };
1798
1823
  const env = (process.env.NODE_ENV === "production" ? "production" : "development") as
1799
1824
  | "development"
1800
1825
  | "production";
@@ -2166,6 +2191,9 @@ export async function buildClientBundles(
2166
2191
  // 7. 통계 계산
2167
2192
  const stats = calculateStats(outputs, startTime);
2168
2193
 
2194
+ // Phase 18.τ — fire onBundleComplete(stats) before return.
2195
+ await fireOnBundleComplete(stats);
2196
+
2169
2197
  measure("bundler:full", "bundler:full");
2170
2198
  return {
2171
2199
  success: errors.length === 0,