question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC - babel-macros

See original GitHub issue

Code modifiers are becoming popular in the javascript ecosystem, via babel-plugins (eg - many css-in-js libs, relay, etc). This issue is to open discussion on a generic system to include them in CRA apps, but still honouring the zero-config philosophy.

The proposal here is to have a constrained form of babel-plugins, disguised to appear like regular libraries. A short writeup on what it would look like here - https://github.com/threepointone/babel-macros/blob/master/README.md

  • modifiers/‘macros’ would be isolated in files with .macros.js suffixes
  • there would no real trace of them in the final bundle stripping imports of all *.macros.js
  • considering they’re localised and used on demand, I expect them to have little effect on build performance, so can be enabled in both dev/prod
  • because there’s no dependence on webpack, it should still work with other js tooling like jest, etc.

I’m looking for feedback on the same before I start writing code for it, as well as possible first implementations (maybe a simple css-in-js lib?)

If this doesn’t belong here, feel free to close the issue. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:95
  • Comments:62 (34 by maintainers)

github_iconTop GitHub Comments

32reactions
kentcdoddscommented, Sep 8, 2017

Ok, so, check this out:

unmaintained-react-scripts-babel-macros diff:

screen shot 2017-09-08 at 10 36 23 am

(this would be implemented as part of babel-preset-react-app if it becomes official)

App.js

screen shot 2017-09-08 at 10 36 58 am

npm test

screen shot 2017-09-08 at 10 38 36 am

npm start

screen shot 2017-09-08 at 10 34 54 am

So that’s pretty rock solid awesome… 😄

25reactions
mxstbrcommented, Oct 21, 2017

We’re pretty close to merging a babel-macro-mode for styled-components. (https://github.com/styled-components/styled-components/pull/1256; import styled from 'styled-components/macro')

Would be awesome to be able to use that in create-react-app ootb to get nicer class names and proper minification just like that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kent C. Dodds on Twitter: "If you're curious what babel-macros ...
If you're curious what babel-macros is, check this thread out: github.com. RFC - babel-macros · Issue #2730 · facebook/create-react-app.
Read more >
RFC 8967: MAC Authentication for the Babel Routing Protocol
RFC 8967. MAC Authentication for the Babel Routing Protocol. Abstract. This document describes a cryptographic authentication mechanism for the Babel ...
Read more >
Zero-config code transformation with babel-plugin-macros
Babel started out as a transpiler to let you write the latest version of the ECMAScript specification but ship to environments that don't ......
Read more >
@lingui/macro | Yarn - Package Manager
Babel Macros which transforms tagged template literals and JSX components to ICU MessageFormat. @lingui/macro is part of LinguiJS. See the documentation for ...
Read more >
sku - npm
... like use a package that requires adding a Babel plugin, try Babel Macros. ... issue and follow the provided RFC template in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found