aboutsummaryrefslogtreecommitdiffstats
path: root/development
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-05-14 21:30:50 +0800
committerDan <danjm.com@gmail.com>2018-05-14 22:14:50 +0800
commit6bc8cc819a16118acc010d0efdec90afbda14590 (patch)
tree2d2c35604af2e6a44c5f3ecb5c901a52980710d8 /development
parent0739618a61cfc383498e466f4fdeb5a25324598f (diff)
downloadtangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar.gz
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar.bz2
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar.lz
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar.xz
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.tar.zst
tangerine-wallet-browser-6bc8cc819a16118acc010d0efdec90afbda14590.zip
Merge branch 'develop' into i3725-refactor-send-component-
Diffstat (limited to 'development')
-rw-r--r--development/sourcemap-validator.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/development/sourcemap-validator.js b/development/sourcemap-validator.js
new file mode 100644
index 000000000..edc97667a
--- /dev/null
+++ b/development/sourcemap-validator.js
@@ -0,0 +1,49 @@
+const fs = require('fs')
+const { SourceMapConsumer } = require('source-map')
+
+//
+// Utility to help check if sourcemaps are working
+//
+// searches `dist/chrome/inpage.js` for "new Error" statements
+// and prints their source lines using the sourcemaps.
+// if not working it may error or print minified garbage
+//
+
+start()
+
+async function start() {
+ const rawBuild = fs.readFileSync(__dirname + '/../dist/chrome/inpage.js', 'utf8')
+ const rawSourceMap = fs.readFileSync(__dirname + '/../dist/sourcemaps/inpage.js.map', 'utf8')
+ const consumer = await new SourceMapConsumer(rawSourceMap)
+
+ console.log('hasContentsOfAllSources:', consumer.hasContentsOfAllSources(), '\n')
+ console.log('sources:')
+ consumer.sources.map((sourcePath) => console.log(sourcePath))
+
+ console.log('\nexamining "new Error" statements:\n')
+ const sourceLines = rawBuild.split('\n')
+ sourceLines.map(line => indicesOf('new Error', line))
+ .forEach((errorIndices, lineIndex) => {
+ // if (errorIndex === null) return console.log('line does not contain "new Error"')
+ errorIndices.forEach((errorIndex) => {
+ const position = { line: lineIndex + 1, column: errorIndex }
+ const result = consumer.originalPositionFor(position)
+ if (!result.source) return console.warn(`!! missing source for position: ${position}`)
+ // filter out deps distributed minified without sourcemaps
+ if (result.source === 'node_modules/browserify/node_modules/browser-pack/_prelude.js') return // minified mess
+ if (result.source === 'node_modules/web3/dist/web3.min.js') return // minified mess
+ const sourceContent = consumer.sourceContentFor(result.source)
+ const sourceLines = sourceContent.split('\n')
+ const line = sourceLines[result.line-1]
+ console.log(`\n========================== ${result.source} ====================================\n`)
+ console.log(line)
+ console.log(`\n==============================================================================\n`)
+ })
+ })
+}
+
+function indicesOf(substring, string) {
+ var a=[],i=-1;
+ while((i=string.indexOf(substring,i+1)) >= 0) a.push(i);
+ return a;
+}