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
Summary
Investigated whether @accordproject/template-engine and cicero-core
can run inside the playground's Vite browser build.
Build: PASSES ✅
npm run buildcompletes 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.jsimports Node'szlibmodule and useszlib.constants.Z_SYNC_FLUSHfor HTTP decompression. In a browserbuild,
zlib.constantsis 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 }tofromArchive()to skip external modelfetching 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 ofhttp.js.Next steps
fromArchive(buffer, { offline: true })JavaScriptEvaluator.evalDangerouslyseparately