Conversation
Co-authored-by: leizongmin <leizongmin@gmail.com>
There was a problem hiding this comment.
Bug: ES Module Loader Malforms Exported Functions
The enhanced ES module loader's transformation for export function statements generates invalid JavaScript syntax. The regex replacement incorrectly modifies the function signature, resulting in malformed code like const temp_func = function name(; exportNamed("name", temp_func); function name( which causes runtime syntax errors. Additionally, the conditional check for applying this transformation is unreliable, potentially preventing correct function export due to false positives if the function name appears elsewhere in the content.
example/es-modules/enhanced-es-module.js#L78-L88
jssh/example/es-modules/enhanced-es-module.js
Lines 78 to 88 in 9203173
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
Co-authored-by: leizongmin <leizongmin@gmail.com>
Implement top-level await support for ES modules in jssh.
This feature allows the
awaitkeyword to be used directly at the top level of ES modules (.mjsfiles), enabling asynchronous initialization and data fetching without wrapping code in anasyncfunction. The implementation involves detecting top-levelawaitusage, transforming ES module export syntax, and wrapping the module's code in an asynchronous IIFE for execution.