-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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: Parse named source AST in a worker #21902
Merged
bvaughn
merged 10 commits into
facebook:main
from
tsirlucas:parse-named-source-ast-on-worker
Jul 21, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2a40c4b
DevTools: Parse named source AST in a worker
tsirlucas 11fced8
DevTools: Fix flow types declarations for workerizedParse
tsirlucas be66d47
DevTools: mock worker for tests
tsirlucas 7346b50
DevTools: use worker instance instead of creating a new one
tsirlucas 1bebee8
DevTools: isolate worker tests and check if function calls are addres…
tsirlucas 485567a
DevTools: move parseHookNames function to worker
tsirlucas c119085
DevTools: adapt tests to parseHookNames changes
tsirlucas 754f8a3
DevTools: update yarn.lock
tsirlucas ea30ba7
DevTools: increase hookNamesCache timeout
tsirlucas d2b962d
DevTools: allow blob: on content_security_policy for firefox
tsirlucas 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 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 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 |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
"update-mock-source-maps": "node ./src/__tests__/updateMockSourceMaps.js" | ||
}, | ||
"devDependencies": { | ||
"acorn-jsx": "^5.2.0", | ||
"@babel/core": "^7.11.1", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-transform-flow-strip-types": "^7.10.4", | ||
|
@@ -28,6 +27,7 @@ | |
"@babel/preset-env": "^7.11.0", | ||
"@babel/preset-flow": "^7.10.4", | ||
"@babel/preset-react": "^7.10.4", | ||
"acorn-jsx": "^5.2.0", | ||
"archiver": "^3.0.0", | ||
"babel-core": "^7.0.0-bridge", | ||
"babel-eslint": "^9.0.0", | ||
|
@@ -55,7 +55,8 @@ | |
"web-ext": "^3.0.0", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11", | ||
"webpack-dev-server": "^3.10.3" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also don't forget to run diff --git a/yarn.lock b/yarn.lock
index c0bddfe82c..03daa69ff8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -14877,6 +14877,13 @@ worker-loader@^3.0.2:
loader-utils "^2.0.0"
schema-utils "^2.7.0"
+workerize-loader@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/workerize-loader/-/workerize-loader-1.3.0.tgz#4995cf2ff2b45dd6dc60e4411e63f5ae2c704d36"
+ integrity sha512-utWDc8K6embcICmRBUUkzanPgKBb8yM1OHfh6siZfiMsswE8wLCa9CWS+L7AARz0+Th4KH4ZySrqer/OJ9WuWw==
+ dependencies:
+ loader-utils "^2.0.0"
+
wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" |
||
"webpack-dev-server": "^3.10.3", | ||
"workerize-loader": "^1.3.0" | ||
}, | ||
"dependencies": { | ||
"web-ext": "^4" | ||
|
This file contains 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
33 changes: 33 additions & 0 deletions
33
packages/react-devtools-extensions/src/parseHookNames/index.js
This file contains 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,33 @@ | ||
/* global chrome */ | ||
|
||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
// This file uses workerize to load ./parseHookNames.worker as a webworker | ||
// and instanciates it, exposing flow typed functions that can be used | ||
// on other files. | ||
|
||
import * as parseHookNamesModule from './parseHookNames'; | ||
import WorkerizedParseHookNames from './parseHookNames.worker'; | ||
|
||
type ParseHookNamesModule = typeof parseHookNamesModule; | ||
|
||
// $FlowFixMe | ||
const wasmMappingsURL = chrome.extension.getURL('mappings.wasm'); | ||
|
||
const workerizedParseHookNames: ParseHookNamesModule = window.Worker | ||
? WorkerizedParseHookNames() | ||
: parseHookNamesModule; | ||
|
||
type ParseHookNames = $PropertyType<ParseHookNamesModule, 'parseHookNames'>; | ||
|
||
export const parseHookNames: ParseHookNames = hooksTree => | ||
workerizedParseHookNames.parseHookNames(hooksTree, wasmMappingsURL); | ||
|
||
export const purgeCachedMetadata = workerizedParseHookNames.purgeCachedMetadata; |
This file contains 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
4 changes: 4 additions & 0 deletions
4
packages/react-devtools-extensions/src/parseHookNames/parseHookNames.worker.js
This file contains 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,4 @@ | ||
import * as parseHookNamesModule from './parseHookNames'; | ||
|
||
export const parseHookNames = parseHookNamesModule.parseHookNames; | ||
export const purgeCachedMetadata = parseHookNamesModule.purgeCachedMetadata; |
This file contains 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 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 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
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.
Oh right. Had to make the same change in #21897