HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
kentcdodds
babel-plugin-macros
JavaScript2018–2020
kentcdodds / babel-plugin-macros

babel-plugin-macros

🎣 Allows you to build simple compile-time libraries

4Distinct people
6Mentions
0Explicit recommenders
2.6KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

🎣 Allows you to build simple compile-time libraries

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:03:16 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by month6 dated mentions

Observed mentions: 2018-09-19 20:24:12 UTC to 2020-06-30 19:16:08 UTC.

012018-09-01 00:00:00 UTC to 2018-10-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsSep 20182018-10-01 00:00:00 UTC to 2018-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-11-01 00:00:00 UTC to 2018-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-12-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-01-01 00:00:00 UTC to 2019-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-02-01 00:00:00 UTC to 2019-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-03-01 00:00:00 UTC to 2019-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-04-01 00:00:00 UTC to 2019-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-05-01 00:00:00 UTC to 2019-06-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-06-01 00:00:00 UTC to 2019-07-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-07-01 00:00:00 UTC to 2019-08-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJul 20192019-08-01 00:00:00 UTC to 2019-09-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2019-09-01 00:00:00 UTC to 2019-10-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2019-10-01 00:00:00 UTC to 2019-11-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-11-01 00:00:00 UTC to 2019-12-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-12-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2020-02-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-02-01 00:00:00 UTC to 2020-03-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-03-01 00:00:00 UTC to 2020-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-04-01 00:00:00 UTC to 2020-05-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-05-01 00:00:00 UTC to 2020-06-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2020-06-01 00:00:00 UTC to 2020-07-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 commentsJun 2020

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Sep 20182018-09-01 00:00:00 UTC2018-10-01 00:00:00 UTC101
Oct 20182018-10-01 00:00:00 UTC2018-11-01 00:00:00 UTC000
Nov 20182018-11-01 00:00:00 UTC2018-12-01 00:00:00 UTC000
Dec 20182018-12-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
Jan 20192019-01-01 00:00:00 UTC2019-02-01 00:00:00 UTC000
Feb 20192019-02-01 00:00:00 UTC2019-03-01 00:00:00 UTC000
Mar 20192019-03-01 00:00:00 UTC2019-04-01 00:00:00 UTC000
Apr 20192019-04-01 00:00:00 UTC2019-05-01 00:00:00 UTC000
May 20192019-05-01 00:00:00 UTC2019-06-01 00:00:00 UTC000
Jun 20192019-06-01 00:00:00 UTC2019-07-01 00:00:00 UTC000
Jul 20192019-07-01 00:00:00 UTC2019-08-01 00:00:00 UTC101
Aug 20192019-08-01 00:00:00 UTC2019-09-01 00:00:00 UTC101
Sep 20192019-09-01 00:00:00 UTC2019-10-01 00:00:00 UTC101
Oct 20192019-10-01 00:00:00 UTC2019-11-01 00:00:00 UTC000
Nov 20192019-11-01 00:00:00 UTC2019-12-01 00:00:00 UTC000
Dec 20192019-12-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
Jan 20202020-01-01 00:00:00 UTC2020-02-01 00:00:00 UTC000
Feb 20202020-02-01 00:00:00 UTC2020-03-01 00:00:00 UTC000
Mar 20202020-03-01 00:00:00 UTC2020-04-01 00:00:00 UTC000
Apr 20202020-04-01 00:00:00 UTC2020-05-01 00:00:00 UTC000
May 20202020-05-01 00:00:00 UTC2020-06-01 00:00:00 UTC101
Jun 20202020-06-01 00:00:00 UTC2020-07-01 00:00:00 UTC101

What Hacker News says

