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.

How to identify a macros

See original GitHub issue

Right now we identify a macros if the import/require source string matches this regex: /[./]macros(\.js)?$/

@gaearon mentioned:

The only thing I don’t quite like is the .macros naming, maybe we can come up with an alternative suffix.

@threepointone suggested:

The ideal solution would be to have separate syntax, e.g. importMacros, but that’s likely never going to happen Another option is to use a webpack inspired ‘babel-macros?css’, but that straight up looks alien Alternate words off the top of my head - mods, plugs, socks(?), defines

So then I said:

I want to make sure that existing tooling will work as much as I can so I want to avoid anything too weird looking… 🤔

I don’t mind macros myself, but happy to consider other names 👍

To which @gaearon replied:

The thing is, it also need to be explicit enough that you wouldn’t mistake it from a regular import. Because otherwise it’ll be a debugging nightmare for the person who doesn’t know what’s going on.

Then @suchipi suggested:

Flow has import type, and sweet.js uses import ... for syntax. Is adding a similar syntax extension to babylon going too far for something like this?

And finally I said:

I’d be fine with it if babylon supported it via a plugin, then people could just include a preset we make (and CRA could include it in its own config theoretically). I like:

import macros glam from 'glam.macros'

But I’m open to pretty much anything else.


So now that we’re all caught up, let’s discuss the options. Other people I’d love to get input from are: @hzoo, @loganfsmyth, and @jlongster 😄

Here are the options as I see them:

  1. babylon plugin for new syntax
  2. matching imports where the source matches a regex

Any other ideas?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
kentcdoddscommented, Jul 12, 2017

Yeah, I think that we should probably only have one (macro) and stick with that… Otherwise it will make things confusing.

1reaction
anikethsahacommented, Oct 5, 2019

I find it very unlikely that something like this would make it to the TC39 ever (I don’t even know how that’d work) because it’s a compile-time thing

I guess the ecosystem need something named CT39 - Compile-Time 39 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use this weight loss calculator to count your to macros, lose fat
How to calculate your macros using WH's macro calculator · Step 1. Work out your Basal Metabolic Rate (BMR) · Step 2. Decide...
Read more >
How to Count Macros: A Step-by-Step Guide - Trifecta
To find the macro ratio percentage for each, you simply divide each calorie amount by total calories (90) and then multiply by 100....
Read more >
What Are Macros And Why Should I Be Counting Them?
First and foremost, knowing what you're counting is super important, right? Well, “macro” is short for macronutrient. What's a macronutrient? They're the three ......
Read more >
Macros or VBA code found - Microsoft Support
Here's how you can find macros and VBA modules in your document: In Word or Excel, click View > Macro > View Macros....
Read more >
The Formula to Calculate Your Macros and REE Accurately
Step 2: TDEE Formula · 10 x weight (kg) + 6.25 x height (cm) – 5 x age (y) + 5 = REE...
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