Skip to content

Navigation Menu

Sign in
Sign up

Async Macros #31

Unanswered
jarrodpayne asked this question in Q&A
Discussion options

The Macro API doesn't appear to support async. I'm curious to know if there may be some interest in this functionality.

Simple example adapted from the docs

import { macaron$ } from '@macaron-css/core';
import { readFile } from 'fs/promises';
const files = macaron$(async () => await readFile('file.txt', 'utf8'));
You must be logged in to vote

Replies: 1 comment

Comment options

I filed this discussion before reading the source code. Based on my first glace, it appears this is a limitation of babel-plugin-macro. There are workarounds if this is something someone needs and macron isn't interested in taking this up.

My initial use case was to dynamically import code inside macaron$, but I may be able to rely on Vite's dead code elimination. Sync only APIs may be fine here, but I'll keep looking to this and report back if I find anything useful.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /