Right now we sort of do this because the main widget doesn't actually contain p5--rather, the preview frame directly loads it over CDN, and the preview frame isn't created until the sketch starts playing.
However, we also mangle the code via esprima in the widget prior to running it, and that's a fairly big dependency. Possibilities:
Use Webpack code splitting to lazily load esprima and other such dependencies in the widget.
Build a separate Webpack bundle for the preview frame (done in #21), and move the code-mangling logic into the preview frame.
Another non-mutually-exclusive option is to switch to a different AST parser, such as acorn (not sure how its size compares to esprima, though).
Right now we sort of do this because the main widget doesn't actually contain p5--rather, the preview frame directly loads it over CDN, and the preview frame isn't created until the sketch starts playing.
However, we also mangle the code via esprima in the widget prior to running it, and that's a fairly big dependency. Possibilities:
Build a separate Webpack bundle for the preview frame(done in #21), and move the code-mangling logic into the preview frame.Another non-mutually-exclusive option is to switch to a different AST parser, such as acorn (not sure how its size compares to esprima, though).