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

How to configure rollup watcher handlers? #2117

Closed
zerkalica opened this issue Apr 10, 2018 · 9 comments
Closed

How to configure rollup watcher handlers? #2117

zerkalica opened this issue Apr 10, 2018 · 9 comments
Milestone

Comments

@zerkalica
Copy link

I try to create rollup-plugin-notifier, like webpack-notifier. But i can't find any api to passing custom handler to watcher instance from rollup plugin or config.
May be add some api to plugins?

{
  onError(error) {
    nodeNotifier.notify(error)
  } 
}
@katywings
Copy link

Hey hey :)

Currently there isnt much API for this stuff.

Best option propably is: https://rollupjs.org/guide/en#rollup-watch

I created a notifier in one of my projects too using the rollup.watch and a websocket. That combination worked pretty okay-ish :D. (P.S. My solution isnt yet on github)

@guybedford
Copy link
Contributor

Are you saying that having these types of events on the plugin interface would be useful to what you're building here? This might be a direction we could consider.

@katywings
Copy link

I guess a minimal but flexible approach would be to have an onwatch option in the plugin config which only is called at rollup.watch and gets the watcher as parameter.

Something like"

var notPomodoroTimeConsideringRollupNotificationPlugin = function(pomodoroTimesToIgnore) {
  var fayeClient ....

  return {
    name: 'nPTCRNP',
    onwatch: (watcher) {
      watcher.on('event', () => {
        fayeClient.publish('/rollupMessages', {
          action: 'shutdownBrowserHost'
        }
      }
    }
  }
}

Or something like that I guess.

@guybedford
Copy link
Contributor

I think this could possibly be handled in plugins / config via a onwatch and onerror plugin hooks. I'm aiming to add onbuildstart and onbuildend hooks in #2126, so between those that might cover these use cases.

@zerkalica
Copy link
Author

Any changes? How to get watch instance in buildStart?

@guybedford
Copy link
Contributor

@zerkalica so you want access to watch events from a plugin? Perhaps we can just pass the watcher as an optional argument to buildStart then? Let me know if that sounds sensible.

@zerkalica
Copy link
Author

Yes, argument in buildStart sounds good.

@guybedford
Copy link
Contributor

@zerkalica sure, I've created #2261, let me know if that seems useful here.

@lukastaegert lukastaegert added this to the 1.0.0 milestone Jun 16, 2018
@lukastaegert lukastaegert added this to To do in Release 1.0.0 via automation Jun 16, 2018
@lukastaegert lukastaegert moved this from To do to Done in Release 1.0.0 Jun 16, 2018
@lukastaegert lukastaegert modified the milestones: 1.0.0, 0.61.0 Jun 20, 2018
@jonaseberle
Copy link

jonaseberle commented Mar 3, 2022

I am just leaving that here because one comes here when searching for "rollup notify"...

This outputs a "bell" character which most terminal emulators turn into a desktop notification:

# rollup.config.ts
export default {
  ...
  plugins: [
    new class implements OutputPlugin {
      name = 'bell';

      buildEnd(error?: Error) {
        // Jonas needs his "bell" for "watch"able build scripts
        console.log(String.fromCharCode(7))
      }
    },
    ...
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Release 1.0.0
  
Done
Development

No branches or pull requests

5 participants