When creating a custom bundle using combineModules, p5 fails to instantiate with the error:
p5 is not a constructor
Steps to reproduce this:
npm run grunt combineModules:core/shape:color:math:image
Use the following for sketch.js in emptyExample
const s = ( sketch ) => {
let x = 100;
let y = 100;
sketch.setup = () => {
sketch.createCanvas(200, 200);
};
sketch.draw = () => {
sketch.background(0);
sketch.fill(255);
sketch.rect(x,y,50,50);
};
};
let myp5 = new p5(s);
Results in error p5 is not a constructor
@outofambit any idea why this happens? I assume there are steps in the regular build process that are not included in combineModules. Is this a correct assumption?
@hsab It may be the browserify step not exposing a p5 global on the combine module step
@hsab @limzykenneth yep that's my theory too. i think there also might be an error that happens if the final export of p5 from the bundle doesn't use the old school way of exporting. (i think it confuses browserify somehow?)
i believe that's why app.js uses this:
https://github.com/processing/p5.js/blob/5df69d9ebdd58eedff35deb472c0d0b13d1a7051/src/app.js#L87
ah yes, that's what @hsab figured out in https://github.com/processing/p5.js/issues/3758#issuecomment-496858975!
@sakshamsaxena thanks for following up on this.
Most helpful comment
@sakshamsaxena thanks for following up on this.