-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Replace applescript with browser-launcher2 #2406
Conversation
console.warn(stderr); | ||
launch(debuggerURL, { | ||
browser: 'chrome', | ||
options: ['--disable-web-security'], |
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.
SOP should be kept on by default. It will be bad if someone launches Chrome with the RN tools and then starts using it as their browser.
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.
That's fair. As an alternative, what do you think about adding a command line option to packager.js to disable SOP? Something like
node packager.js --disable-web-security
Can you also squash your commits? |
Is it alright if I keep the commits separate for now, until we have a solution for if/how to use |
Sure. Re: solution I think you could expose a CLI flag from the packager that sets the disable-web-security option. Something like |
2ef54fe
to
6c98770
Compare
225a019
to
219fa82
Compare
Ok, I've added a command line argument |
}, function(err, instance) { | ||
if (err) { | ||
console.error('Failed to launch chrome', err); | ||
next(err); |
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.
missing return
here?
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.
Fixed
473e44c
to
25a2cbb
Compare
After rebaseing it on latest master it also works for React Native Android on Linux 👍 |
25a2cbb
to
e73442b
Compare
Awesome that it works! On that note, I've just rebased this PR onto master. |
e73442b
to
1033712
Compare
Hi guys |
@BerndWessels no, this PR is still open. The plan is for the packager to be moved into another repo some time next week or maybe the week after, so PRs that touch the packager are on hiatus. |
Hi @ide. Thanks for the information. There are several small fixes that all together will enable React-Native development on Windows. You can find them by following this issue. Please let us know when all these made it into master - I believe there are masses of developers desperately waiting to be able to start developing with React-Native on Windows. Thank you |
@BerndWessels you can pull the changes to your local and test on windows (that is what I am doing) |
3c0905e
to
1ff0f35
Compare
@frantic I've just amended my commit with the following two changes:
|
Slight update to the quick fix if your don't want to get spammed by new tabs: @@ -184,22 +184,24 @@ function getDevToolsLauncher(options) {
+ var launched = false;
return function(req, res, next) {
if (req.url === '/debugger-ui') {
var debuggerPath = path.join(__dirname, 'debugger.html');
res.writeHead(200, {'Content-Type': 'text/html'});
fs.createReadStream(debuggerPath).pipe(res);
} else if (req.url === '/launch-chrome-devtools') {
var debuggerURL = 'http://localhost:' + options.port + '/debugger-ui';
- var script = 'launchChromeDevTools.applescript';
console.log('Launching Dev Tools...');
- execFile(path.join(__dirname, script), [debuggerURL], function(err, stdout, stderr) {
- if (err) {
- console.log('Failed to run ' + script, err);
- }
- console.log(stdout);
- console.warn(stderr);
- });
+ if (!launched) {
+ // NOTE: The exec command varies depending on your OS and chrome installation.
+ require('child_process').exec('google-chrome "' + debuggerURL + '"', function (err) {
+ if (err) {
+ console.log("error", err);
+ }
+ });
+ launched = true;
+ }
res.end('OK');
} else {
next();
}
};
} |
Sorry for the delay @elliottsj, pinging @frantic to take another look. |
@elliottsj Is it possible to keep the exact original developer experience? |
I'm landing a couple of diffs that clean up this code separating each middleware packager.js has on multiple files. You'll need to rebase.. |
@mkonicek I'm not sure whether it's possible to keep the original applescript behaviour (i.e. using the user's normal Chrome instance) using browser-launcher2. How important is it to use the default Chrome instance? With the @martinbigio Let me know when your diff lands 😄 |
@elliottsj my main concern is that it opens another Chrome instance, which is pretty confusing. I just tried running |
@frantic Hmm, I agree that it might be a bit confusing at first. Though the If we opt for using the user's default Chrome instance, how do you think we should handle the |
if the option is present do launch new Chrome instance, no doubts about that. |
Alright, sounds good 😁 I'll do some digging to see if browser-launcher2 supports what we want, or perhaps use an alternative like https://github.com/sindresorhus/opn. |
thanks! |
This allows... 1. launching Chrome on platforms other than OS X 2. users to launch their own instance of Chrome (e.g. via command line) rather than being forced to use the default instance (i.e. `tell application "Chrome"` always used the default instance) `isDebuggerConnected()` addresses the problem in facebook#510 where the dev tools would only open once per server session. Add a '--dangerouslyDisableChromeDebuggerWebSecurity' flag to packager.js to enable Chrome '--disable-web-security' flag. This allows users to inspect network requests in Chrome by commenting the xhr polyfill in InitializeJavaScriptAppEngine.js: facebook#934 (comment) Usage: node packager.js --dangerouslyDisableChromeDebuggerWebSecurity or: packager.sh --dangerouslyDisableChromeDebuggerWebSecurity
1ff0f35
to
dd8d641
Compare
@elliottsj updated the pull request. |
Summary: This allows opening the Chrome debugger on OS X, Linux, and Windows, and succeeds the previous PR which used [browser-launcher2](https://github.com/benderjs/browser-launcher2) and included a `--dangerouslyDisableChromeDebuggerWebSecurity` option: #2406 [opn](https://github.com/sindresorhus/opn) is cross-platform and much simpler than browser-launcher2 (since we don't have to manage the opened Chrome instance; the OS will just use the default instance). Closes #3394 Reviewed By: mkonicek Differential Revision: D2550996 Pulled By: frantic fb-gh-sync-id: fa4cbe55542562f30f77e0a6ab4bc53980ee13aa
v0.13.0 does not have this fix yet, what @davidgilbertson and + @jrouleau suggest seem to be working on windows without opening new tab each reload. Are these already on pull request? |
Summary: This allows opening the Chrome debugger on OS X, Linux, and Windows, and succeeds the previous PR which used [browser-launcher2](https://github.com/benderjs/browser-launcher2) and included a `--dangerouslyDisableChromeDebuggerWebSecurity` option: facebook#2406 [opn](https://github.com/sindresorhus/opn) is cross-platform and much simpler than browser-launcher2 (since we don't have to manage the opened Chrome instance; the OS will just use the default instance). Closes facebook#3394 Reviewed By: mkonicek Differential Revision: D2550996 Pulled By: frantic fb-gh-sync-id: fa4cbe55542562f30f77e0a6ab4bc53980ee13aa
Summary: This allows opening the Chrome debugger on OS X, Linux, and Windows, and succeeds the previous PR which used [browser-launcher2](https://github.com/benderjs/browser-launcher2) and included a `--dangerouslyDisableChromeDebuggerWebSecurity` option: facebook#2406 [opn](https://github.com/sindresorhus/opn) is cross-platform and much simpler than browser-launcher2 (since we don't have to manage the opened Chrome instance; the OS will just use the default instance). Closes facebook#3394 Reviewed By: mkonicek Differential Revision: D2550996 Pulled By: frantic fb-gh-sync-id: fa4cbe55542562f30f77e0a6ab4bc53980ee13aa
Summary: This allows opening the Chrome debugger on OS X, Linux, and Windows, and succeeds the previous PR which used [browser-launcher2](https://github.com/benderjs/browser-launcher2) and included a `--dangerouslyDisableChromeDebuggerWebSecurity` option: facebook/react-native#2406 [opn](https://github.com/sindresorhus/opn) is cross-platform and much simpler than browser-launcher2 (since we don't have to manage the opened Chrome instance; the OS will just use the default instance). Closes facebook/react-native#3394 Reviewed By: mkonicek Differential Revision: D2550996 Pulled By: frantic fb-gh-sync-id: fa4cbe55542562f30f77e0a6ab4bc53980ee13aa
This allows...
tell application "Chrome"
always used the default instance)isDebuggerConnected()
addresses the problem in #510 where the dev tools would only open once per server session.Also passing the--disable-web-security
flag when launching Chrome so that users can inspect network requests in Chrome by commenting the xhr polyfill in InitializeJavaScriptAppEngine.js: #934 (comment)Also added a
--dangerouslyDisableChromeDebuggerWebSecurity
flag topackager.js to enable Chrome
--disable-web-security
flag so that users can inspect network requests in Chrome by commenting the xhr polyfill in InitializeJavaScriptAppEngine.js: #934 (comment)The only issue I've found in my testing is the console output
WARN: not opened
whenever you reload the iOS app: