forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DevTools: Parse named source AST in a worker (facebook#21902)
Resolves facebook#21855 Ended up using workerize in order to setup the worker once it allows easy imports (for babel's parse function) and exports.
- Loading branch information
Showing
9 changed files
with
161 additions
and
45 deletions.
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
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