Skip to content

fix(app): keep exported widget scripts separate - #105

Open
asasemahmed wants to merge 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/app-export-js-separator
Open

asasemahmed wants to merge 1 commit into
CopilotKit:mainfrom
asasemahmed:fix/app-export-js-separator

Conversation

@asasemahmed

Copy link
Copy Markdown

The standalone HTML export joins jsFunctions and every jsExpressions entry with "\n" into one script. The live sandbox runs each piece as its own script, so generated code often has no trailing semicolons. Once joined, automatic semicolon insertion merges the pieces, and an exported widget that worked live is dead after "Download" or "Copy". Two examples:

  • jsFunctions: "let count = 0" followed by the async IIFE becomes 0(async () => ...), which throws TypeError: 0 is not a function.
  • Expressions draw() and [1, 2].forEach(...) become draw()[1, 2].forEach(...).

The pieces are now joined with "\n;\n", so each stays its own statement.

Tests: export-utils.test.ts runs the exported script with semicolon-free pieces and checks that every expression ran.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant