Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for calling other macros as shown in the Bun example #48

Open
3 tasks done
herkulano opened this issue Nov 23, 2024 · 1 comment
Open
3 tasks done

Support for calling other macros as shown in the Bun example #48

herkulano opened this issue Nov 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@herkulano
Copy link

herkulano commented Nov 23, 2024

Clear and concise description of the problem

Currently the Bun example doesn't work, arguments can only be literal strings, objects and arrays in unplugin-macros.

import {getText} from './getText.ts' with { type: 'macro' };
import {getFoo} from './getFoo.ts' with { type: 'macro' };

export function howLong() {
  // this works because getFoo() is statically known
  const foo = getFoo();
  const text = getText(`https://example.com/${foo}`);
  console.log("The page is", text.length, "characters long");
}

Suggested solution

Support macro functions as arguments. Not sure if the implementation of #12 would solve this.

Alternative

No response

Additional context

No response

Validations

@herkulano herkulano added the enhancement New feature or request label Nov 23, 2024
@sxzz
Copy link
Member

sxzz commented Nov 23, 2024

#12 should fix this, but I haven't found a good solution for this feature.

Update: WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants