Commit Graph

31 Commits

Author SHA1 Message Date
Ruslan Lesiutin
8269d55d23
chore[react-devtools]: add global for native and use it to fork backend implementation (#30533)
Adding `__IS_NATIVE__` global, which will be used for forking backend
implementation. Will only be set to `true` for `react-devtools-core`
package, which is used by `react-native`.

Ideally, we should name it `react-devtools-native`, and keep
`react-devtools-core` as host-agnostic.

With this change, the next release of `react-devtools-core` should
append component stack as Error object, not as string, and should add
`(<anonymous>)` suffix to component stack frames.
2024-08-02 10:51:15 +01:00
Ruslan Lesiutin
b15c8492ca
fix[react-devtools/extensions]: propagate globals from env (#29963)
Somehow missed this while working on
https://github.com/facebook/react/pull/29869.

With these changes, manual inspection of the
`react_devtools_backend_compact.js` doesn't have any occurences of
`__IS_FIREFOX__` flag.
2024-06-20 09:29:05 +01:00
Ruslan Lesiutin
ff6e05a705
chore[react-devtools]: unify console patching and default to ansi escape symbols (#29869)
Stacked on https://github.com/facebook/react/pull/29856.

## Summary

By default, React DevTools will apply dimming with ANSI escape symbols,
so it works for both terminals and browser consoles.

For Firefox, which doesn't support ANSI escape symbols console stylings,
we fallback to css properties, like we used to do before.

## How did you test this change?

| Environment | Dark mode | Light mode |
|--------|--------|--------|
| Terminal | ![Screenshot 2024-06-12 at 19 39
46](https://github.com/facebook/react/assets/28902667/2d470eee-ec5f-4362-be7d-8d80c6c72d09)
| ![Screenshot 2024-06-12 at 19 39
09](https://github.com/facebook/react/assets/28902667/616f2c58-a251-406b-aee6-841e07d652ba)
|
| Fusebox&nbsp;console | ![Screenshot 2024-06-12 at 21 03
14](https://github.com/facebook/react/assets/28902667/6050f730-8e82-4aa1-acbc-7179aac3a8aa)
| ![Screenshot 2024-06-12 at 21 02
48](https://github.com/facebook/react/assets/28902667/6708b938-8a90-476f-a057-427963d58caa)
|
| Firefox&nbsp;console | ![Screenshot 2024-06-12 at 21 40
29](https://github.com/facebook/react/assets/28902667/4721084f-bbfa-438c-b61b-395da8ded590)
| ![Screenshot 2024-06-12 at 21 40
42](https://github.com/facebook/react/assets/28902667/72bbf001-2d3d-49e7-91c9-20a4f0914d4d)
|
| Chrome&nbsp;console | ![Screenshot 2024-06-12 at 21 43
09](https://github.com/facebook/react/assets/28902667/93c47881-a0dd-44f8-8dc2-8710149774e5)
| ![Screenshot 2024-06-12 at 21 43
00](https://github.com/facebook/react/assets/28902667/07ea4ff5-4322-4db9-9c12-4321d9577c9d)
|
2024-06-17 16:31:36 +01:00
Ruslan Lesiutin
d7bb6039de
chore[react-devtools/extensions]: make source maps url relative (#29886)
This adds few changes:
1. We are going to ship source maps only for 2 artifacts:
`installHook.js` and `react_devtools_backend_compact.js`, because it is
only these modules that can patch console and be visible to the user via
stack traces in console. We need to ship source maps to be able to use
`ignoreList` feature in source maps, so we can actually hide these from
stack traces.

| Before | After |
|--------|--------|
| ![Screenshot 2024-06-13 at 17 44
25](https://github.com/facebook/react/assets/28902667/464e097b-a95e-47eb-967c-0579daad316b)
| ![Screenshot 2024-06-13 at 17 39
53](https://github.com/facebook/react/assets/28902667/e4afe642-d65b-4296-a2cf-26c0b925ebf2)
|
 
2. The `"sources"` field in source map will have relative urls listed,
instead of absolute with `webpack://` protocol. This will move the
sources to the `React Developer Tools` frame in `Sources` panel, instead
of `webpack://`.
 
 | Before | After |
|--------|--------|
| ![Screenshot 2024-06-13 at 17 48
24](https://github.com/facebook/react/assets/28902667/a18edad2-5b4e-4ad7-8a7a-8b389c2edf92)
| ![Screenshot 2024-06-13 at 17 49
41](https://github.com/facebook/react/assets/28902667/5db491f7-5d1d-4155-9910-16ac4384d34e)
|

> [!NOTE]  
> I still have 1 unresolved issue with shipping source maps in extension
build, and it is related to Firefox, which can't find them in the
extension bundle and returns 404, even though urls are relative and I
can actually open them via unique address like
`moz-extension://<extension-id>/build/intallHook.js.map` ¯\\\_(ツ)\_/¯
2024-06-17 11:58:19 +01:00
Sebastian Silbermann
14f71db6b6
Devtools: Fix build-for-devtools (#28976) 2024-05-02 21:58:51 +02:00
Ruslan Lesiutin
6de7733e73
feat[devtools]: ship source maps for content scripts and ignore list installHook script (#28730)
## Summary

1. RDT browser extension's content scripts will now ship source maps
(without source in prod, to save some bundle size).
2. `installHook` content script will be ignore listed via `ignoreList`
field in the corresponding source map.
3. Previously, source map for backend file used `x_google_ignoreList`
naming, now `ignoreList`.

## How did you test this change?

1. `ignoreList-test.js`
2. Tested manually that I don't see `installHook` in stack traces when
`console.error` is called.
2024-04-08 18:10:09 +01:00
Ruslan Lesiutin
2c4c847188
refactor: resolve browser via env variables based on build rather than user agent (#27179)
Fixes https://github.com/facebook/react/issues/26911,
https://github.com/facebook/react/issues/26860.

Currently, we are parsing user agent string to determine which browser
is running the extension. This doesn't work well with custom user
agents, and sometimes when user turns on mobile dev mode in Firefox, we
stop resolving that this is a Firefox browser, extension starts to use
Chrome API's and fails to inject.

Changes:
Since we are building different extensions for all supported browsers
(Chrome, Firefox, Edge), we predefine env variables for browser
resolution, which are populated in a build step.
2023-08-29 10:40:02 +01:00
Ruslan Lesiutin
e3fb7c1de1
feat[devtools]: support x_google_ignoreList source maps extension (#26951)
## Summary
This was originally implemented by Mengdi @mondaychen in
https://github.com/facebook/react/pull/26506.

Because we patch console methods (to append components stack and some
other features), errors in console will include
`react_devtools_backend-....js` in its stack traces. Example:
<img width="763" alt="Screenshot 2023-06-15 at 13 31 49"
src="https://github.com/facebook/react/assets/28902667/fa9c3d26-b6c5-4965-af71-62d100cd806d">

Using https://github.com/mondaychen/devtools-ignore-webpack-plugin to
support [x_google_ignoreList source maps
extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).

@mondaychen created a react app, which throws an error via
`console.error`, when user click on the button -
https://3owqsn.csb.app/.

Stack trace with these changes: 
<img width="759" alt="Screenshot 2023-06-14 at 14 26 38"
src="https://github.com/facebook/react/assets/28902667/b118b168-3200-4a47-9718-39fc455ea993">
2023-06-21 12:36:48 +01:00
Ruslan Lesiutin
4ddc019aca
chore[devtools]: upgrade to webpack v5 (#26887)
## Summary
- Updated `webpack` (and all related packages) to v5 in
`react-devtools-*` packages.
- I haven't touched any `TODO (Webpack 5)`. Tried to poke it, but each
my attempt failed and parsing hook names feature stopped working. I will
work on this in a separate PR.
- This work is one of prerequisites for updating Firefox extension to
manifests v3

related PRs:
https://github.com/facebook/react/pull/22267
https://github.com/facebook/react/pull/26506

## How did you test this change?
Tested on all surfaces, explicitly checked that parsing hook names
feature still works.
2023-06-14 13:15:52 +01:00
Mengdi Chen
d962f35cac
[DevTools] use backend manager to support multiple backends in extension (#26615)
In the extension, currently we do the following:
1. check whether there's at least one React renderer on the page
2. if yes, load the backend to the page
3. initialize the backend 

To support multiple versions of backends, we are changing it to:
1. check the versions of React renders on the page
2. load corresponding React DevTools backends that are shipped with the
extension; if they are not contained (usually prod builds of
prereleases), show a UI to allow users to load them from UI
3. initialize each of the backends

To enable this workflow, a backend will ignore React renderers that does
not match its version

This PR adds a new file "backendManager" in the extension for this
purpose.


------
I've tested it on Chrome, Edge and Firefox extensions
2023-04-18 12:02:42 -04:00
Mengdi Chen
78c4bec207
[DevTools] fix local build for extension (#26067)
## Summary

resolves #26051

After we upgrade to Manifest V3, the browser no longer allow us to run
`eval` within the extension. It's not a problem for prod build, but for
dev build, webpack has been using eval to inject the source map for
devtool. This PR changes it to an alternative method.
2023-01-27 15:35:07 -05:00
Brian Vaughn
c624dc3598
DevTools supports ENV-injected version for better internal bug reports (#22635) 2021-10-27 17:18:48 -04:00
Andrew Clark
bb0d069359
[build2 -> build] Local scripts
Update all our local scripts to use `build` instead of `build2`.

There are still downstream scripts that depend on `build2`, though, so
we can't remove it yet.
2021-09-21 15:14:09 -04:00
Andrew Clark
baff3f2005
Move build_devtools_and_process_artifacts (#22388)
This is the last CI job that needs to be migrated to the new workflow.
2021-09-21 08:51:51 -07:00
Luna Ruan
60a30cf32e
Console Logging for StrictMode Double Rendering (#22030)
React currently suppress console logs in StrictMode during double rendering. However, this causes a lot of confusion. This PR moves the console suppression logic from React into React Devtools. Now by default, we no longer suppress console logs. Instead, we gray out the logs in console during double render. We also add a setting in React Devtools to allow developers to hide console logs during double render if they choose.
2021-08-25 15:35:38 -07:00
Brian Vaughn
c5cfa71948
DevTools: Show hook names based on variable usage (#21641)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
Co-authored-by: Saphal Patro <saphal1998@gmail.com>
Co-authored-by: VibhorCodecianGupta <vibhordelgupta@gmail.com>
2021-07-01 14:39:18 -04:00
Brian Vaughn
85b543c6b4
Added new GitHub issue form for React DevTools bug reports (#21450)
Added a new bug report template built with GitHub issue forms:
https://gh-community.github.io/issue-template-feedback/structured/

And updated DevTools bug report link to send information formatted for this new template.
2021-05-07 08:46:58 -04:00
Brian Vaughn
119736b1c2
[FB-only] Show which hooks (indices) changed when profiling (#20998) 2021-03-17 12:28:21 -04:00
Sy Tran Dung
4e5d7faf54
Fix error loading source maps for devtools extension (#20079) 2020-10-22 11:26:24 -04:00
Johnny Pribyl
b3b1bb9ce2
Enable source maps for DevTools production builds (#19773)
Co-authored-by: Brian Vaughn <bvaughn@fb.com>
2020-09-18 10:07:22 -04:00
Brian Vaughn
a9ba5283d9
Disable DevTools minification (#19369)
DevTools isn't being downloaded like typical JavaScript, so bundle size concerns don't apply. Parsing is still a consideration (so I'm open for discussion here) but I think this change would provide a couple of benefits:
* People are more likely to *actually read* non-minified source code when e.g. a breakpoint is hit (as with the recent debugger statement)
* Component stacks will be easier to parse on bug reports
2020-07-15 10:38:30 -04:00
Brian Vaughn
2efe63d99c
DevTools: Add break-on-warn feature (#19048)
This commit adds a new tab to the Settings modal: Debugging

This new tab has the append component stacks feature and a new one: break on warn

This new feature adds a debugger statement into the console override
2020-05-29 14:34:43 -07:00
Brian Vaughn
fb3f0acad9
Disable Webpack setImmediate polyfill for DevTools (#18860)
* Upgrade Webpack deps to latet

* Disable Webpack setImmediate polyfill
2020-05-07 13:13:47 -07:00
Brian Vaughn
36cab2720a
DevTools: Improved "native" component stacks (#18656)
* DevTools console override handles new component stack format

DevTools does not attempt to mimic the default browser console format for its component stacks but it does properly detect the new format for Chrome, Firefox, and Safari.
2020-04-21 11:46:11 -07:00
Brian Vaughn
1c63b2e416
Renamed "backend.js" to "react_devtools_backend.js" (#17790) 2020-01-06 09:29:20 -08:00
Brian Vaughn
5fc97420b9
Remove dependency on local git checkout from build process (#17475)
* Remove dependency on local git checkout from build process

* Updated Webpack dependencies to account for recent changes to deps for Flight
2019-11-27 07:48:09 -08:00
Brian Vaughn
41db902ed4 Removed unused __TEST__ files 2019-08-14 19:03:32 -07:00
Brian Vaughn
58b39c60db Fixed web extensions 2019-08-14 10:33:33 -07:00
Brian Vaughn
30b8ef3756 Iterated on Webpack configs until I got the inline and shell packages seemingly working 2019-08-14 09:24:35 -07:00
Brian Vaughn
441d014cef Cleaned up some extnesions build script stuff 2019-08-13 22:15:38 -07:00
Brian Vaughn
ac2e861fbe Fixed a bunch of Lint issues 2019-08-13 21:59:07 -07:00