fix(runframe): treat .cjs as a dynamic (source) file, not a static asset#3751
Draft
addibble wants to merge 1 commit into
Draft
fix(runframe): treat .cjs as a dynamic (source) file, not a static asset#3751addibble wants to merge 1 commit into
addibble wants to merge 1 commit into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The store decides which uploaded files get their real text content vs. a
"__STATIC_ASSET__"placeholder viaisDynamicFilePath. ItsDYNAMIC_FILE_EXTENSIONSlists.tsx/.ts/.jsx/.js/.mjs/.json(+ kicad) but omits.cjs. So a.cjssource file is treated as binary: its content is replaced with"__STATIC_ASSET__", and when eval then imports it as code the worker throwsReferenceError: __STATIC_ASSET__ is not defined.This is the runframe-side twin of tscircuit/eval#2996 (which lets eval transpile
.cjs); both are needed for.cjsdeps to work intsci dev.tsci build(Node) is unaffected — this only manifests in the browser/dev path.Fix
Add
".cjs"toDYNAMIC_FILE_EXTENSIONS(next to.mjs), so runframe delivers its real source instead of a placeholder.Test
Extends
tests/runframe-dynamic-file-path.test.tswith a.cjscase.Risk
Negligible —
.cjsis source, not a binary asset; it belongs in the list.Draft: opening for review before merge. (
package.jsonis intentionally excluded — local yalc artifacts only.)