This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update source-map worker to use source-map 0.7.x (#7071)
* Remove unused wrapper function in Webpack config generation. * Update yarn.lock for recent package.json changes. * Add a general concept of assets to the source-map worker. * Upgrade the source-map module for WASM performance. * Centralize sourcemap consumer construction.
- Loading branch information
1 parent
ef851da
commit 0d0dbd3
Showing
20 changed files
with
243 additions
and
83 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ | ||
// @flow | ||
|
||
module.exports = { | ||
"dwarf_to_json.wasm": require.resolve("./wasm/dwarf_to_json.wasm"), | ||
"source-map-mappings.wasm": require.resolve("source-map/lib/mappings.wasm") | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ | ||
|
||
// @flow | ||
const { SourceMapConsumer } = require("source-map"); | ||
|
||
async function createConsumer(map: any, sourceMapUrl: any): SourceMapConsumer { | ||
return new SourceMapConsumer(map, sourceMapUrl); | ||
} | ||
|
||
module.exports = { | ||
createConsumer | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ | ||
// @flow | ||
|
||
const fs = require("fs"); | ||
|
||
const assets = require("../../assets"); | ||
|
||
function setAssetRootURL(assetRoot: string): void { | ||
// No-op on Node | ||
} | ||
|
||
async function getDwarfToWasmData(): Promise<ArrayBuffer> { | ||
const data = await new Promise((res, rej) => { | ||
fs.readFile(assets["dwarf_to_json.wasm"], (err, result) => { | ||
if (err) { | ||
return rej(err); | ||
} | ||
res(result); | ||
}); | ||
}); | ||
|
||
return data.buffer; | ||
} | ||
|
||
module.exports = { | ||
setAssetRootURL, | ||
getDwarfToWasmData | ||
}; |
31 changes: 31 additions & 0 deletions
31
packages/devtools-source-map/src/utils/wasmAssetBrowser.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,31 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ | ||
// @flow | ||
|
||
const { SourceMapConsumer } = require("source-map"); | ||
|
||
let root; | ||
function setAssetRootURL(assetRoot: string): void { | ||
// Remove any trailing slash so we don't generate a double-slash below. | ||
root = assetRoot.replace(/\/$/, ""); | ||
|
||
SourceMapConsumer.initialize({ | ||
"lib/mappings.wasm": `${root}/source-map-mappings.wasm` | ||
}); | ||
} | ||
|
||
async function getDwarfToWasmData(name: string): Promise<ArrayBuffer> { | ||
if (!root) { | ||
throw new Error(`No wasm path - Unable to resolve ${name}`); | ||
} | ||
|
||
const response = await fetch(`${root}/dwarf_to_json.wasm`); | ||
|
||
return response.arrayBuffer(); | ||
} | ||
|
||
module.exports = { | ||
setAssetRootURL, | ||
getDwarfToWasmData | ||
}; |
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
File renamed without changes.
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
Oops, something went wrong.