4 ms·
A few years ago when I was trying to understand the new JavaScript world with React and all its toys (moving from my background of PHP and other 'old-school' se
by Winsaucerer 4y ago
A few years ago when I was trying to understand the new JavaScript world with React and all its toys (moving from my background of PHP and other 'old-school' server-side rendered solutions), I hit problems similar to this.
This particular example isn't too bad -- looking at that line, it would be clear to me that I'm missing 'npm', and the solution is obvious -- find out what npm is, and get it installed. But the things that really bit me were tons of examples of JavaScript, which included strange lines like 'import', and I had no idea how to get my website's JavaScript to understand what an import is or any of the other syntax. Nothing would work! I didn't realise there was a whole ecosystem around how to build your code so that it can make use of these things. Every guide assumed I had things going, and I just didn't understand that I needed this other infrastructure in place first before I could do anything.
- rablackburn 4y agoI’d recommend reading this[1] (fantastic) article that came out a few years ago. It’s exactly the kind of guide you’re looking for. [1] https://peterxjang.com/blog/modern-javascript-explained-for-dinosaurs.html https://peterxjang.com/blog/modern-javascript-explained-for-... Some notes of things that have changed in the last five years: - bundling is (almost) no longer needed for simple import/export as we now have a native module capability (esmodules). The biggest issue you’re likely to have here is waiting for any dependencies you have to upgrade from common js to esmodules. - transpiling is not as necessary unless you explicitly have to support IE11, or require something in the latest ecmascript spec. It really speaks to the maturation of front-end development that after five years that article is still fairly accurate. About time too - I’m too old to put up with that level of churn anymore.