It seems like a strange set of tooling and I don't get to configure it how I like.
Why would I want to use Babel to compile server side code rather than just use the latest version of Node? It's actually doing two compilation steps because it's got TypeScript in there too, which is also a compiler. It uses Jest for testing, which is primarily designed for React.
I haven't found my preferred environment scaffolding yet. As I go I find better and better ways to set up my app and usually it's pretty app specific. If I did find a great scaffolding tool I think it would be one I have full control over. Maybe a lot more like Yeoman which has been around for quite a while.
You can do a lot even without scaffolding, just npm init and git init.
Jest isn't primarily designed for React. It has a lot of built in feature for making testing React components easier. But it's a generic Javascript test runner and framework
Yep - the main thing that Jest gives out of the box is jsdom, so allows for dom based testing without needing phantom (or more modern now, headless browser).
I also find it's faster and has better features than Mocha (for instance, coverage out of the box).
I use Babel and TS server side. TS for types, and Babel because the latest stable version of node does not always support the latest
Ecmascript features. Example from recent memory: Async generators (async function* yada(){} and for await of).
It doesn't do double compilation when using TypeScript, .ts goes goes to tsc and .js to Babel. It uses Babel so you can use ES6/7/8 on the server.
This is meant as a simplified project build tool, not for every use, but you can configure it quite extensively if you need to (although it has limitations). I would estimation that ~80% of projects could use this, and is less than 5 minutes of migration or 30 seconds to get started. It's not for the 20% of projects with very custom needs for build configuration.
You might be interested in Concatapult [1]. I built it to minimally cover server needs (first-time setup, env vars, testing) and optionally add tech as your project needs it (react, knex, typescript, etc).
Basically it's a lego-like version of yeoman, and opinionated towards simplicity.
I'm not really on board with using babel for a server-only project either, but I do like jest for testing and have in fact only used it for node app servers so far.
Just noticed the docs have a tutorial on creating a command line interface app[0]. Thanks for this. Would love to read the next steps involved in making the app accessible with with just `fibonacci`, as opposed to `npm start fibonacci`.
Check out something like pkg by zeit[0] which compiles the node app to a binary. Then put it in a directory in your $PATH and you'll be able to run it as `fibonacci`.
I’m interested in making binaries, to hopefully ease distributing in-house utils. Our various projects depend on misc node versions and reinstalling our utils to each new global bin ain’t fun. If there’s a better way, I’m all ears.
Please don't use this if the project is for work/something you care about, because it's a bitch to support in production, especially when compatibility becomes an issue. Better to not mention it at all in a work related context and just say there's no way to distribute nodeJS applications as binaries.
In a team environment npm or yarn configuration would go through peer review, whereas getting used to typing npx increases your chances of falling victim to a typo.
Is there something like this that is a template for server-side node apps? My experience with node has been small scripts and build configs but I would love to find a template to start with. Any recommendations are appreciated!
I created a mostly unopinionated starter project [1] for creating RESTful APIs using Koa2 and ES2017+ features in a Node.js server environment as well as providing linting and testing support. It provides the setup for compiling, linting and testing your code but doesn't make any further assumptions on how your project should be structured.
From what I understand, it installs a bunch of opinionated packages and then you're on your own. This isn't the same as "create a useful app in 30 seconds".
Yo is a scaffolder. At the end of the generation you are more or less on your own.
This is a full prepackaged config you can easily upgrade. The cost? Hard (if not impossible) customizations of underlying products config. Not a con IMHO.
Why would I want to use Babel to compile server side code rather than just use the latest version of Node? It's actually doing two compilation steps because it's got TypeScript in there too, which is also a compiler. It uses Jest for testing, which is primarily designed for React.
I haven't found my preferred environment scaffolding yet. As I go I find better and better ways to set up my app and usually it's pretty app specific. If I did find a great scaffolding tool I think it would be one I have full control over. Maybe a lot more like Yeoman which has been around for quite a while.
You can do a lot even without scaffolding, just npm init and git init.