-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Add a script for extracting error codes #6882
Conversation
@keyanzhang updated the pull request. |
var source = fs.readFileSync(filePath, 'utf8'); | ||
return babylon.parse(source, { | ||
sourceType: 'module', | ||
plugins: [ |
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.
should this use the same config from 'babel-preset-fbjs' in #6876?
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.
@keyanzhang updated the pull request. |
@zpao the tests pass locally but not on travis. Could this be a caching-related issue? https://travis-ci.org/facebook/react/jobs/133367229 |
@@ -95,6 +97,7 @@ | |||
"testPathDirs": [ | |||
"<rootDir>/eslint-rules", | |||
"<rootDir>/mocks", | |||
"<rootDir>/scripts/error-extractor", |
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.
Let's just add all of scripts here in case we want to add more later.
@keyanzhang updated the pull request. |
|
||
var evalToString = require('./evalToString'); | ||
var invertObject = require('./invertObject'); | ||
var safeParseJSON = require('./safeParseJSON'); |
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.
As discussed in person, let's move this back inline – but move all the logic in this file into top-level functions and then just call it at the end of the file.
@keyanzhang updated the pull request. |
@keyanzhang updated the pull request. |
This looks great. Two things:
Otherwise this looks great – feel free to merge whenever. |
function flush(cb) { | ||
fs.writeFile( | ||
errorMapFilePath, | ||
JSON.stringify(invertObject(existingErrorMap), null, 2) + os.EOL, |
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.
I think we probably actually want to just use '\n'
so we generate the same file on Windows. Or even just leave off the newline.
@keyanzhang updated the pull request. |
@keyanzhang updated the pull request. |
(cherry picked from commit bfd1531)
(cherry picked from commit bfd1531)
…help from 1d0c1b1 to get the basic gulp setup (0.14 beta v2 code), and took a lot of dependency wrangling. `grunt extract-errors` should run the script now. I'm starting with a fresh codes.json because these will never match up with the official ones unfortunately. Things skipped: - travis integration. I don't know anything about travis so don't know if / how to hook this up for it. - inserting this as part of a full build process. It looks like it's a oneoff in master too fwiw
…help from 1d0c1b1 to get the basic gulp setup (0.14 beta v2 code), and took a lot of dependency wrangling. `grunt extract-errors` should run the script now. I'm starting with a fresh codes.json because these will never match up with the official ones unfortunately. Things skipped: - travis integration. I don't know anything about travis so don't know if / how to hook this up for it. - inserting this as part of a full build process. It looks like it's a oneoff in master too fwiw
* Remove es3-ify and es5-shim * adding our own readme * Update version references * Rename readme to markdown * Update the build process to build react-debug.js and react-with-addons-debug.js, which are going to be a hybrid dev/prod build that is faster than the dev version but still has most of the production error messages * Replace some choice instances of __DEV__ with __DEBUG__, including - use of factory on React.DOM members - use of analytics plugin (maybe don't need this...) Avoided (these are still __DEV__) - freezing objects - propType checking - lots of small checks like warnings of whether style names are valid. * keep warning messages in debug builds * Add a hook for registering a callback on warnings * update dropbox readme with instructions for how to the custom react gets loaded into metaserver * Fix bug in WarningHandlers * update README_DROPBOX with info I've learned * Make warning handlers actually work instead of crash * This backports bfd1531 from react 15.2 (facebook#6882); it took some help from 1d0c1b1 to get the basic gulp setup (0.14 beta v2 code), and took a lot of dependency wrangling. `grunt extract-errors` should run the script now. I'm starting with a fresh codes.json because these will never match up with the official ones unfortunately. Things skipped: - travis integration. I don't know anything about travis so don't know if / how to hook this up for it. - inserting this as part of a full build process. It looks like it's a oneoff in master too fwiw * backport rewriting to error codes working for debug & prod builds from 1abce16 * minor README_DROPBOX tweak * add space to invariant error message * Add debug warnings for ReactClass * Keep some DEV only warnings in DEBUG * Re-extract error codes * Include instructions on prod version in dropbox readme * Fix warning handlers * Remove instruction to copy over production React. Instead we should use the official build for prod. * Revert inclusion of prop mutations to DEV builds We probably want to include them later on since they're immensely useful for upgrading to future versions. But for the (at least) initial 0.13.3 we can live without them. * Include debug warning about `componentShouldUpdate` * Update .eslintrc with DEBUG global
As we talked in #6874, this is the first step that extracts error codes to a JSON file. The script adds any new error messages to the end of the file without changing existing codes. The traversal order of files is determined by their path names so that the result is stable.
I added
babel-traverse
andbabylon
as new dev dependencies, but they are already required bybabel-core
so we actually just lifted them up.Thanks for reviewing! CC @spicyj
A few things left:
Require glob patterns rather than copy themUse gulp