mattdesl / canvas-sketch

[beta] A framework for making generative artwork in JavaScript and the browser.
MIT License
4.97k stars 393 forks source link

build fails when using Two.js (0.8.10) template #158

Open cdaein opened 2 years ago

cdaein commented 2 years ago

I will have to ping you again 🙏 - @jonobr1

This also might be related to the 0.8.x update as the sketch builds fine with 0.7.x.

Reproducing the problem:

create a sketch with Two.js v.0.8.10 template:

canvas-sketch sketch.js --new --open --template=two

build the sketch:

canvas-sketch sketch.js --dir build --build 

gets an error on CLI:

  → Building...  

SyntaxError: Unexpected token: operator (=)
At line 2333 and column 12 of generated bundle
  ...
  2331:   // src/events.js
  2332:   var Events = class {
  2333:     _events = {};
                   ^
  2334:     _bound = false;
  2335:     constructor() {
  ...
jonobr1 commented 2 years ago

This has to do with the build configuration. It doesn't support ES6 definitions. I'm away from the computer today, but I'll take a look and try to commit a PR for this.

jonobr1 commented 2 years ago

Perhaps if the microbundler package is updated to the latest this would be fixed. More soon.

jonobr1 commented 2 years ago

An alternative is to re-target Two.js export with ES5 compatibility so that public field declarations aren't defined that way.