Skip to content

Feature request: expose errors to plugins #481

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

Closed
tiye opened this issue May 17, 2016 · 5 comments
Closed

Feature request: expose errors to plugins #481

tiye opened this issue May 17, 2016 · 5 comments

Comments

@tiye
Copy link
Contributor

tiye commented May 17, 2016

By now errors in Webpack is handled like this, an error message:

        errors: function(errors) {
            status.text("App updated with errors. No reload!");
            okness.text("Errors while compiling.");
            $errors.text("\n" + stripAnsi(errors.join("\n\n\n")) + "\n\n");
            header.css({borderColor: "#ebcb8b"});
            $errors.show(); iframe.hide();
        },

If that code is exposed then we may get error messages like this with plugins, and it can be quite convenient, as it already was in ClojureScript projects.


update:

I made a prototype https://github.com/mvc-works/webpack-hud

@SpaceK33z
Copy link
Member

SpaceK33z commented Aug 22, 2016

Did you look at #542? It has a nice example of how to listen to socket changes. Bit hacky, but it works.

That's probably only a temporary solution though. Any feedback on how you want this exposed would be helpful.

SpaceK33z added a commit that referenced this issue Nov 5, 2016
This allows plugins to act upon events (e.g. show a splash page when compiling)

Ref #481, #686
@SpaceK33z
Copy link
Member

SpaceK33z commented Nov 5, 2016

I exposed some events to the window now with 06c7773. An example of how to use it:

window.addEventListener('message', function onWebpackMessage (msg) {
    if (!msg.data || !msg.data.type) return;
    switch(msg.data.type) {
        case 'webpackOk':
            console.log('bundle compiled ok');
            break;
        case 'webpackErrors':
            console.log('There were some errors', msg.data.data);
            break;
    }
}, false);

Let me know if you have any feedback. It's not released yet.

@tiye
Copy link
Contributor Author

tiye commented Nov 7, 2016

Looks good to me https://github.com/mvc-works/webpack-hud/tree/with-new-api

Still want to ask if I can get the stripped string, since in the browser people are unlikely to need ANSI escape code. Then I should not need to strip by myself:

const errorMsg = webpackMsg.data.map((s) => stripAnsi(s)).join('\n');

@SpaceK33z
Copy link
Member

Sure, can you make a PR for that? Busy atm.

@SpaceK33z
Copy link
Member

Closing this since the feature has been implemented. Let me know if you don't like the API or want to make some changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants