@nifrajs/cli 3.3.0 → 4.0.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/README.md +42 -3
- package/dist/app-files.d.ts +11 -0
- package/dist/app-files.d.ts.map +1 -0
- package/dist/app-files.js +34 -0
- package/dist/app-files.js.map +1 -0
- package/dist/assure-hydration.d.ts +7 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +128 -43
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +16 -2
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts +5 -1
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +32 -10
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/cdn-check.d.ts +41 -0
- package/dist/cdn-check.d.ts.map +1 -0
- package/dist/cdn-check.js +207 -0
- package/dist/cdn-check.js.map +1 -0
- package/dist/check-diagnostics.d.ts +7 -15
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +162 -713
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +58 -7
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +323 -62
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts +1 -0
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +145 -54
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +42 -16
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +306 -87
- package/dist/cli.js.map +1 -1
- package/dist/command-catalog.d.ts +60 -5
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +298 -33
- package/dist/command-catalog.js.map +1 -1
- package/dist/config-target.d.ts +8 -0
- package/dist/config-target.d.ts.map +1 -0
- package/dist/config-target.js +45 -0
- package/dist/config-target.js.map +1 -0
- package/dist/contracts.d.ts +3 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +56 -16
- package/dist/contracts.js.map +1 -1
- package/dist/db-audit.d.ts +37 -0
- package/dist/db-audit.d.ts.map +1 -0
- package/dist/db-audit.js +99 -0
- package/dist/db-audit.js.map +1 -0
- package/dist/db-child.d.ts +64 -0
- package/dist/db-child.d.ts.map +1 -0
- package/dist/db-child.js +213 -0
- package/dist/db-child.js.map +1 -0
- package/dist/db-config.d.ts +60 -0
- package/dist/db-config.d.ts.map +1 -0
- package/dist/db-config.js +176 -0
- package/dist/db-config.js.map +1 -0
- package/dist/db-tool.d.ts +84 -0
- package/dist/db-tool.d.ts.map +1 -0
- package/dist/db-tool.js +537 -0
- package/dist/db-tool.js.map +1 -0
- package/dist/dev-bun-config.d.ts +20 -13
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +98 -41
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.d.ts +106 -0
- package/dist/dev-feed-tool.d.ts.map +1 -0
- package/dist/dev-feed-tool.js +713 -0
- package/dist/dev-feed-tool.js.map +1 -0
- package/dist/dev-server-client.d.ts +67 -0
- package/dist/dev-server-client.d.ts.map +1 -0
- package/dist/dev-server-client.js +195 -0
- package/dist/dev-server-client.js.map +1 -0
- package/dist/diagnostics.d.ts +86 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +85 -0
- package/dist/diagnostics.js.map +1 -1
- package/dist/diff-tool.d.ts +3 -3
- package/dist/diff-tool.d.ts.map +1 -1
- package/dist/diff-tool.js +6 -5
- package/dist/diff-tool.js.map +1 -1
- package/dist/docs-search.d.ts.map +1 -1
- package/dist/docs-search.js +12 -4
- package/dist/docs-search.js.map +1 -1
- package/dist/doctor.d.ts +17 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +76 -15
- package/dist/doctor.js.map +1 -1
- package/dist/env-file.d.ts +15 -0
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +73 -1
- package/dist/env-file.js.map +1 -1
- package/dist/fix-recipes.d.ts.map +1 -1
- package/dist/fix-recipes.js +41 -21
- package/dist/fix-recipes.js.map +1 -1
- package/dist/frontend-guidance.js +5 -5
- package/dist/frontend-guidance.js.map +1 -1
- package/dist/i18n-check.d.ts +16 -0
- package/dist/i18n-check.d.ts.map +1 -0
- package/dist/i18n-check.js +154 -0
- package/dist/i18n-check.js.map +1 -0
- package/dist/init-agents.d.ts +49 -13
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +239 -34
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/code-unit-order.d.ts +4 -0
- package/dist/internal/code-unit-order.d.ts.map +1 -0
- package/dist/internal/code-unit-order.js +6 -0
- package/dist/internal/code-unit-order.js.map +1 -0
- package/dist/internal/script-kind.d.ts +7 -0
- package/dist/internal/script-kind.d.ts.map +1 -0
- package/dist/internal/script-kind.js +12 -0
- package/dist/internal/script-kind.js.map +1 -0
- package/dist/internal/source-facts.d.ts +5 -0
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +61 -5
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.d.ts +49 -24
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +507 -67
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/introspect.d.ts +6 -4
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +93 -74
- package/dist/introspect.js.map +1 -1
- package/dist/learn.js +3 -3
- package/dist/learn.js.map +1 -1
- package/dist/levels-tool.d.ts +10 -0
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +33 -3
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +71 -16
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +78 -18
- package/dist/load.js.map +1 -1
- package/dist/manifest-tool.d.ts.map +1 -1
- package/dist/manifest-tool.js +3 -2
- package/dist/manifest-tool.js.map +1 -1
- package/dist/mcp-app-tool.d.ts.map +1 -1
- package/dist/mcp-app-tool.js +2 -0
- package/dist/mcp-app-tool.js.map +1 -1
- package/dist/mcp-context.d.ts.map +1 -1
- package/dist/mcp-context.js +5 -6
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.d.ts +57 -0
- package/dist/mcp-delegate.d.ts.map +1 -0
- package/dist/mcp-delegate.js +130 -0
- package/dist/mcp-delegate.js.map +1 -0
- package/dist/mcp-docs-tools.d.ts.map +1 -1
- package/dist/mcp-docs-tools.js +23 -5
- package/dist/mcp-docs-tools.js.map +1 -1
- package/dist/mcp-exec.d.ts +3 -0
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +263 -131
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.d.ts.map +1 -1
- package/dist/mcp-http.js +20 -5
- package/dist/mcp-http.js.map +1 -1
- package/dist/mcp-io.d.ts +26 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +113 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-isolate.d.ts +48 -0
- package/dist/mcp-isolate.d.ts.map +1 -0
- package/dist/mcp-isolate.js +222 -0
- package/dist/mcp-isolate.js.map +1 -0
- package/dist/mcp-path.d.ts +10 -0
- package/dist/mcp-path.d.ts.map +1 -0
- package/dist/mcp-path.js +51 -0
- package/dist/mcp-path.js.map +1 -0
- package/dist/mcp-project-child.d.ts +74 -0
- package/dist/mcp-project-child.d.ts.map +1 -0
- package/dist/mcp-project-child.js +130 -0
- package/dist/mcp-project-child.js.map +1 -0
- package/dist/mcp-reflect.d.ts.map +1 -1
- package/dist/mcp-reflect.js +2 -2
- package/dist/mcp-reflect.js.map +1 -1
- package/dist/mcp-render.d.ts.map +1 -1
- package/dist/mcp-render.js +64 -45
- package/dist/mcp-render.js.map +1 -1
- package/dist/mcp-root.d.ts +37 -9
- package/dist/mcp-root.d.ts.map +1 -1
- package/dist/mcp-root.js +124 -25
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp-run.d.ts +18 -1
- package/dist/mcp-run.d.ts.map +1 -1
- package/dist/mcp-run.js +159 -55
- package/dist/mcp-run.js.map +1 -1
- package/dist/mcp-ws.js +4 -1
- package/dist/mcp-ws.js.map +1 -1
- package/dist/mcp.d.ts +18 -5
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +165 -82
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.d.ts +44 -0
- package/dist/migrate-layout.d.ts.map +1 -0
- package/dist/migrate-layout.js +982 -0
- package/dist/migrate-layout.js.map +1 -0
- package/dist/openapi-tool.d.ts +2 -2
- package/dist/openapi-tool.d.ts.map +1 -1
- package/dist/openapi-tool.js.map +1 -1
- package/dist/openapi-types.d.ts +2 -1
- package/dist/openapi-types.d.ts.map +1 -1
- package/dist/openapi-types.js +240 -12
- package/dist/openapi-types.js.map +1 -1
- package/dist/pipeline-report.d.ts +3 -2
- package/dist/pipeline-report.d.ts.map +1 -1
- package/dist/pipeline-report.js +19 -16
- package/dist/pipeline-report.js.map +1 -1
- package/dist/port.d.ts +5 -4
- package/dist/port.d.ts.map +1 -1
- package/dist/port.js +46 -29
- package/dist/port.js.map +1 -1
- package/dist/project-facts.d.ts +28 -4
- package/dist/project-facts.d.ts.map +1 -1
- package/dist/project-facts.js +12 -2
- package/dist/project-facts.js.map +1 -1
- package/dist/recipes/4.0.0.d.ts +9 -0
- package/dist/recipes/4.0.0.d.ts.map +1 -0
- package/dist/recipes/4.0.0.js +34 -0
- package/dist/recipes/4.0.0.js.map +1 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +2 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.d.ts +11 -1
- package/dist/release-verification.d.ts.map +1 -1
- package/dist/release-verification.js +47 -4
- package/dist/release-verification.js.map +1 -1
- package/dist/review.d.ts +21 -0
- package/dist/review.d.ts.map +1 -0
- package/dist/review.js +823 -0
- package/dist/review.js.map +1 -0
- package/dist/route-types.d.ts +28 -0
- package/dist/route-types.d.ts.map +1 -0
- package/dist/route-types.js +106 -0
- package/dist/route-types.js.map +1 -0
- package/dist/rules/codes.d.ts +9 -0
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +9 -0
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/data-guard.d.ts +12 -0
- package/dist/rules/data-guard.d.ts.map +1 -0
- package/dist/rules/data-guard.js +213 -0
- package/dist/rules/data-guard.js.map +1 -0
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +17 -5
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/islands.d.ts.map +1 -1
- package/dist/rules/islands.js +7 -4
- package/dist/rules/islands.js.map +1 -1
- package/dist/rules/legacy.d.ts +3 -1
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +829 -34
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/nano.d.ts.map +1 -1
- package/dist/rules/nano.js +15 -6
- package/dist/rules/nano.js.map +1 -1
- package/dist/rules/pages.d.ts +15 -0
- package/dist/rules/pages.d.ts.map +1 -0
- package/dist/rules/pages.js +88 -0
- package/dist/rules/pages.js.map +1 -0
- package/dist/rules/routes.d.ts +11 -0
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +180 -2
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/secrets.d.ts +10 -0
- package/dist/rules/secrets.d.ts.map +1 -0
- package/dist/rules/secrets.js +169 -0
- package/dist/rules/secrets.js.map +1 -0
- package/dist/rules/security.d.ts +7 -0
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +171 -65
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/typescript.d.ts +16 -0
- package/dist/rules/typescript.d.ts.map +1 -0
- package/dist/rules/typescript.js +59 -0
- package/dist/rules/typescript.js.map +1 -0
- package/dist/rules/zones.d.ts +17 -0
- package/dist/rules/zones.d.ts.map +1 -0
- package/dist/rules/zones.js +174 -0
- package/dist/rules/zones.js.map +1 -0
- package/dist/scaffold.d.ts +25 -12
- package/dist/scaffold.d.ts.map +1 -1
- package/dist/scaffold.js +154 -90
- package/dist/scaffold.js.map +1 -1
- package/dist/sdk.d.ts +17 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +941 -153
- package/dist/sdk.js.map +1 -1
- package/dist/search-terms.d.ts +2 -0
- package/dist/search-terms.d.ts.map +1 -1
- package/dist/search-terms.js +23 -8
- package/dist/search-terms.js.map +1 -1
- package/dist/smoke.d.ts +79 -0
- package/dist/smoke.d.ts.map +1 -0
- package/dist/smoke.js +494 -0
- package/dist/smoke.js.map +1 -0
- package/dist/sync-manifest.d.ts.map +1 -1
- package/dist/sync-manifest.js +2 -1
- package/dist/sync-manifest.js.map +1 -1
- package/dist/sync-routes.d.ts +4 -3
- package/dist/sync-routes.d.ts.map +1 -1
- package/dist/sync-routes.js +4 -3
- package/dist/sync-routes.js.map +1 -1
- package/dist/test-tool.d.ts.map +1 -1
- package/dist/test-tool.js +30 -11
- package/dist/test-tool.js.map +1 -1
- package/dist/types-search.d.ts.map +1 -1
- package/dist/types-search.js +11 -5
- package/dist/types-search.js.map +1 -1
- package/dist/upgrade.d.ts +36 -6
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +167 -29
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +8 -0
- package/dist/verification-plan.js.map +1 -1
- package/dist/verification.d.ts.map +1 -1
- package/dist/verification.js +45 -12
- package/dist/verification.js.map +1 -1
- package/dist/web-app-options.d.ts +19 -0
- package/dist/web-app-options.d.ts.map +1 -0
- package/dist/web-app-options.js +49 -0
- package/dist/web-app-options.js.map +1 -0
- package/dist/work-graph.d.ts +3 -0
- package/dist/work-graph.d.ts.map +1 -1
- package/dist/work-graph.js +33 -16
- package/dist/work-graph.js.map +1 -1
- package/docs/examples.json +185 -29
- package/docs/llms-full.txt +4123 -548
- package/docs/types.json +14391 -10060
- package/package.json +19 -11
- package/src/app-files.ts +40 -0
- package/src/assure-hydration.ts +139 -46
- package/src/assure.ts +17 -2
- package/src/capabilities-tool.ts +35 -9
- package/src/cdn-check.ts +268 -0
- package/src/check-diagnostics.ts +199 -797
- package/src/check-scan.ts +394 -63
- package/src/check.ts +146 -58
- package/src/cli.ts +347 -92
- package/src/command-catalog.ts +407 -45
- package/src/config-target.ts +47 -0
- package/src/contracts.ts +66 -15
- package/src/db-audit.ts +128 -0
- package/src/db-child.ts +285 -0
- package/src/db-config.ts +224 -0
- package/src/db-tool.ts +690 -0
- package/src/dev-bun-config.ts +116 -40
- package/src/dev-feed-tool.ts +912 -0
- package/src/dev-server-client.ts +267 -0
- package/src/diagnostics.ts +179 -0
- package/src/diff-tool.ts +6 -5
- package/src/docs-search.ts +10 -3
- package/src/doctor.ts +98 -15
- package/src/env-file.ts +78 -1
- package/src/fix-recipes.ts +44 -31
- package/src/frontend-guidance.ts +5 -5
- package/src/i18n-check.ts +179 -0
- package/src/init-agents.ts +301 -38
- package/src/internal/code-unit-order.ts +5 -0
- package/src/internal/script-kind.ts +11 -0
- package/src/internal/source-facts.ts +96 -22
- package/src/internal/typescript-import.ts +663 -68
- package/src/introspect.ts +93 -82
- package/src/learn.ts +3 -3
- package/src/levels-tool.ts +47 -2
- package/src/load.ts +144 -32
- package/src/manifest-tool.ts +3 -2
- package/src/mcp-app-tool.ts +2 -0
- package/src/mcp-context.ts +5 -7
- package/src/mcp-delegate.ts +162 -0
- package/src/mcp-docs-tools.ts +23 -5
- package/src/mcp-exec.ts +301 -161
- package/src/mcp-http.ts +22 -5
- package/src/mcp-io.ts +130 -0
- package/src/mcp-isolate.ts +287 -0
- package/src/mcp-path.ts +50 -0
- package/src/mcp-project-child.ts +182 -0
- package/src/mcp-reflect.ts +3 -2
- package/src/mcp-render.ts +72 -42
- package/src/mcp-root.ts +130 -24
- package/src/mcp-run.ts +190 -56
- package/src/mcp-ws.ts +4 -1
- package/src/mcp.ts +193 -91
- package/src/migrate-layout.ts +1121 -0
- package/src/openapi-tool.ts +7 -3
- package/src/openapi-types.ts +315 -13
- package/src/pipeline-report.ts +22 -18
- package/src/port.ts +53 -30
- package/src/project-facts.ts +42 -8
- package/src/recipes/4.0.0.ts +35 -0
- package/src/recipes/index.ts +2 -0
- package/src/release-verification.ts +74 -5
- package/src/review.ts +988 -0
- package/src/route-types.ts +133 -0
- package/src/rules/codes.ts +9 -0
- package/src/rules/data-guard.ts +230 -0
- package/src/rules/index.ts +18 -5
- package/src/rules/islands.ts +12 -4
- package/src/rules/legacy.ts +947 -35
- package/src/rules/nano.ts +18 -6
- package/src/rules/pages.ts +99 -0
- package/src/rules/routes.ts +181 -2
- package/src/rules/secrets.ts +174 -0
- package/src/rules/security.ts +198 -70
- package/src/rules/typescript.ts +77 -0
- package/src/rules/zones.ts +195 -0
- package/src/scaffold.ts +175 -98
- package/src/sdk.ts +1215 -158
- package/src/search-terms.ts +24 -7
- package/src/smoke.ts +607 -0
- package/src/sync-manifest.ts +2 -1
- package/src/sync-routes.ts +4 -3
- package/src/test-tool.ts +32 -11
- package/src/types-search.ts +11 -4
- package/src/upgrade.ts +205 -25
- package/src/verification-plan.ts +27 -0
- package/src/verification.ts +50 -12
- package/src/web-app-options.ts +57 -0
- package/src/work-graph.ts +40 -16
package/src/dev-bun-config.ts
CHANGED
|
@@ -3,24 +3,26 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Bun's dev-server bundling (`Bun.serve` HTML imports) accepts plugins ONLY through bunfig's
|
|
5
5
|
* `[serve.static] plugins` - there is no programmatic option (upstream ask: oven-sh/bun#36830), and
|
|
6
|
-
* a runtime `Bun.plugin()` never reaches it. Without a plugin there, a `*.fn` server-function
|
|
7
|
-
* would ship to the browser WHOLE (body, DB handles, secrets) instead of as the RPC stub the
|
|
8
|
-
* production client build emits, and a
|
|
6
|
+
* a runtime `Bun.plugin()` never reaches it. Without a plugin there, a `*.fn` server-function
|
|
7
|
+
* module would ship to the browser WHOLE (body, DB handles, secrets) instead of as the RPC stub the
|
|
8
|
+
* production client build emits, and backend code a browser module imports would be served instead
|
|
9
|
+
* of refused.
|
|
9
10
|
*
|
|
10
11
|
* The same channel is the only way an app's OWN `clientPlugins` (SFC compilers and the like) can reach
|
|
11
12
|
* that bundler: the CLI holds them as plugin OBJECTS, and bunfig accepts only module paths - so the
|
|
12
13
|
* generated module re-imports the app's config and composes them in.
|
|
13
14
|
*
|
|
14
15
|
* So the CLI generates, under `.nifra/dev-bun/`:
|
|
15
|
-
* - `boundary-plugin.ts` - default-exports one plugin composing the SAME `
|
|
16
|
-
* `
|
|
17
|
-
* `@nifrajs/web`, resolved from the app - identical transforms, not re-implementations), plus
|
|
18
|
-
* app's own `clientPlugins`;
|
|
16
|
+
* - `boundary-plugin.ts` - default-exports one plugin composing the SAME `zoneGuardPlugin` +
|
|
17
|
+
* `serverFnStubPlugin` + CSS Modules transform the production build uses (imported from
|
|
18
|
+
* `@nifrajs/web`, resolved from the app - identical transforms, not re-implementations), plus
|
|
19
|
+
* the app's own `clientPlugins`;
|
|
19
20
|
* - `bunfig.toml` - the app's ENTIRE bunfig carried over verbatim (jsx, loaders, defines, install
|
|
20
|
-
* settings - dropping any of them would give dev a different Bun than the app configured),
|
|
21
|
-
* `[serve.static] plugins`
|
|
22
|
-
* (`preload`, plugin paths) re-rooted at
|
|
23
|
-
* against the CONFIG file's directory;
|
|
21
|
+
* settings - dropping any of them would give dev a different Bun than the app configured), except
|
|
22
|
+
* that `[serve.static] plugins` names only the boundary plugin, which composes the app's own
|
|
23
|
+
* entries last, in their order; path-bearing entries (`preload`, plugin paths) are re-rooted at
|
|
24
|
+
* the app, because bunfig resolves relative entries against the CONFIG file's directory; and
|
|
25
|
+
* the config's `define` is layered over both `[define]` and `[serve.static] define`;
|
|
24
26
|
* - `launch-token` - a per-launch random value (see below).
|
|
25
27
|
*
|
|
26
28
|
* `dev --bun` then re-execs itself once with `--config=<generated>` (bunfig is read at process
|
|
@@ -106,33 +108,68 @@ export function serializeBunfig(data: BunfigData): string {
|
|
|
106
108
|
return `${lines.join("\n")}\n`
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
/** A bunfig entry that names a file, re-rooted at the APP: bunfig resolves a relative entry against
|
|
112
|
+
* the config file's own directory, which for the generated config is `.nifra/dev-bun/`. */
|
|
113
|
+
const resolveEntry = (entry: unknown, appRoot: string): unknown =>
|
|
114
|
+
typeof entry === "string" && entry.startsWith(".") ? resolve(appRoot, entry) : entry
|
|
115
|
+
|
|
116
|
+
/** The app's own `[serve.static] plugins`, re-rooted at the app, for the boundary module to compose. */
|
|
117
|
+
export function userServePlugins(user: BunfigData, appRoot: string): string[] {
|
|
118
|
+
const serve = isTable(user.serve) ? user.serve : {}
|
|
119
|
+
const serveStatic = isTable(serve.static) ? serve.static : {}
|
|
120
|
+
const plugins = Array.isArray(serveStatic.plugins) ? serveStatic.plugins : []
|
|
121
|
+
return plugins.map((entry, i) => {
|
|
122
|
+
const resolved = resolveEntry(entry, appRoot)
|
|
123
|
+
if (typeof resolved !== "string") {
|
|
124
|
+
throw new Error(`[nifra] bunfig field \`serve.static.plugins[${i}]\` must be a module path`)
|
|
125
|
+
}
|
|
126
|
+
return resolved
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Render the generated bunfig: the user's config carried whole, with `[serve.static] plugins` naming
|
|
131
|
+
* only the boundary plugin (it composes the app's own entries, see {@link userServePlugins}),
|
|
132
|
+
* `preload` re-rooted at the APP, and the config's `define` added to both halves. */
|
|
113
133
|
export function renderDevBunfig(
|
|
114
134
|
boundaryPluginPath: string,
|
|
115
135
|
user: BunfigData,
|
|
116
136
|
appRoot: string,
|
|
137
|
+
define: Readonly<Record<string, string>> = {},
|
|
117
138
|
): string {
|
|
118
|
-
const resolveEntry = (entry: unknown): unknown =>
|
|
119
|
-
typeof entry === "string" && entry.startsWith(".") ? resolve(appRoot, entry) : entry
|
|
120
139
|
const data: BunfigData = structuredClone(user)
|
|
121
140
|
if (data.preload !== undefined) {
|
|
122
141
|
const entries = Array.isArray(data.preload) ? data.preload : [data.preload]
|
|
123
|
-
data.preload = entries.map(resolveEntry)
|
|
142
|
+
data.preload = entries.map((entry) => resolveEntry(entry, appRoot))
|
|
124
143
|
}
|
|
125
144
|
const serve = isTable(data.serve) ? data.serve : {}
|
|
126
145
|
data.serve = serve
|
|
127
146
|
const serveStatic = isTable(serve.static) ? serve.static : {}
|
|
128
147
|
serve.static = serveStatic
|
|
129
|
-
|
|
130
|
-
|
|
148
|
+
serveStatic.plugins = [boundaryPluginPath]
|
|
149
|
+
if (Object.keys(define).length > 0) {
|
|
150
|
+
for (const [key, value] of Object.entries(define)) {
|
|
151
|
+
if (typeof value !== "string") {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`[nifra] \`define\` entry \`${key}\` must be a string of source code, such as "true" or ` +
|
|
154
|
+
`'"text"' - it replaces the name in the bundle as written.`,
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// `nifra build` applies `define` to the client and the server bundle. In dev the two halves read
|
|
159
|
+
// different keys: the runtime SSR runs in honours only top-level `[define]`, Bun's dev-server
|
|
160
|
+
// bundler only `[serve.static] define`. Layered last, so a clash resolves the way production does.
|
|
161
|
+
data.define = Object.assign(isTable(data.define) ? data.define : {}, define)
|
|
162
|
+
serveStatic.define = Object.assign(
|
|
163
|
+
isTable(serveStatic.define) ? serveStatic.define : {},
|
|
164
|
+
define,
|
|
165
|
+
)
|
|
166
|
+
}
|
|
131
167
|
return (
|
|
132
168
|
"# Generated by `nifra dev --bun` - do not edit. Regenerated on every dev start.\n" +
|
|
133
169
|
"# The app's own bunfig is carried over verbatim; [serve.static] plugins additionally deliver\n" +
|
|
134
|
-
"# the client-boundary plugins (
|
|
135
|
-
"# bundler, which only accepts plugins via this channel (oven-sh/bun#36830)
|
|
170
|
+
"# the client-boundary plugins (zone guard, server-fn stubs) to Bun's dev-server\n" +
|
|
171
|
+
"# bundler, which only accepts plugins via this channel (oven-sh/bun#36830). The app's\n" +
|
|
172
|
+
"# config `define` is added to [define] (SSR) and [serve.static] define (client).\n" +
|
|
136
173
|
serializeBunfig(data)
|
|
137
174
|
)
|
|
138
175
|
}
|
|
@@ -151,13 +188,22 @@ function relativeSpecifier(fromDir: string, target: string): string {
|
|
|
151
188
|
* The `@nifrajs/*` specifiers are bare so they resolve from the APP's install (the module lives under
|
|
152
189
|
* the app's `.nifra/`), keeping dev transforms byte-identical to production's.
|
|
153
190
|
*
|
|
154
|
-
* `configPath` is the app's `nifra.config.ts` (or `framework.ts`). Importing it here is the
|
|
155
|
-
* app's `clientPlugins` can reach Bun's dev-server bundler at all: that bundler takes
|
|
156
|
-
* PATHS via bunfig, never as the plugin objects the CLI already holds in memory.
|
|
157
|
-
* whose transforms live in `clientPlugins` had no working Bun dev loop - its
|
|
158
|
-
* with the transform silently missing. `setup` is async because
|
|
191
|
+
* `configPath` is the app's `nifra.config.ts` (or `backend/framework.ts`). Importing it here is the
|
|
192
|
+
* only way an app's `clientPlugins` can reach Bun's dev-server bundler at all: that bundler takes
|
|
193
|
+
* plugins as module PATHS via bunfig, never as the plugin objects the CLI already holds in memory.
|
|
194
|
+
* Without this an app whose transforms live in `clientPlugins` had no working Bun dev loop - its
|
|
195
|
+
* client would be bundled with the transform silently missing. `setup` is async because
|
|
196
|
+
* `clientPlugins` may be a thunk.
|
|
197
|
+
*
|
|
198
|
+
* `servePlugins` are the app's own bunfig `[serve.static] plugins`, composed last and in order rather
|
|
199
|
+
* than listed beside this module, so that every plugin reaching the bundler registers through
|
|
200
|
+
* `reserveDevSpecifiers` (see `@nifrajs/web/internal/dev-reserved`).
|
|
159
201
|
*/
|
|
160
|
-
export function renderBoundaryPluginModule(
|
|
202
|
+
export function renderBoundaryPluginModule(
|
|
203
|
+
configPath?: string,
|
|
204
|
+
pluginDir?: string,
|
|
205
|
+
servePlugins: readonly string[] = [],
|
|
206
|
+
): string {
|
|
161
207
|
const appImport =
|
|
162
208
|
configPath !== undefined && pluginDir !== undefined
|
|
163
209
|
? `import * as appConfig from ${tomlString(relativeSpecifier(pluginDir, configPath))}\n`
|
|
@@ -168,25 +214,49 @@ export function renderBoundaryPluginModule(configPath?: string, pluginDir?: stri
|
|
|
168
214
|
: ` // The app's OWN client transforms (SFC compilers etc.). \`clientPlugins\` may be a thunk.
|
|
169
215
|
const field = appConfig.clientPlugins
|
|
170
216
|
const appPlugins = (typeof field === "function" ? await field() : field) ?? []
|
|
171
|
-
for (const p of appPlugins) await p.setup(
|
|
217
|
+
for (const p of appPlugins) await p.setup(guarded)
|
|
218
|
+
`
|
|
219
|
+
const serveSetup =
|
|
220
|
+
servePlugins.length === 0
|
|
221
|
+
? ""
|
|
222
|
+
: ` // The app's own bunfig [serve.static] plugins, as Bun would load them, in their order.
|
|
223
|
+
for (const specifier of ${JSON.stringify(servePlugins)}) {
|
|
224
|
+
const plugin = (await import(specifier)).default
|
|
225
|
+
if (typeof plugin?.setup !== "function") {
|
|
226
|
+
throw new TypeError(\`[nifra] bunfig.toml [serve.static] plugin "\${specifier}" does not default-export a bundler plugin\`)
|
|
227
|
+
}
|
|
228
|
+
await plugin.setup(guarded)
|
|
229
|
+
}
|
|
172
230
|
`
|
|
173
231
|
return `// Generated by \`nifra dev\` (Bun pipeline) - do not edit. Regenerated on every dev start.
|
|
174
|
-
import { serverFnStubPlugin,
|
|
232
|
+
import { serverFnStubPlugin, zoneGuardPlugin } from "@nifrajs/web/build"
|
|
233
|
+
import { reserveDevSpecifiers } from "@nifrajs/web/internal/dev-reserved"
|
|
175
234
|
import { cssModulesBunPlugin } from "@nifrajs/web/plugins/css-modules"
|
|
176
235
|
${appImport}
|
|
236
|
+
// This module lives at <app>/.nifra/dev-bun/, so the app root is two directories up.
|
|
237
|
+
const zones = zoneGuardPlugin({
|
|
238
|
+
appRoot: Bun.fileURLToPath(new URL("../../", import.meta.url)),${
|
|
239
|
+
appImport === ""
|
|
240
|
+
? ""
|
|
241
|
+
: `
|
|
242
|
+
...(typeof appConfig.publicEnvPrefix === "string" ? { publicEnvPrefix: appConfig.publicEnvPrefix } : {}),`
|
|
243
|
+
}
|
|
244
|
+
})
|
|
177
245
|
const fn = serverFnStubPlugin()
|
|
178
|
-
const serverOnly = serverOnlyEmptyPlugin()
|
|
179
246
|
const cssModules = cssModulesBunPlugin("dom")
|
|
180
247
|
|
|
181
248
|
export default {
|
|
182
249
|
name: "nifra-dev-boundary",
|
|
183
250
|
async setup(build) {
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
251
|
+
// Every plugin below registers through this view: a resolve filter matching the dev entry script
|
|
252
|
+
// or Bun's built-in React refresh runtime breaks the page even when its handler declines.
|
|
253
|
+
const guarded = reserveDevSpecifiers(build)
|
|
254
|
+
// Boundary first: an app plugin must never get to transform a module that the boundary is about
|
|
255
|
+
// to refuse or stub, or the transform decides what ships instead of the boundary.
|
|
256
|
+
zones.setup(guarded)
|
|
257
|
+
fn.setup(guarded)
|
|
258
|
+
cssModules.setup(guarded)
|
|
259
|
+
${appSetup}${serveSetup} },
|
|
190
260
|
}
|
|
191
261
|
`
|
|
192
262
|
}
|
|
@@ -201,20 +271,26 @@ const TOKEN_FILE = "launch-token"
|
|
|
201
271
|
|
|
202
272
|
/** Write the generated config for an app; returns the bunfig path to re-exec with and the fresh
|
|
203
273
|
* launch token to pass in the child's environment. `configPath` (the app's `nifra.config.ts` /
|
|
204
|
-
* `framework.ts`) is what lets the app's own `clientPlugins` reach Bun's dev-server
|
|
274
|
+
* `backend/framework.ts`) is what lets the app's own `clientPlugins` reach Bun's dev-server
|
|
275
|
+
* bundler; `define` is the config's own. */
|
|
205
276
|
export async function writeBunDevConfig(
|
|
206
277
|
appRoot: string,
|
|
207
278
|
configPath?: string,
|
|
279
|
+
define?: Readonly<Record<string, string>>,
|
|
208
280
|
): Promise<BunDevConfig> {
|
|
209
281
|
const dir = resolve(appRoot, ".nifra", "dev-bun")
|
|
210
282
|
mkdirSync(dir, { recursive: true })
|
|
211
283
|
const pluginPath = resolve(dir, "boundary-plugin.ts")
|
|
212
|
-
writeFileSync(pluginPath, renderBoundaryPluginModule(configPath, dir))
|
|
213
284
|
const userToml = await Bun.file(resolve(appRoot, "bunfig.toml"))
|
|
214
285
|
.text()
|
|
215
286
|
.catch(() => undefined)
|
|
287
|
+
const user = parseUserBunfig(userToml)
|
|
288
|
+
writeFileSync(
|
|
289
|
+
pluginPath,
|
|
290
|
+
renderBoundaryPluginModule(configPath, dir, userServePlugins(user, appRoot)),
|
|
291
|
+
)
|
|
216
292
|
const bunfigPath = resolve(dir, "bunfig.toml")
|
|
217
|
-
writeFileSync(bunfigPath, renderDevBunfig(pluginPath,
|
|
293
|
+
writeFileSync(bunfigPath, renderDevBunfig(pluginPath, user, appRoot, define))
|
|
218
294
|
const launchToken = crypto.randomUUID()
|
|
219
295
|
writeFileSync(resolve(dir, TOKEN_FILE), launchToken)
|
|
220
296
|
return { bunfigPath, launchToken }
|