chore: replace yazl with fflate#148
Conversation
jsteinich
left a comment
There was a problem hiding this comment.
I do like the simplifications made, but I am a bit concerned with using fflate. It hasn't been updated in 2 years which isn't necessarily a deal breaker; however, there are some reported potential compatibility issues with Node 22 and TypeScript 5.9.
Owner is responding to discussion - 101arrowz/fflate#248 (reply in thread) The Node v22 discussion - 101arrowz/fflate#227
The metamask project added the workaround, but then replaced But they used
I think we can conclude that Nodev22 should work (they had the workaround in place Dec 2024 -> Apr 2026) |
|
There is also 101arrowz/fflate#242 which could be a concern |
I don't have any concerns that weren't already raised in this discussion. I viewed #95 as a short-term solution to the lodash CVE (a lateral change), with an understanding there was already a desire for longer-term improvements. It's ok with me if my short-term solution is very short-term. |
Description
The
archiveSyncfunction inpackages/cdktn/lib/private/fs.tsruns fromTerraformAsset._onSynthesize, which executes inside the synchronous constructs synth lifecycle, so it has to block until the zip is on disk. yazl only exposes a streaming API, so the previous implementation worked around this by re-invoking the current module file as a child Node process viaexecSync(node ${__filename} ...). That hack relies on__filenamealways resolving to a CommonJS-loadable JS file — an assumption that breaks the moment ts-jest (or anything else) causes__filenameto point at a.tssource. Node's strip-types loader applies ESM resolution to such files and rejects the extensionless relative importfrom "../errors".fflate ships a real synchronous zip API (
zipSync) and, for the test rig's HTTP-streaming use case, a streamingZip/ZipDeflatepair. Swapping yazl for fflate lets us delete the child-process bridge entirely and the whole class of layout-fragility bugs that come with it.archiveSyncrewritten onfflate.zipSync— ~15 lines, no subprocess, no__filenamedependency, no inline runner script.test/template-server.tsmigrated tofflate.Zip+ZipDeflate; chunk-by-chunk streaming to the HTTP response is preserved.yazl+@types/yazlremoved frompackages/cdktnandtest;fflateadded to both. Rootnohoistupdated sofflatelands insidepackages/cdktn/node_modules/forbundledDependencies.Checklist