-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Deprecate bound action creators for "actions" #3491
Conversation
@@ -350,6 +352,19 @@ module.exports = async (program: any) => { | |||
console.log() | |||
} | |||
|
|||
function printDeprecationWarnings() { | |||
const files = glob | |||
.sync("{,!(node_modules|public)/**/}*.js") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be pretty expensive. I was thinking that instead, we could wrap the functions we pass to boundActionCreators
so that any time those functions are called, we write to console (only once per session) a message saying that they should switch to actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is nice you say which files are using it — we do know which plugins we're calling so we could probably capture that data as well to improve the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too expensive -- just searches through the gatsby repo for any source code javascript files. I timed it on the gatsbyjs.org website and it takes 0.044 seconds the first time, 0.02 seconds the second time, 0.013 seconds the third time (probably due to bits of memory getting pulled into caches).
Also this only gets called once per gatsby develop, if we are worried about performance in the future, we can make it async so it's not blocking. In general too this seems like a pretty nice structure for other helpful messages we may want to add in the future. "We see you're using plugin X, this has been deprecated in favor of plugin Y"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I thought this was searching all of node_modules
. This is only alerting on site specific code not 3rd party plugins. Makes sense.
This PR should also replace all instances of |
👍 done |
Sweet! |
* deprecate bound action creators for v2, remove from website, add error message * remove find-in-files * modify plugins to replace boundActionCreators with actions * modify examples to replace boundActionCreators with actions * remove merge artifact
Fixes #1909