| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18c057a commit 653b20b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,6 @@ class ModuleJob { | |||
| 14 | 14 | // `moduleProvider` is a function | |
| 15 | 15 | constructor(loader, url, moduleProvider, isMain) { | |
| 16 | 16 | this.loader = loader; | |
| 17 | - this.error = null; | ||
| 18 | - this.hadError = false; | ||
| 19 | 17 | this.isMain = isMain; | |
| 20 | 18 | ||
| 21 | 19 | // This is a Promise<{ module, reflect }>, whose fields will be copied | |
@@ -72,15 +70,7 @@ class ModuleJob { | |||
| 72 | 70 | const dependencyJobs = await moduleJob.linked; | |
| 73 | 71 | return Promise.all(dependencyJobs.map(addJobsToDependencyGraph)); | |
| 74 | 72 | }; | |
| 75 | - try { | ||
| 76 | - await addJobsToDependencyGraph(this); | ||
| 77 | - } catch (e) { | ||
| 78 | - if (!this.hadError) { | ||
| 79 | - this.error = e; | ||
| 80 | - this.hadError = true; | ||
| 81 | - } | ||
| 82 | - throw e; | ||
| 83 | - } | ||
| 73 | + await addJobsToDependencyGraph(this); | ||
| 84 | 74 | try { | |
| 85 | 75 | if (this.isMain && process._breakFirstLine) { | |
| 86 | 76 | delete process._breakFirstLine; | |
@@ -103,13 +93,7 @@ class ModuleJob { | |||
| 103 | 93 | ||
| 104 | 94 | async run() { | |
| 105 | 95 | const module = await this.instantiate(); | |
| 106 | - try { | ||
| 107 | - module.evaluate(-1, false); | ||
| 108 | - } catch (e) { | ||
| 109 | - this.hadError = true; | ||
| 110 | - this.error = e; | ||
| 111 | - throw e; | ||
| 112 | - } | ||
| 96 | + module.evaluate(-1, false); | ||
| 113 | 97 | return module; | |
| 114 | 98 | } | |
| 115 | 99 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Flags: --experimental-modules | ||
| 4 | + | ||
| 5 | + const common = require('../common'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + | ||
| 8 | + common.crashOnUnhandledRejection(); | ||
| 9 | + | ||
| 10 | + const file = '../../fixtures/syntax/bad_syntax.js'; | ||
| 11 | + | ||
| 12 | + let error; | ||
| 13 | + (async () => { | ||
| 14 | + try { | ||
| 15 | + await import(file); | ||
| 16 | + } catch (e) { | ||
| 17 | + assert.strictEqual(e.name, 'SyntaxError'); | ||
| 18 | + error = e; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + assert(error); | ||
| 22 | + | ||
| 23 | + try { | ||
| 24 | + await import(file); | ||
| 25 | + } catch (e) { | ||
| 26 | + assert.strictEqual(error, e); | ||
| 27 | + } | ||
| 28 | + })(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments