mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
63a1c94fbb
measure-headless.mjs prints the number the PR's bundle claim rests on, and it had three ways to report a broken run as a good one. All three reproduced: 1. No zero-output guard (the react-core sibling has one). A run whose bundle collapses to nothing measures ~20-35 B of gzip envelope, prints "0.0 kB" and exits 0 — reported into the CI job summary as a spectacular win. Note a zero-ONLY guard would not have caught the reproduction (35 B, not 0), so this adds a plausibility FLOOR of 8 kB alongside the zero check: ~11x below the real 92.7 kB, so legitimate size work can never trip it. 2. `logLevel: "silent"` discarded `result.warnings` and there was no try/catch, so esbuild resolution problems escaped as an unhandled rejection printing esbuild's internal frames and `errors: [Getter/Setter]` instead of the messages. Silent is kept (as in the sibling) so stdout stays the single figure line CI quotes; warnings are now formatted to stderr and errors are re-thrown with esbuild's own formatted diagnostics. 3. An unbuilt dist died on a raw "Could not resolve" stack. A preflight on dist/headless.mjs now names `npx nx run @copilotkit/react-native:build`, and the catch adds the same hint when the entry specifier is what failed. The measurement itself is untouched — same esbuild options, same synthetic entry, same six symbols, same external list — and still reports 92.7 kB, so comparability across PRs is preserved. A moved figure would have meant the measurement changed rather than its guards. Also adds the test hook RN lacked, mirroring react-core exactly: scripts/__tests__/measure-headless.test.mjs under `node --test`, wired as `test:scripts` and chained into `test`. Coverage targets the failure modes, not the happy path. Both packages' vitest `include` globs are scoped to `src/**`, so the .mjs test cannot collide with the jsdom setup — the reason the sibling runs under node --test in the first place. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
14 lines
768 B
JavaScript
14 lines
768 B
JavaScript
// Same shape as tiny-headless.js plus one construct esbuild warns about
|
|
// (a duplicate object key). Used to prove measureHeadlessBundle RETURNS
|
|
// esbuild's warnings rather than dropping them on the floor — `logLevel:
|
|
// "silent"` stops esbuild printing them, so the script must surface them.
|
|
export const CopilotKitProvider = () => null;
|
|
export const useAgent = () => null;
|
|
export const useFrontendTool = () => null;
|
|
export const useRenderTool = () => null;
|
|
export const useRenderToolCall = () => null;
|
|
// The duplicate key is the POINT of this fixture — it is what makes esbuild
|
|
// emit a warning. Silence the linter rather than the test's subject.
|
|
// oxlint-disable-next-line no-dupe-keys
|
|
export const useComponent = () => ({ duplicated: 1, duplicated: 2 });
|