v0.1.3: lazy-load @e-invoice-eu/core (engine importable on Cloudflare Workers)#9
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
@grunt-it/fiscalizeimportable on Workers/workerd (unblocks fiscalize-demo's deploy). Verified failing on 0.1.2, fixed + verified here.Problem:
@e-invoice-eu/coreis Node-only — its ESM eager-importstmp-promise→fs.realpathSync, unimplemented in CFnodejs_compat. So merely importing@grunt-it/fiscalizecrashed a Worker at module-init.Fix: dynamic-import its value-imports (
InvoiceService,invoiceSchema) insidegenerateEInvoice(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:
bun test44/1,tscclean — lazy-load preserves behavior (UBL/validate still work).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/coreUBL+EN16931-validate +xmllint-wasmvalidateEslogXml).🤖 Generated with Claude Code