Skip to content

v0.1.3: lazy-load @e-invoice-eu/core (engine importable on Cloudflare Workers)#9

Merged
terrxo merged 1 commit into
mainfrom
v0.1.3-lazy-einvoice
May 25, 2026
Merged

v0.1.3: lazy-load @e-invoice-eu/core (engine importable on Cloudflare Workers)#9
terrxo merged 1 commit into
mainfrom
v0.1.3-lazy-einvoice

Conversation

@terrxo

@terrxo terrxo commented May 25, 2026

Copy link
Copy Markdown
Contributor

Makes @grunt-it/fiscalize importable on Workers/workerd (unblocks fiscalize-demo's deploy). Verified failing on 0.1.2, fixed + verified here.

Problem: @e-invoice-eu/core is Node-only — its ESM eager-imports tmp-promisefs.realpathSync, unimplemented in CF nodejs_compat. So merely importing @grunt-it/fiscalize crashed a Worker at module-init.

Fix: dynamic-import its value-imports (InvoiceService, invoiceSchema) inside generateEInvoice (ubl/cii) + validateEn16931. Importing the engine is now Workers-safe; those two paths throw only if called on a non-Node runtime. e-SLOG generation + all FURS crypto are unaffected and Workers-safe.

Verified:

  • Node: bun test 44/1, tsc clean — lazy-load preserves behavior (UBL/validate still work).
  • workerd (wrangler dev): top-level import no longer crashes, generateEInvoice('eslog') works (was a module-init 500 on 0.1.2).

Adds docs/RUNTIME-COMPAT.md — the verified Workers-vs-Node matrix (Workers-safe: e-SLOG gen + FURS crypto incl. node-forge/node:crypto/X509; Node-only: @e-invoice-eu/core UBL+EN16931-validate + xmllint-wasm validateEslogXml).

🤖 Generated with Claude Code

…kers)

@e-invoice-eu/core is Node-only (module-init crash under Cloudflare Workers:
tmp-promise → fs.realpathSync, unimplemented in nodejs_compat). Until now, merely
importing @grunt-it/fiscalize crashed a Worker at load.

Now its value-imports (InvoiceService, invoiceSchema) are dynamic-imported inside
generateEInvoice (ubl/cii) + validateEn16931, so importing the engine is
Workers-safe; those two paths throw only-if-called on a non-Node runtime.
e-SLOG generation + all FURS crypto + (Node) UBL/validation unaffected.

Verified: 44/1 tests + tsc on Node (lazy-load preserves behavior); under local
workerd, top-level import no longer crashes and generateEInvoice('eslog') works.

Adds docs/RUNTIME-COMPAT.md (the verified Workers-vs-Node capability matrix):
Workers-safe = e-SLOG gen + FURS crypto; Node-only = @e-invoice-eu/core (UBL +
EN16931 validation) + xmllint-wasm (validateEslogXml, "Worker is not defined").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@terrxo terrxo merged commit 1701e99 into main May 25, 2026
@terrxo terrxo deleted the v0.1.3-lazy-einvoice branch May 25, 2026 06:58
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