Fix unsafe Deno global access causing dnt WASM transformer panics #28
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.
Description
The dnt WASM transformer panics when statically analyzing direct
Deno.*property accesses, even within runtime-guarded conditionals. The error manifests asReflect.get called on non-objectatwasm/src/lib.rs:56:64.Type of Change
Changes Made
Replace direct
Deno.*accesses with dynamic property access viaglobalThisto bypass static analysis:Before:
After:
Files modified:
src/parser.ts-Deno.cwd()accesscli.ts- exit, readTextFile, writeTextFile, stat, argsruntime.ts- readTextFile, writeTextFile, writeFile, statTesting
deno task gensuccessfullydeno lint(noted any acceptable errors)deno check mod.tsdeno task build:npmcompletes without panicsArchitectural Decision Record (ADR)
docs/adr/docs/adr/README.mdIf ADR is required but not included, please explain why:
Tactical fix for WASM transformer limitation, not an architectural decision.
Documentation
Breaking Changes
None. Runtime behavior unchanged.
Related Issues
Fixes #issue_number
Additional Notes
The
isDenocheck pattern ("Deno" in globalThis) was already safe. The issue was that direct property access (Deno.*) triggered static analysis in dnt's WASM transformer, which callsReflect.getbefore runtime guards execute.Checklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.204/linux64/chrome-headless-shell-linux64.zipnode install.mjs(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.