-
Notifications
You must be signed in to change notification settings - Fork 49.4k
Add additional secret property to build artifact for react-dom-server #5381
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
Merged
+64
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ examples/ | |
build/ | ||
scripts/bench/bench-*.js | ||
vendor/react-dom.js | ||
vendor/react-dom-server.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
var grunt = require('grunt'); | ||
var UglifyJS = require('uglify-js'); | ||
|
||
var LICENSE_TEMPLATE = | ||
grunt.file.read('./grunt/data/header-template-extended.txt'); | ||
|
||
module.exports = function() { | ||
var templateData = { | ||
package: 'ReactDOMServer', | ||
version: grunt.config.data.pkg.version, | ||
}; | ||
var header = grunt.template.process( | ||
LICENSE_TEMPLATE, | ||
{data: templateData} | ||
); | ||
var src = grunt.file.read('vendor/react-dom-server.js'); | ||
grunt.file.write( | ||
'build/react-dom-server.js', | ||
header + src | ||
); | ||
grunt.file.write( | ||
'build/react-dom-server.min.js', | ||
header + UglifyJS.minify(src, {fromString: true}).code | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js | ||
;(function(f) { | ||
// CommonJS | ||
if (typeof exports === "object" && typeof module !== "undefined") { | ||
module.exports = f(require('react')); | ||
|
||
// RequireJS | ||
} else if (typeof define === "function" && define.amd) { | ||
define(['react'], f); | ||
|
||
// <script> | ||
} else { | ||
var g | ||
if (typeof window !== "undefined") { | ||
g = window; | ||
} else if (typeof global !== "undefined") { | ||
g = global; | ||
} else if (typeof self !== "undefined") { | ||
g = self; | ||
} else { | ||
// works providing we're not in "use strict"; | ||
// needed for Java 8 Nashorn | ||
// see https://github.com/facebook/react/issues/3037 | ||
g = this; | ||
} | ||
g.ReactDOM = f(g.React); | ||
} | ||
|
||
})(function(React) { | ||
return React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
SECRET_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
made sense when we were migrating and you really would break stuff. But if we're adding this as an explicit hook to allow various environments, it shouldn't be a severe variable name (IMHO) - Or if this is just for the 0.14.3 update, perhaps it makes sense. cc @zpao @spicyj for thoughts.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.
The point is that the
react-dom-server.js
package we provide uses this secret key, but you're meant to never type it in your own code.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.
Yup, this is fine as is. We are not planning on making these properties condoned in any public use. They are subject to breaking (and I might just change them in the next release to ensure this does break)