Skip to content

Commit 525fd70

Browse files
author
Brian Vaughn
committed
Replaced source-map with source-map-js
1 parent f51579f commit 525fd70

File tree

9 files changed

+13
-62
lines changed

9 files changed

+13
-62
lines changed

packages/react-devtools-extensions/build.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ const build = async (tempPath, manifestPath) => {
9393
STATIC_FILES.map(file => copy(join(__dirname, file), join(zipPath, file))),
9494
);
9595

96-
// The "source-map" library requires this chunk of WASM to be bundled at runtime.
97-
await copy(
98-
join(__dirname, 'node_modules', 'source-map', 'lib', 'mappings.wasm'),
99-
join(zipPath, 'mappings.wasm'),
100-
);
101-
10296
const commit = getGitCommit();
10397
const dateString = new Date().toLocaleDateString();
10498
const manifest = JSON.parse(readFileSync(copiedManifestPath).toString());

packages/react-devtools-extensions/chrome/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
"main.html",
3333
"panel.html",
3434
"build/react_devtools_backend.js",
35-
"build/renderer.js",
36-
"mappings.wasm"
35+
"build/renderer.js"
3736
],
3837

3938
"background": {

packages/react-devtools-extensions/edge/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
"main.html",
3333
"panel.html",
3434
"build/react_devtools_backend.js",
35-
"build/renderer.js",
36-
"mappings.wasm"
35+
"build/renderer.js"
3736
],
3837

3938
"background": {

packages/react-devtools-extensions/firefox/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"main.html",
3838
"panel.html",
3939
"build/react_devtools_backend.js",
40-
"build/renderer.js",
41-
"mappings.wasm"
40+
"build/renderer.js"
4241
],
4342

4443
"background": {

packages/react-devtools-extensions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"rollup-plugin-babel": "^4.0.1",
6363
"rollup-plugin-commonjs": "^9.3.4",
6464
"rollup-plugin-node-resolve": "^2.1.1",
65-
"source-map": "^0.8.0-beta.0",
65+
"source-map-js": "^0.6.2",
6666
"sourcemap-codec": "^1.4.8",
6767
"style-loader": "^0.23.1",
6868
"webpack": "^4.43.0",

packages/react-devtools-extensions/src/__tests__/parseHookNames-test.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ function requireText(path, encoding) {
2525
}
2626
}
2727

