Skip to content

Emit watch changes as a plugin hook - #2405

Merged
lukastaegert merged 3 commits into
masterfrom
watch-events
Aug 21, 2018
Merged

lukastaegert merged 3 commits into
masterfrom
watch-events

Conversation

@guybedford

Copy link
Copy Markdown
Contributor

This PR contains:

  • bugfix
  • feature
  • refactor
  • tests
  • documentation
  • metadata

Breaking Changes?

  • yes
  • no

Please Describe Your Changes

Fixes #2383 adding a watch hook for change events.

The idea here as well is to then deprecate the this.watcher as we should now have all the info we need here.

@shellscape shellscape left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tangential question: Should we start using emitWarning for use of deprecated hooks?

Comment thread src/rollup/types.d.ts Outdated
resolveId: ResolveIdHook;
isExternal: IsExternal;
parse: (input: string, options: any) => ESTree.Program;
// deprecate asset dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't even know that assets could have dependencies and it's already being deprecated 🤔😞

@tivac

tivac commented Aug 13, 2018

Copy link
Copy Markdown
Contributor

This'll be a big help, thanks so much @guybedford!

Comment thread src/rollup/types.d.ts
footer?: AddonHook;
intro?: AddonHook;
outro?: AddonHook;
watchChange?: (id: string) => void;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea is to deprecate asset dependencies in favour of the watchChange handler? Sounds really good to me, much clearer and easier to reason about.

In order to start the actual deprecation soon, should we

  • Remove the "dependencies" version emitAssets from the types, or at least
  • Add an @deprecated JSDoc comment above the type which should be picked up by many IDEs? (would be an interesting thing to do for other deprecations as well. Not 100% sure about VSCode but I know WebStorm/IntelliJ uses these @deprecated tags to visually mark usages as deprecated).

Also I agree with @shellscape that a warning would make sense considering asset dependencies are not widely known yet anyway (thanks @tivac for pointing that out 😉)

@guybedford

Copy link
Copy Markdown
Contributor Author

I was going to do a PR specifically just on the deprecations for 1.0 (adding warnings, but not actually making them breaking).

This asset dependencies one could be one we deprecate before 1.0 though potentially, as I don't think anyone is using this feature yet as it's been very early for this.

I could add the removal here if you like?

@guybedford

Copy link
Copy Markdown
Contributor Author

Asset dependencies were not documented for stability reasons (I like to give all new APIs a grace period personally), so removing it should be fine actually.

@guybedford

Copy link
Copy Markdown
Contributor Author

I've added the asset dependencies removal.

@guybedford guybedford mentioned this pull request Aug 14, 2018
4 of 8 tasks

@lukastaegert lukastaegert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin onchange hook for notifications when a file change is detected

4 participants