Skip to content

v0.1.2: bundler-neutral XSD load (unblocks Vite/Rollup/Workers consumers)#8

Merged
terrxo merged 1 commit into
mainfrom
v0.1.2-bundler-neutral-xsd
May 25, 2026
Merged

v0.1.2: bundler-neutral XSD load (unblocks Vite/Rollup/Workers consumers)#8
terrxo merged 1 commit into
mainfrom
v0.1.2-bundler-neutral-xsd

Conversation

@terrxo

@terrxo terrxo commented May 25, 2026

Copy link
Copy Markdown
Contributor

Unblocks fiscalize-demo's deploy (and any Vite/Rollup/Workers consumer). The bun import … with { type: "text" } XSD load is bun-only — a consumer's vite build fails: "xmldsig-core-schema.xsd (1:0): Expression expected (need plugins to import non-JS)". Verified failing on 0.1.1, fixed here.

Fix: inline each XSD as a JS string (JSON-stringified, generated from the vendored .xsd by scripts/gen-xsd-modules.ts) and import those .ts modules — no text-import / ?raw / fs, loads under any bundler/runtime. Removed the now-dead *.xsd ambient + its triple-slash ref.

Verified:

  • bun test 44 pass / 1 skip, tsc clean — validateEslogXml still passes (inlined XSD byte-identical to the file).
  • A consumer SvelteKit vite build now succeeds (✓ built with the buildEInvoice route bundled; was failing on 0.1.1) — tested against this exact build.

Consumers on ^0.1.x auto-inherit; bump to ^0.1.2 to build. .xsd files kept for provenance; .ts are generated (regen via bun run scripts/gen-xsd-modules.ts).

🤖 Generated with Claude Code

…consumers)

The bun `import xsd from "./x.xsd" with { type: "text" }` is bun-only — Vite/
Rollup reject it ("Expression expected; need plugins to import non-JS"), so any
consumer bundling the e-SLOG validation path (e.g. fiscalize-demo's SvelteKit/
adapter-cloudflare vite build) failed.

Fix: inline each XSD as a JS string (JSON-stringified, generated from the
vendored .xsd by scripts/gen-xsd-modules.ts) and import those .ts modules. No
text-import / ?raw / fs — loads under any bundler/runtime. Removed the now-dead
`declare module "*.xsd"` ambient + its triple-slash ref.

Verified: validateEslogXml still passes (inlined XSD byte-identical, 44/1 tests,
tsc clean) AND a consumer SvelteKit `vite build` now succeeds (was failing on
0.1.1). Consumers on ^0.1.x auto-inherit; bump to ^0.1.2 to build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@terrxo terrxo merged commit cf06850 into main May 25, 2026
@terrxo terrxo deleted the v0.1.2-bundler-neutral-xsd branch May 25, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant