Commit 0923863
fix(app): re-export storage + dom globals into the bundle's module scope
Bug surfaced in browser while running examples/03_interactive.py:
NameError: name 'store' is not defined — when @app.client.on("ready")
restore() runs in Pyodide.
Cause: the example imports `from violetear.storage import store` at
module level, then uses `store` inside the restore handler. The bundle
generator transpiles the function via inspect.getsource(), which keeps
the function body but drops the surrounding module-level imports. At
exec time, `store` is undefined in the bundle's globals.
Compile-time tests (compile(text, "<bundle>", "exec", flags=...)) pass
fine — the bundle is syntactically valid; it only fails when Pyodide
actually runs it. This is exactly the class of bug we need e2e browser
testing for; logged as issues/7.6.
Fix: emit `from violetear.storage import store, session` after the
storage module injection block, and `from violetear.dom import DOM,
DOMElement, Event` after the dom injection block. User code that
imported these names at module level now resolves cleanly without
having to lazy-import inside every function.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6e79486 commit 0923863
2 files changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
46 | 58 | | |
47 | 59 | | |
48 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
666 | 670 | | |
667 | 671 | | |
668 | 672 | | |
| |||
682 | 686 | | |
683 | 687 | | |
684 | 688 | | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
685 | 693 | | |
686 | 694 | | |
687 | 695 | | |
| |||
0 commit comments