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

Async plugins #260

Closed
TrySound opened this issue Nov 2, 2015 · 2 comments · Fixed by #263
Closed

Async plugins #260

TrySound opened this issue Nov 2, 2015 · 2 comments · Fixed by #263

Comments

@TrySound
Copy link
Member

TrySound commented Nov 2, 2015

Is there a way to use asynchronous in plugins? rollup could detect promise returned from plugin like

export default function string (opts) {
    return {
        transform (code, id) {
            if (filter(id)) {
                if (opts.someAsyncOpt) {
                    return new Promise(function (code) {
                        resolve(code);
                    });
                }
                return code;
            }
        }
    };
}
@TrySound TrySound changed the title Async transformations Async plugins Nov 2, 2015
@Rich-Harris
Copy link
Contributor

It could be done, certainly. There's a slight performance penalty associated with async-ifying transforms since you basically need to wrap everything in a Promise.resolve() – do you have a specific use case in mind?

@TrySound
Copy link
Member Author

TrySound commented Nov 2, 2015

@Rich-Harris https://github.com/JohnPostlethwait/stringify accepts minificators for code. It make sense in browser. But minificators api can be async (cssnano is async)

Victorystick added a commit that referenced this issue Nov 3, 2015
support async transformers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants