镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Commit 63a7bd7

Browse files
committed
fix: share public prop declarations across component renderers
1 parent ee90c6a commit 63a7bd7

6 files changed

Lines changed: 665 additions & 591 deletions

File tree

‎docs/api/component-library.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ Client methods can explicitly import browser helpers from relative TypeScript mo
8484

8585
Imports resolve from the authored component's package, including browser export conditions and package import maps, even when `outputDir` is outside that package. Comments and import attributes retain their ordinary module meaning. `<script server>` blocks are excluded from the browser component graph and are not executed by the component-library compiler. Supply browser render values through properties or the component's default client script; server-only declarations are unavailable to the generated browser render.
8686

87+
A public `defineProps` declaration in the default script also supplies the initial ordinary STX server render. SSR reads the macro's literal defaults and caller props without executing the client script or its imports. Destructuring (including `class: inputClass`) and an identifier such as `const props = withDefaults(defineProps<Props>(), { ... })` use the same supplied values in both renderers; explicit `false`, `0`, and empty strings are preserved. Supported SSR defaults are literal strings, numbers, booleans, null, arrays and objects containing those values. Functions, calls, computed expressions and interpolated template strings remain browser work; compute server values in `<script server>` when they are needed before hydration.
88+
89+
Private local interfaces or type aliases used only as the `defineProps` type argument are compiler input and are consumed rather than copied into the generated declaration file. A component named `Field` may therefore declare a local `FieldProps`; the generated exported `FieldProps` remains its public DOM attribute contract. Types referenced by public methods continue to travel with those method declarations.
90+
8791
Literal dynamic imports such as `await import('./optional.ts')` use the same source-context dependency graph, including components with no static imports. Their modules execute when imported; distributed ESM includes the required lazy chunks, and the standalone bundle includes their dependencies. Browser dependency checks apply to these imports as well.
8892

8993
Distribute the complete emitted directory, including any `chunks/` files. Both individual ESM entries and `bundle.js` work without the author's source tree. `bundle: false` disables only the standalone bundle; browser dependencies are still compiled into the ESM distribution. Server-only modules such as `node:fs` fail the browser build. Component metadata and SSR helper generation do not execute these browser dependencies.

0 commit comments

Comments
 (0)