mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
- compileLibrary runs the --npm-static eligibility bar automatically over every bare specifier the graph exposes (opted-in packages' own import and top-level require edges included, iterated to a fixpoint) — an eligible package compiles statically into the library graph, and every fallback the shared frontend records refuses as SC4013 naming the package, the specific failed bar, and the vendor-or-drop remedy (with the profile's SC4013 teaching riding the hint), never SC1010/SC2013's executable-lane teachings. - requireInitStmt now emits the guarded %init call for a bare require naming another opted-in package: the dep's module body never ran before (NULL-closure crash at first use), a latent npm-static gap on both lanes that the library fixpoint hits immediately; the executable lane never exercised an inter-package require. - Contract facts exclude statically-compiled npm files (their .d.ts is dropped by construction, so no npm declaration can name a wire-contract type) while their bytes keep joining source_hash/build_id through moduleOrder; the sidecar stays byte-deterministic and a package-file edit flips both identity hashes. - Builtins keep their story under the npm posture: async_free builtin imports compile alongside npm code, event-loop surfaces still refuse SC4005, no new fence. - New fixtures npm-static, npm-refuse, and contract-npm vendor fake packages per the tests/fixtures/npm precedent; the K12 suites assert the compile and refusal sides on both emissions and the contract suite covers the identity-hash implications.
32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
/* Library-mode npm posture probe: the eligible package's code (mathkit,
|
|
* and its own dep mathdep) compiled statically into the archive — the
|
|
* values below are computed by the packages' shipped JS — plus the
|
|
* builtin (node:path) surface riding the same graph. */
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
extern void kn_init(void);
|
|
extern void kn_set_panic_sink(void (*fn)(void *, const uint8_t *, size_t, uint64_t), void *ctx);
|
|
extern void kn_collect(void);
|
|
extern double kn_scaled(double x);
|
|
extern void kn_tail(const uint8_t *p, size_t len, const uint8_t **out, size_t *out_len);
|
|
|
|
static void sink(void *ctx, const uint8_t *msg, size_t len, uint64_t addr) {
|
|
(void)ctx; (void)msg; (void)len; (void)addr;
|
|
printf("UNEXPECTED SINK\n");
|
|
}
|
|
|
|
int main(void) {
|
|
kn_set_panic_sink(sink, NULL);
|
|
kn_init();
|
|
/* scale(5, 3) = twice(5) * 3 = 30, + OFFSET 7 */
|
|
printf("scaled: %.0f\n", kn_scaled(5));
|
|
const uint8_t *s;
|
|
size_t n;
|
|
kn_tail((const uint8_t *)"/a/b/c.txt", 10, &s, &n);
|
|
printf("tail: %.*s (len %zu)\n", (int)n, s, n);
|
|
kn_collect();
|
|
return 0;
|
|
}
|