Imagine you’re a writer, and when your muse visits, you have to hunt down a large bird, pluck a feather, sharpen the quill, mix your ink, and so on (you get the point) before you can put your first word to paper.
Or you’re a painter, and whenever inspiration strikes, you have to stretch a new canvas before you can apply your first stroke.
How did this happen?
In a recent conversation in Postlight Slack, Kevin Barrett sums up the problem I’m getting at:
I was looking at
- Support for ES2015 features (and beyond), more often than not transpiled via Babel, compiled via Webpack or maybe Rollup.
- Testing, with Jest as the testing framework du jour (oh and don’t forget, you need to make sure you also set up Jest to respect your Babel config).
- Linting, with ESLint. (You have your
.eslintrcready to go, right?)
If you wanted to cut it down to the bare minimum (not recommended), you can get rid of testing and linting. Now you’re left with setting up Babel and your build tool (let’s say Webpack). So you choose a Babel preset (
stage 0 if you’re feeling lazy), add any plugins you might need (you’ll need to do a lot more of this if you didn’t choose
stage 0), and set up your build tool.
This alone would take most seasoned developers the better part of an hour if they were starting from scratch; for people new to the ecosystem, the tooling step is intensely intimidating.
Now let’s say you only have five minutes and you just want to write some code.
I have a base
package.jsonI copy paste around, but more often I use one of the base boilerplate thingies. I tend to trust other people on the internet instead of my own old man memory.
I’m 100% with Drew on this. If, for example, I want to start writing anything targeted at the browser, I’ll use
create-react-app, a tool from Facebook that scaffolds boilerplate setup for a modern React app. I’ll use
src folder shouldn’t have to change at all.
yarn/npm start, and you’re off to the races.
I hear you, there in the back: But if your code relies on Webpack, you should know how it works. I get it. But here’s my counterpoint: I’ve written plenty of Webpack configs from scratch. Any time I’m not copying and pasting from a previous config I’ve written, it’s as though I’m learning Webpack again for the first time. Maybe I’m a bad programmer; or maybe Webpack isn’t my code, and when it’s necessary to change it, I’ll figure it out.
So What Do You Do?