Skip to content

Commit

Permalink
make parseHookNames a separate webpack module
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaruan committed Aug 16, 2021
1 parent 8258361 commit 4f51630
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
38 changes: 20 additions & 18 deletions packages/react-devtools-extensions/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
getSavedComponentFilters,
getShowInlineWarningsAndErrors,
} from 'react-devtools-shared/src/utils';
import {parseHookNames, purgeCachedMetadata} from './parseHookNames';
import {
localStorageGetItem,
localStorageRemoveItem,
Expand Down Expand Up @@ -210,23 +209,26 @@ function createPanelIfReactLoaded() {

render = (overrideTab = mostRecentOverrideTab) => {
mostRecentOverrideTab = overrideTab;

root.render(
createElement(DevTools, {
bridge,
browserTheme: getBrowserTheme(),
componentsPortalContainer,
enabledInspectedElementContextMenu: true,
loadHookNames: parseHookNames,
overrideTab,
profilerPortalContainer,
purgeCachedHookNamesMetadata: purgeCachedMetadata,
showTabBar: false,
store,
warnIfUnsupportedVersionDetected: true,
viewAttributeSourceFunction,
viewElementSourceFunction,
}),
import('./parseHookNames').then(
({parseHookNames, purgeCachedMetadata}) => {
root.render(
createElement(DevTools, {
bridge,
browserTheme: getBrowserTheme(),
componentsPortalContainer,
enabledInspectedElementContextMenu: true,
loadHookNames: parseHookNames,
overrideTab,
profilerPortalContainer,
purgeCachedHookNamesMetadata: purgeCachedMetadata,
showTabBar: false,
store,
warnIfUnsupportedVersionDetected: true,
viewAttributeSourceFunction,
viewElementSourceFunction,
}),
);
},
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
// 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;
import typeof * as ParseHookNamesModule from './parseHookNames';

// $FlowFixMe
const wasmMappingsURL = chrome.extension.getURL('mappings.wasm');

const workerizedParseHookNames: ParseHookNamesModule = window.Worker
? WorkerizedParseHookNames()
: parseHookNamesModule;
const workerizedParseHookNames: ParseHookNamesModule = WorkerizedParseHookNames();

type ParseHookNames = $PropertyType<ParseHookNamesModule, 'parseHookNames'>;

Expand Down
1 change: 1 addition & 0 deletions packages/react-devtools-extensions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
},
output: {
path: __dirname + '/build',
publicPath: '/build/',
filename: '[name].js',
},
node: {
Expand Down

0 comments on commit 4f51630

Please sign in to comment.