Front-End Engineer Career, Learning to Code – the interview with Matt Williams (HTBT)

I was interviewed by Matt Williams on the How to Build a Tent show and podcast; watch the video!

In the interview, we discuss how I began my front-end engineer career, how I learned to code, how you can learn to code, and more. Opinions expressed are my own and do not represent my employer.

Referenced Resources

First Things First

“Do first things first, and second things not at all.”  – Peter Drucker

I love this quote. It’s about prioritization and deciding what to focus on in your life, in your work, with your time.

If you don’t know your mission and your vision, you won’t know what goals to set.  If you don’t know your goals, you won’t have a list of goals to prioritize.  If you don’t prioritize the list, you won’t know the most important thing to focus on right now.  If you don’t know what’s most important for you to focus on and get done now, you will not reach your goals, fulfill your vision, and complete your mission.

Clearly, I haven’t prioritized blogging, or you’d see more from me here.  I’ve been focused on growing in my career and at my work.  And that’s okay — it’s a conscious trade-off I’ve made.  And I’ve been focused on my life, dealing with the day to day elements of living, the grimy problems that come up that require the same sort of thought and juggling and prioritization.  Now I have to put down this laptop and go help assemble a side table because that’s my current “first thing”. 

Babel 7 dynamic config – making Babel work with esm, Jest, JSX, and Preact server-side rendering

Babel enables use of modern JS code (ES2015 — ES2018) in browsers and environments that don’t inherently support it using a technique known as transpiling. One of the features I enjoy about Babel 7 (currently at beta 46) is the ability to provide a dynamic .babelrc.js configuration file rather than a statically defined .babelrc (JSON) file.

I recently adopted esm (for ES Modules support in Node.js; import and export) on the Verses for Life website.  One of the challenges I ran into with using esm was getting my server to use esm by default for development and production work, but still having my tests work.  (For general esm setup, see esm on npm.)

I’d already decided in the past to use Jest, but, unfortunately, Jest doesn’t play nicely with esm by default and Jest doesn’t support a --require flag like many other JS testing libraries.  So what to do?

The solution is allowing Jest to use Babel to transpile the modules during testing (so you avoid those pesky “unexpected token import” errors), but keeping esm in place for all your other dev and production work.

I set up my Babel 7 config (.babelrc.js) to use Babel to handle modules only in test mode, but esm does the work everywhere else.

.babelrc.js code

This approach enabled my tests to work again.  The downside of this approach is that the way modules are loaded in testing doesn’t match my other environments.  You’ll want to ensure you have appropriate integration tests (a la Puppeteer) to ensure your site works end-to-end.

If you’re early on in deciding your tooling, you can look at the list of the many other test libraries supported by esmand maybe you won’t need this work-around.