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

feat: add support for @sheepdog-transform comment #209

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

paoloricciuti
Copy link
Collaborator

Just had an awesome idea on lunch and couldn't restrain myself from implementing it. With this change users will have the ability to annotate a function so that it can be converted by the async transform. This means that even if they don't want to write the task inline for some reason they can just do

/**
 * @sheepdog-transform
 */
export async function task_fn() {
    await Promise.resolve();
}

and the vite plugin will convert this into

/**
 * @sheepdog-transform
 */
export async function* task_fn() {
    yield Promise.resolve();
}

I had to change some test because now we are keeping comments but that's it. WDYT about this feature? If we are ok with it i'll add this to the documentation.

@paoloricciuti paoloricciuti added the enhancement New feature or request label Oct 18, 2024
Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for sheepdog ready!

Name Link
🔨 Latest commit 2c5e729
🔍 Latest deploy log https://app.netlify.com/sites/sheepdog/deploys/6712e80338630700081c55d7
😎 Deploy Preview https://deploy-preview-209--sheepdog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@marcoow
Copy link
Member

marcoow commented Oct 18, 2024

would a decorator not be better than a magic comment?

@paoloricciuti
Copy link
Collaborator Author

would a decorator not be better than a magic comment?

Decorators are only available for classes tho, you need to import them and this is actually not something we do at runtime but at build time so if we use the decorator would actually just be an "identity decorator" that just returns the function as is

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

Successfully merging this pull request may close these issues.

2 participants