| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1e37eab commit c89b67e
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,17 +112,12 @@ function serializeJSStackFrame(sm, callSite, callerCallSite) { | |||
| 112 | 112 | ||
| 113 | 113 | const typeName = callSite.getTypeName(); | |
| 114 | 114 | const namePrefix = typeName !== null && typeName !== 'global' ? `${typeName}.` : ''; | |
| 115 | - const originalName = `${namePrefix}${fnName || '<anonymous>'}`; | ||
| 116 | - // The original call site may have a different symbol name | ||
| 117 | - // associated with it, use it: | ||
| 118 | - const mappedName = (name && name !== originalName) ? | ||
| 119 | - `${name}` : | ||
| 120 | - `${originalName}`; | ||
| 121 | - const hasName = !!(name || originalName); | ||
| 115 | + const originalName = `${fnName || '<anonymous>'}`; | ||
| 116 | + const mappedName = `${namePrefix}${name || originalName}` || ''; | ||
| 122 | 117 | // Replace the transpiled call site with the original: | |
| 123 | - return `${prefix}${mappedName}${hasName ? ' (' : ''}` + | ||
| 118 | + return `${prefix}${mappedName} (` + | ||
| 124 | 119 | `${originalSourceNoScheme}:${originalLine + 1}:` + | |
| 125 | - `${originalColumn + 1}${hasName ? ')' : ''}`; | ||
| 120 | + `${originalColumn + 1})`; | ||
| 126 | 121 | } | |
| 127 | 122 | ||
| 128 | 123 | // Transpilers may have removed the original symbol name used in the stack | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Flags: --enable-source-maps | ||
| 4 | + | ||
| 5 | + require('../../../common'); | ||
| 6 | + Error.stackTraceLimit = 2; | ||
| 7 | + require('../throw-class-method.min.js'); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,6 @@ | |||
| 1 | + Error: This is a test | ||
| 2 | + at Foo.bar (*/test/fixtures/source-map/throw-class-method.js:3:11) | ||
| 3 | + at Object.<anonymous> (*/test/fixtures/source-map/throw-class-method.js:12:7) | ||
| 4 | + Error: This is a test | ||
| 5 | + at Bar.bar (*/test/fixtures/source-map/throw-class-method.js:3:11) | ||
| 6 | + at Object.<anonymous> (*/test/fixtures/source-map/throw-class-method.js:19:7) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + class Foo { | ||
| 2 | + bar() { | ||
| 3 | + throw Error('This is a test'); | ||
| 4 | + } | ||
| 5 | + } | ||
| 6 | + | ||
| 7 | + class Bar {} | ||
| 8 | + Bar.prototype.bar = Foo.prototype.bar; | ||
| 9 | + | ||
| 10 | + try { | ||
| 11 | + const foo = new Foo(); | ||
| 12 | + foo.bar(); | ||
| 13 | + } catch (e) { | ||
| 14 | + console.error(e); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + try { | ||
| 18 | + const bar = Object.create(Bar.prototype); | ||
| 19 | + bar.bar(); | ||
| 20 | + } catch (e) { | ||
| 21 | + console.error(e); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + // To recreate: | ||
| 25 | + // | ||
| 26 | + // cd test/fixtures/source-map | ||
| 27 | + // npx terser -o throw-class-method.min.js --source-map "url='throw-class-method.min.js.map'" throw-class-method.js | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () => | |||
| 27 | 27 | { name: 'source-map/output/source_map_sourcemapping_url_string.js' }, | |
| 28 | 28 | { name: 'source-map/output/source_map_throw_async_stack_trace.mjs' }, | |
| 29 | 29 | { name: 'source-map/output/source_map_throw_catch.js' }, | |
| 30 | + { name: 'source-map/output/source_map_throw_class_method.js' }, | ||
| 30 | 31 | { name: 'source-map/output/source_map_throw_construct.mjs' }, | |
| 31 | 32 | { name: 'source-map/output/source_map_throw_first_tick.js' }, | |
| 32 | 33 | { name: 'source-map/output/source_map_throw_icu.js' }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments