Created by: iChenLei
Summary
To supoort react devtools launch editor feature https://github.com/facebook/react/pull/20821
Current issues
When we develop a react project in DEV
, we can get the component source file path by source
, (but it's abosulte path usually, react-dev-utils not support currently.)
* @param {*} source An annotation object (added by a transpiler or otherwise)
* indicating filename, line number, and/or other information.
* @internal
*/
const ReactElement = function(type, key, ref, self, source, owner, props) {
for example
/Users/username/code/src/app.tsx
/src/app.tsx
support custom launchEditorEndpoint
Do we need change these hard code for launchEditorEndpoint
???
- // TODO: we might want to make this injectable to support DEV-time non-root URLs.
- module.exports = '/__open-stack-frame-in-editor';
+ const LaunchEditorEndpoint = process.env.LAUNCH_EDITOR_ENDPOINT ?? '/__open-stack-frame-in-editor';
+ module.exports = LaunchEditorEndpoint;
So we can inject custom LaunchEditorEndpoint
by node process env.
"start": "LAUNCH_EDITOR_ENDPOINT=/__open-in-editor react-scripts start"
Test Plan
Please tell me how to test this change ? necessary unit test will be added later when I figure out how to test it.
append
Welcome any suggestion. draft
pull request, not the final pull request.