-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move away from browserify? #3425
Comments
What would be the benefit of moving from browserify to webpack or rollup? What would be the drawbacks, if any? |
Disclaimer: I am a One weak(ish) reason to switch to I just low-key want to help P5 get better ES6/"Instance" support since ES6 actually made me "okay" with JS. So mainly +1 to bringing |
with webpack, how easy is it to run custom build steps? for example, something like the grunt task defined in BTW: there's an example of a babelified, ES6 version of p5 over here: #3394. still uses grunt, but hey. |
If there isn't a strong benefit to switch build tool then the effort may not be worth the reward so that's why I'm asking. Out of curiosity, because I haven't have a project that uses webpack or rollup but I want to try, how do they integrate with test runner like mocha or linters like eslint? Do they run with plugins on top or are they completely seperate, ie run with two shell commands (or one npm script with something like |
Tests all depends on the test suite, but with mocha there's a plugin or you can use a script as you described.
"easy" is a hard word to nail down. 😁 It's done by building a plugin and referencing that plugin in your set of build rules. See eslint-loader as an example, and how to build a plugin on webpack's wiki. I will disclaim that I've never built in a custom build step. So YMMV. |
@Spongman webpack wouldn't replace all of the scripts in the build folder, it would mostly replace
@limzykenneth I agree with @bigmstone, I think the main benefit is that these tools are have a larger ecosystem. They would also be easier to integrate with tools like babel, which may be useful with some of the es6ing coming up. There are also some parts of our build process that would be simplified. Right now we use derequire as an additional build step after browserify, which wouldn't be required by a rollup or webpack setup. There are also rollup plugins for minifying that would remove the uglify grunt task entirely. I think the main drawback of webpack is that the learning curve is a bit steep and configuration can be challenging. Rollup and Parcel (which I forgot to mention earlier) have significantly less configuration (mostly because they have sensible defaults) and are much more approachable. |
When I was looking through the dependencies to find obsolete ones On another note, I've seen Babel being thrown around in these discussion, and maybe I'm not familiar with some aspect of it, what I don't understand is why do we need it? Most of the biggest ES6 features are already supported by all major browsers for several years and so well covered by our compatibility targets (discounting IE 😞 😠 ) so I assume the aim is not to transpile to ES5? Then if I'm not missing anything else Babel will then be used to transpile features not yet widely implemented by browsers to something current browsers can run, in this case I would be more wary. I see the source code of p5.js as a learning resource for everyone including beginners as well but if we include code that doesn't run in the user's environment out of the box when they copied it, it becomes a source of confusion and another barrier to entry because now they need to know about Babel before continuing. |
There are commonly used features that haven't been fully standardized yet. Field declarations being one. Now that the industry seems to have centered around
I can see your point, but we can all admit javascript has historically been fractured. Take your pick: dependency management, build tooling, framework flavor of the week (I'm looking at you jquery, angular, react, vue), browser support circus. So I can appreciate what the popularity of Rereading that comment I think you might not be talking about beginners working on the library (which 1. would likely not be realistic and 2. babel would be "abstract" from them by the build process), but rather consumption of the library. My assumption with ES6+ support w/ |
I don't currently have a strong opinion here, I need to do some more research into the different options before I can weigh in more substantively. But I'm excited about exploring possibilities for improving the build system. One note @bigmstone, it is indeed a goal that beginner programmers find the p5.js ecosystem friendly enough to make contributions. This is different than a lot of software projects, and requires us to make certain decisions privileging readability over software extreme heavy lifting. We try to find a balance. (Sidenote: this makes me realize that the list of goals we hashed out in a meeting last spring never made it to the github, so I need to work on getting this up there! Currently, there's not any way to know the extent to which we aim to make this beginner accessible.) |
I can appreciate that and I can see both sides. On one hand it might be worthwhile being opinionated on some tooling. I find newcomers to JS get overwhelmed by all the options and are unsure where to start. So they read an article from a few years ago and are convinced |
There's a lot of other things we could have babel do, but I think the strongest case for babel in p5js is to ensure backward compatibility with older browser versions (or ones that are the minority in not supporting an ES syntax/feature) using babel-preset-env. Supporting a range of browsers is much easier with babel-preset-env. When added to your build process, it will polyfill and transpile your javascript to work on the browser versions listed in a configuration file (which we maintain as part of our repo). It's super cool and would allow us to embrace whatever features of es6+ we find appropriate without limiting the library's (browser) reach. On the topic of build processes and readability: I did a quick proof of concept in #3429 to explore what using (Also, the promise chain at the end is a little wonky. That could be cleaned up with async/await but I don't think grunt supports promises, so we could just separate the |
One key benefit of |
@hydrosquall Pacel also has tree shaking support albeit experimental still, and Parcel also caches builds so according to them provides even faster builds, not sure how it compares for us though. |
I've too have been trying to reduce the size of p5 as much as possible for a single sketch which uses very few of the features in p5 and am limited by the current build process. I'm also having a separate issue using p5 and Gatsby together. I've tried various workarounds as part of the debug process but no such luck in my case… @Aendrew has also mentioned this in #2244 and #2503—with additional general discussion in #522. It seems using rollup, webpack, or parcel would help. I thought maybe if I tried The current grunt task for combineModules doesn't also create a p5Custom.min.js using uglify like the normal grunt build task. 😉 |
@coreygo have you tried this? p5.js developer docs: creating a custom build of p5.js with select components |
@lmccart yep… 😃
|
hey all, #3431 is ready for review as a first step to simplifying the build process with |
As discussed in #3431, we've explored the options and unfortunately none of them provide what we need right now. parcel seemed like the best fit, but because of transpiling limitations it doesn't suit our purposes. I'm closing this for organization, we can revisit in the future as the state of the web evolves :) Thanks all for the discussion and @outofambit for investigating the parcel solution and other alternatives. |
While working on #3385, (and from discussions in #3409) I can't help but wonder if this project would be better served by a babel + webpack build process over the current browserify + uglify infrastructure.
I think we can replicate the existing behavior with babel, using babel-preset-env and babel-minify, and webpack to do the bundling.
We might also be able to use something as simple as rollup, though I am less familiar with that tool.
What do y'all think on a migration like this? Are there other tools worth considering?
The text was updated successfully, but these errors were encountered: