Skip to content

Bug: browser compatibility of @accordproject/template-engine with Vite #852

@Satvik77777

Description

@Satvik77777

Summary

Investigated whether @accordproject/template-engine and cicero-core
can run inside the playground's Vite browser build.

Build: PASSES ✅

npm run build completes successfully with both packages imported.
No blocking errors at bundle time.

Runtime: FAILS ❌

Browser console shows:

Uncaught TypeError: Cannot read properties of undefined (reading 'Z_SYNC_FLUSH')
at axios → httparchiveloader → templateloader → template

Root cause (confirmed via grep)

axios/lib/adapters/http.js imports Node's zlib module and uses
zlib.constants.Z_SYNC_FLUSH for HTTP decompression. In a browser
build, zlib.constants is undefined, causing the crash.

This is triggered when cicero-core's archive loader uses axios to
fetch external models from models.accordproject.org.

Proposed fix

Pass { offline: true } to fromArchive() to skip external model
fetching entirely. This avoids the axios/zlib path and relies only
on JSZip for archive decompression, which is browser-compatible.

Alternatively, a Vite alias can force axios to use its browser
adapter (xhr.js) instead of http.js.

Next steps

  • Test fromArchive(buffer, { offline: true })
  • Verify JavaScriptEvaluator.evalDangerously separately
  • Open draft PR with ExecutionService skeleton

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions