| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1996580 commit dc855af
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,9 @@ const { | |||
| 24 | 24 | const { ModuleWrap } = internalBinding('module_wrap'); | |
| 25 | 25 | ||
| 26 | 26 | const { decorateErrorStack } = require('internal/util'); | |
| 27 | + const { | ||
| 28 | + getSourceMapsEnabled, | ||
| 29 | + } = require('internal/source_map/source_map_cache'); | ||
| 27 | 30 | const assert = require('internal/assert'); | |
| 28 | 31 | const resolvedPromise = PromiseResolve(); | |
| 29 | 32 | ||
@@ -122,7 +125,12 @@ class ModuleJob { | |||
| 122 | 125 | } | |
| 123 | 126 | } catch (e) { | |
| 124 | 127 | decorateErrorStack(e); | |
| 125 | - if (StringPrototypeIncludes(e.message, | ||
| 128 | + // TODO(@bcoe): Add source map support to exception that occurs as result | ||
| 129 | + // of missing named export. This is currently not possible because | ||
| 130 | + // stack trace originates in module_job, not the file itself. A hidden | ||
| 131 | + // symbol with filename could be set in node_errors.cc to facilitate this. | ||
| 132 | + if (!getSourceMapsEnabled() && | ||
| 133 | + StringPrototypeIncludes(e.message, | ||
| 126 | 134 | ' does not provide an export named')) { | |
| 127 | 135 | const splitStack = StringPrototypeSplit(e.stack, '\n'); | |
| 128 | 136 | const parentFileUrl = splitStack[0]; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + import { Something } from './esm-export-missing-module.mjs'; | ||
| 2 | + //# sourceMappingURL=esm-export-missing.mjs.map | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + | ||
| 2 | + import { Something } from './exm-export-missing-module.mjs'; | ||
| 3 | + console.info(Something); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -324,6 +324,25 @@ function nextdir() { | |||
| 324 | 324 | assert.ok(sourceMap); | |
| 325 | 325 | } | |
| 326 | 326 | ||
| 327 | + // Does not throw TypeError when exception occurs as result of missing named | ||
| 328 | + // export. | ||
| 329 | + { | ||
| 330 | + const coverageDirectory = nextdir(); | ||
| 331 | + const output = spawnSync(process.execPath, [ | ||
| 332 | + '--enable-source-maps', | ||
| 333 | + require.resolve('../fixtures/source-map/esm-export-missing.mjs'), | ||
| 334 | + ], { env: { ...process.env, NODE_V8_COVERAGE: coverageDirectory } }); | ||
| 335 | + const sourceMap = getSourceMapFromCache( | ||
| 336 | + 'esm-export-missing.mjs', | ||
| 337 | + coverageDirectory | ||
| 338 | + ); | ||
| 339 | + // Module loader error displayed. | ||
| 340 | + assert.match(output.stderr.toString(), | ||
| 341 | + /does not provide an export named 'Something'/); | ||
| 342 | + // Source map should have been serialized. | ||
| 343 | + assert.ok(sourceMap); | ||
| 344 | + } | ||
| 345 | + | ||
| 327 | 346 | function getSourceMapFromCache(fixtureFile, coverageDirectory) { | |
| 328 | 347 | const jsonFiles = fs.readdirSync(coverageDirectory); | |
| 329 | 348 | for (const jsonFile of jsonFiles) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments