Skip to content

fix(runframe): treat .cjs as a dynamic (source) file, not a static asset#3751

Draft
addibble wants to merge 1 commit into
tscircuit:mainfrom
addibble:fix/treat-cjs-files-as-dynamic
Draft

fix(runframe): treat .cjs as a dynamic (source) file, not a static asset#3751
addibble wants to merge 1 commit into
tscircuit:mainfrom
addibble:fix/treat-cjs-files-as-dynamic

Conversation

@addibble

Copy link
Copy Markdown

Problem

The store decides which uploaded files get their real text content vs. a "__STATIC_ASSET__" placeholder via isDynamicFilePath. Its DYNAMIC_FILE_EXTENSIONS lists .tsx/.ts/.jsx/.js/.mjs/.json (+ kicad) but omits .cjs. So a .cjs source file is treated as binary: its content is replaced with "__STATIC_ASSET__", and when eval then imports it as code the worker throws ReferenceError: __STATIC_ASSET__ is not defined.

This is the runframe-side twin of tscircuit/eval#2996 (which lets eval transpile .cjs); both are needed for .cjs deps to work in tsci dev. tsci build (Node) is unaffected — this only manifests in the browser/dev path.

Fix

Add ".cjs" to DYNAMIC_FILE_EXTENSIONS (next to .mjs), so runframe delivers its real source instead of a placeholder.

Test

Extends tests/runframe-dynamic-file-path.test.ts with a .cjs case.

Risk

Negligible — .cjs is source, not a binary asset; it belongs in the list.


Draft: opening for review before merge. (package.json is intentionally excluded — local yalc artifacts only.)

isDynamicFilePath decides which uploaded files get their real text content
vs. a "__STATIC_ASSET__" placeholder. DYNAMIC_FILE_EXTENSIONS listed
.tsx/.ts/.jsx/.js/.mjs/.json (+ kicad) but omitted .cjs, so a .cjs source
file was treated as a binary asset: its content was replaced with
"__STATIC_ASSET__", and when eval then imported it as code the worker threw
"ReferenceError: __STATIC_ASSET__ is not defined".

Add .cjs to DYNAMIC_FILE_EXTENSIONS and cover it in the existing test.
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
runframe Ready Ready Preview, Comment Jun 23, 2026 12:52am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant