@mandujs/core 0.32.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.
- package/package.json +4 -1
- package/src/bundler/build.ts +29 -1
- package/src/bundler/generate-static-params.ts +302 -290
- package/src/bundler/prerender.ts +446 -368
- package/src/bundler/types.ts +20 -0
- package/src/config/validate.ts +22 -0
- package/src/diagnose/__tests__/checks.test.ts +378 -0
- package/src/diagnose/checks.ts +599 -0
- package/src/diagnose/index.ts +15 -0
- package/src/diagnose/run.ts +87 -0
- package/src/diagnose/types.ts +53 -0
- package/src/guard/graph.ts +898 -0
- package/src/guard/index.ts +14 -0
- package/src/plugins/__tests__/lifecycle-integration.test.ts +272 -0
- package/src/plugins/__tests__/runner.test.ts +409 -0
- package/src/plugins/define.ts +124 -0
- package/src/plugins/examples/dep-check-plugin.ts +80 -0
- package/src/plugins/examples/prerender-cache-plugin.ts +111 -0
- package/src/plugins/examples/sitemap-plugin.ts +65 -0
- package/src/plugins/hooks.ts +297 -64
- package/src/plugins/index.ts +80 -41
- package/src/plugins/runner.ts +361 -0
- package/src/router/fs-routes.ts +64 -1
- package/src/runtime/server.ts +132 -1
- package/src/spec/schema.ts +25 -0
- package/src/testing/__tests__/reporter.test.ts +454 -0
- package/src/testing/index.ts +29 -0
- 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.
|
|
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,6 +35,8 @@
|
|
|
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",
|
|
39
41
|
"./i18n": "./src/i18n/index.ts",
|
|
40
42
|
"./id": "./src/id/index.ts",
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"./bundler/plugins": "./src/bundler/plugins/index.ts",
|
|
57
59
|
"./bundler/plugins/block-generated-imports": "./src/bundler/plugins/block-generated-imports.ts",
|
|
58
60
|
"./bundler/generate-static-params": "./src/bundler/generate-static-params.ts",
|
|
61
|
+
"./diagnose": "./src/diagnose/index.ts",
|
|
59
62
|
"./dev-error-overlay": "./src/dev-error-overlay/index.ts",
|
|
60
63
|
"./middleware/compose": "./src/middleware/compose.ts",
|
|
61
64
|
"./middleware/define": "./src/middleware/define.ts",
|
package/src/bundler/build.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|