28-
const chromeGlobal = {
29-
extension: {
30-
getURL: jest.fn((...args) => {
31-
const {join} = require('path');
32-
return join(
33-
__dirname,
34-
'..',
35-
'..',
36-
'node_modules',
37-
'source-map',
38-
'lib',
39-
'mappings.wasm',
40-
);
41-
}),
42-
},
43-
};
44-
4528
describe('parseHookNames', () => {
4629
let fetchMock;
4730
let inspectHooks;
@@ -57,9 +40,6 @@ describe('parseHookNames', () => {
5740
fetchMock = require('jest-fetch-mock');
5841
fetchMock.enableMocks();
5942

60-
// Mock out portion of browser API used by parseHookNames to initialize "source-map".
61-
global.chrome = chromeGlobal;
62-
6343
inspectHooks = require('react-debug-tools/src/ReactDebugHooks')
6444
.inspectHooks;
6545
parseHookNames = require('../parseHookNames/parseHookNames').parseHookNames;
@@ -734,9 +714,6 @@ describe('parseHookNames worker', () => {
734714
};
735715
});
736716

737-
// Mock out portion of browser API used by parseHookNames to initialize "source-map".
738-
global.chrome = chromeGlobal;
739-
740717
inspectHooks = require('react-debug-tools/src/ReactDebugHooks')
741718
.inspectHooks;
742719
parseHookNames = require('../parseHookNames').parseHookNames;

packages/react-devtools-extensions/src/parseHookNames/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global chrome */
2-
31
/**
42
* Copyright (c) Facebook, Inc. and its affiliates.
53
*
@@ -15,14 +13,11 @@
1513
import WorkerizedParseHookNames from './parseHookNames.worker';
1614
import typeof * as ParseHookNamesModule from './parseHookNames';
1715

18-
// $FlowFixMe
19-
const wasmMappingsURL = chrome.extension.getURL('mappings.wasm');
20-
2116
const workerizedParseHookNames: ParseHookNamesModule = WorkerizedParseHookNames();
2217

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

2520
export const parseHookNames: ParseHookNames = hooksTree =>
26-
workerizedParseHookNames.parseHookNames(hooksTree, wasmMappingsURL);
21+
workerizedParseHookNames.parseHookNames(hooksTree);
2722

2823
export const purgeCachedMetadata = workerizedParseHookNames.purgeCachedMetadata;

packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import {parse} from '@babel/parser';
1111
import LRU from 'lru-cache';
12-
import {SourceMapConsumer} from 'source-map';
12+
import {SourceMapConsumer} from 'source-map-js';
1313
import {getHookName} from '../astUtils';
1414
import {areSourceMapsAppliedToErrors} from '../ErrorTester';
1515
import {__DEBUG__} from 'react-devtools-shared/src/constants';
@@ -110,7 +110,6 @@ const originalURLToMetadataCache: LRUCache<
110110

111111
export async function parseHookNames(
112112
hooksTree: HooksTree,
113-
wasmMappingsURL: string,
114113
): Thenable<HookNames | null> {
115114
const hooksList: Array<HooksNode> = [];
116115
flattenHooksList(hooksTree, hooksList);
@@ -169,9 +168,7 @@ export async function parseHookNames(
169168
}
170169

171170
return loadSourceFiles(locationKeyToHookSourceData)
172-
.then(() =>
173-
extractAndLoadSourceMaps(locationKeyToHookSourceData, wasmMappingsURL),
174-
)
171+
.then(() => extractAndLoadSourceMaps(locationKeyToHookSourceData))
175172
.then(() => parseSourceAST(locationKeyToHookSourceData))
176173
.then(() => updateLruCache(locationKeyToHookSourceData))
177174
.then(() => findHookNames(hooksList, locationKeyToHookSourceData));
@@ -193,7 +190,6 @@ function decodeBase64String(encoded: string): Object {
193190

194191
function extractAndLoadSourceMaps(
195192
locationKeyToHookSourceData: Map<string, HookSourceData>,
196-
wasmMappingsURL: string,
197193
): Promise<*> {
198194
// SourceMapConsumer.initialize() does nothing when running in Node (aka Jest)
199195
// because the wasm file is automatically read from the file system
@@ -204,8 +200,6 @@ function extractAndLoadSourceMaps(
204200
'extractAndLoadSourceMaps() Initializing source-map library ...',
205201
);
206202
}
207-
208-
SourceMapConsumer.initialize({'lib/mappings.wasm': wasmMappingsURL});
209203
}
210204

211205
// Deduplicate fetches, since there can be multiple location keys per source map.
@@ -264,11 +258,7 @@ function extractAndLoadSourceMaps(
264258
if (hookMap != null) {
265259
hookSourceData.hookMap = hookMap;
266260
}
267-
setPromises.push(
268-
new SourceMapConsumer(parsed).then(sourceConsumer => {
269-
hookSourceData.sourceConsumer = sourceConsumer;
270-
}),
271-
);
261+
hookSourceData.sourceConsumer = new SourceMapConsumer(parsed);
272262
break;
273263
}
274264
} else {

yarn.lock

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14168,6 +14168,11 @@ source-list-map@^2.0.0:
1416814168
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
1416914169
integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==
1417014170

14171+
source-map-js@^0.6.2:
14172+
version "0.6.2"
14173+
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e"
14174+
integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==
14175+
1417114176
source-map-resolve@^0.5.0:
1417214177
version "0.5.3"
1417314178
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
@@ -14223,13 +14228,6 @@ source-map@^0.7.3:
1422314228
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
1422414229
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
1422514230

14226-
source-map@^0.8.0-beta.0:
14227-
version "0.8.0-beta.0"
14228-
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.8.0-beta.0.tgz#d4c1bb42c3f7ee925f005927ba10709e0d1d1f11"
14229-
integrity sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==
14230-
dependencies:
14231-
whatwg-url "^7.0.0"
14232-
1423314231
sourcemap-codec@^1.4.1, sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8:
1423414232
version "1.4.8"
1423514233
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"

0 commit comments

Comments
 (0)