Skip to content
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

[DevTools Bug]: Can not work on devtools, instructions lead to error #26051

Closed
sroussey opened this issue Jan 26, 2023 · 4 comments · Fixed by #26067
Closed

[DevTools Bug]: Can not work on devtools, instructions lead to error #26051

sroussey opened this issue Jan 26, 2023 · 4 comments · Fixed by #26067
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@sroussey
Copy link

Website or app

https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en

Repro steps

Because react requires java, not on macos (but assumes brew installed!):

brew update && brew install java
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc
export PATH="/usr/local/opt/openjdk/bin:$PATH" >> ~/.zshrc
export PATH="/usr/local/opt/openjdk/bin:$PATH"

Because react requires node before v17 (but assuming you have nvm installed!):

nvm install 16

then the real stuff (directions inside folders like ./chrome/ are quite wrong):

git clone https://github.com/facebook/react.git
cd react
yarn install
yarn build-for-devtools
cd packages/react-devtools-extensions
yarn build:chrome
yarn build:chrome:local
yarn run test:chrome

Now inside devtools:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'".

    at ./src/contentScripts/prepareInjection.js (prepareInjection.js:133:1)
    at __webpack_require__ (prepareInjection.js:20:30)
    at prepareInjection.js:84:18
    at prepareInjection.js:87:10

What exactly are you doing that works in order to build, test, and develop this extension?

How often does this bug happen?

Every time

DevTools package (automated)

No response

DevTools version (automated)

No response

Error message (automated)

No response

Error call stack (automated)

No response

Error component stack (automated)

No response

GitHub query string (automated)

No response

@sroussey sroussey added Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Jan 26, 2023
@mondaychen
Copy link
Contributor

Sounds like you are trying to set up the development environment of DevTools extension and found the docs confusing, rather than reporting a bug in DevTools. The docs are indeed confusing and outdated, and I plan to improve them in near future.
That being said, I never encountered the issue you described. Can you let me know which version of Chrome are you using?

@sroussey
Copy link
Author

Stable version. 109

@mondaychen
Copy link
Contributor

Ah I've successfully reproduced this issue. The root cause is that webpack was using eval for local (dev mode) build. Will submit a fix soon

mondaychen added a commit that referenced this issue Jan 27, 2023
## 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.
github-actions bot pushed a commit that referenced this issue Jan 27, 2023
## 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.

DiffTrain build for [78c4bec](78c4bec)
[View git log for this commit](https://github.com/facebook/react/commits/78c4bec207795e718b5f4acc48ade19c8b94bf1f)
@sroussey
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@sroussey @mondaychen and others