6 sources
Haha, I have spent my fair share of time procrastinating over what a type-safe JSX alternative would look like for React. The most ergonomic solution (well, atleast for me) has been their old factory API upon which I layered a set of convenience utilities [1]. I have been trying it out in a hobby project and I find the reduction of className boilerplate, elimination of closing tags etc. quite productive. And unlike alternatives like react-pug etc. I don't have to compromise with type checking of attributes. I'll probably release it as a library after doing some performance evaluation and if needed, wrapping it in a babel-macro [2] that eliminates the runtime overhead. -- [1] Example in CodeSandbox: https://codesandbox.io/s/pedantic-shape-lq9q9?file=/src/reac... Code in github gist: https://gist.github.com/lorefnon/53377e4d6a6b13adbcfa155f
Read the rest
In Hyperapp – A tiny framework for building web interfaces
I do agree that sticking to TSC keeps things a lot simpler, and that should be the default setup. Pandora's box has been opened though. Majority of the JS community seem to have adopted Babel in their workflow. Even as I question it, I must admit it's pretty sweet to have a transpiler in the buid toolchain. It frees one from the browser/backward compatibility question, more or less, and opens up the language to be extensible - for better or worse. For example, Babel macros ¹ is an interesting concept, using the language to extend the language during compile time. To bring it back to the topic at hand (PgTyped, Typesafe SQL) - one thing that I'd like to see in TSC is a way to output type definitions (either inlined metadata or external JSON schema), to be consumed for run-time type checking. That would "complete the circle" for me. TypeScr
Read the rest
ipt "compiler plugins" seem to be on the roadmap, or at least under consideration ². Some may see that as opening a proverbial can of worms, down a similar road to Babel. I wouldn't disagree, but it'd be so useful! ¹ https://github.com/kentcdodds/babel-plugin-macros ² https://github.com/Microsoft/TypeScript/issues/16607
In Show HN: PgTyped – Typesafe SQL in TypeScript and Postgres
I got interested in Reason last year after reading lorefnon's article [1] comparing Reason with TypeScript. Recently, after evaluating both for a large project we decided to prefer TypeScript primarily because TypeScript's support for intersection types, mapped types and conditional types is really awesome and make integration with javascript libraries a lot easier. As far as I could find, similar things can't be done in ReasonML at all (although I could be wrong on it). The tooling integration of TypeScript is also really awesome. Besides the usual refactoring, jump to definition support etc. a lot of effort has gone into small things that makes life easier. For example, if you have ctrl+click on a mapped type's property it will jump to the original type being mapped. In libraries like io-ts if you add doc comments on methods which are u
Read the rest
sed to derive the types, the documentation will be propagated to the derived types [2]. I recently found that the author of the above post has been experimenting [3] with babel-macros [4] to facilitate nice type-safe fluent APIs/abstractions which are compiled away to simple readable javascript with zero/negligible runtime overhead and found it a really neat idea. Looking at some of that code, it appears to be a lot simpler than writing ppx macros [5] for ocaml which I very briefly experimented with. [1] https://lorefnon.tech/2018/05/13/reasonml-vs-typescript-firs... [2] https://github.com/gcanti/io-ts/issues/201#issuecomment-4347... [3] https://github.com/ts-delight [4] https://github.com/kentcdodds/babel-plugin-macros [5] http://ocamllabs.io/doc/ppx.html
In TypeScript vs. ReasonML
Yeah, this is something I had hoped for as well. Mobx-state-tree [1] also makes use of generators for asynchronous tasks and typescript's inability to infer types of values returned from a yield is a pain. But fortunately, atleast in this particular case the usage semantics are really close to async/await so I have had success using a babel macro [2][3] to transform async functions to generators which restores type-safety. This is of-course a hack but has proven to work fairly well in practice. [1] https://github.com/mobxjs/mobx-state-tree [2] https://github.com/kentcdodds/babel-plugin-macros [3] https://github.com/ts-delight/async-to-generator.macro
In TypeScript 3.6
I've only recently learned about Babel Plugin Macros and haven't used it in production - but here are a few links in case anyone's interested. https://babeljs.io/blog/2017/09/11/zero-config-with-babel-ma... https://github.com/kentcdodds/babel-plugin-macros https://github.com/jgierer12/awesome-babel-macros These "macros" take a different approach than Sweet.js: they're not syntax extensions, but rather code transformers that you import and use explicitly.
In Sweet.js – Hygienic Macros for JavaScript

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.