| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ffc29c1 commit a75e44d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,12 +110,7 @@ class Loader { | |||
| 110 | 110 | loaderInstance = translators.get(format); | |
| 111 | 111 | } | |
| 112 | 112 | ||
| 113 | - let inspectBrk = false; | ||
| 114 | - if (process._breakFirstLine) { | ||
| 115 | - delete process._breakFirstLine; | ||
| 116 | - inspectBrk = true; | ||
| 117 | - } | ||
| 118 | - job = new ModuleJob(this, url, loaderInstance, inspectBrk); | ||
| 113 | + job = new ModuleJob(this, url, loaderInstance, parentURL === undefined); | ||
| 119 | 114 | this.moduleMap.set(url, job); | |
| 120 | 115 | return job; | |
| 121 | 116 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,15 +12,15 @@ const resolvedPromise = SafePromise.resolve(); | |||
| 12 | 12 | class ModuleJob { | |
| 13 | 13 | // `loader` is the Loader instance used for loading dependencies. | |
| 14 | 14 | // `moduleProvider` is a function | |
| 15 | - constructor(loader, url, moduleProvider, inspectBrk) { | ||
| 15 | + constructor(loader, url, moduleProvider, isMain) { | ||
| 16 | 16 | this.loader = loader; | |
| 17 | 17 | this.error = null; | |
| 18 | 18 | this.hadError = false; | |
| 19 | - this.inspectBrk = inspectBrk; | ||
| 19 | + this.isMain = isMain; | ||
| 20 | 20 | ||
| 21 | 21 | // This is a Promise<{ module, reflect }>, whose fields will be copied | |
| 22 | 22 | // onto `this` by `link()` below once it has been resolved. | |
| 23 | - this.modulePromise = moduleProvider(url); | ||
| 23 | + this.modulePromise = moduleProvider(url, isMain); | ||
| 24 | 24 | this.module = undefined; | |
| 25 | 25 | this.reflect = undefined; | |
| 26 | 26 | ||
@@ -82,7 +82,8 @@ class ModuleJob { | |||
| 82 | 82 | throw e; | |
| 83 | 83 | } | |
| 84 | 84 | try { | |
| 85 | - if (this.inspectBrk) { | ||
| 85 | + if (this.isMain && process._breakFirstLine) { | ||
| 86 | + delete process._breakFirstLine; | ||
| 86 | 87 | const initWrapper = process.binding('inspector').callAndPauseOnStart; | |
| 87 | 88 | initWrapper(this.module.instantiate, this.module); | |
| 88 | 89 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ translators.set('esm', async (url) => { | |||
| 36 | 36 | // Strategy for loading a node-style CommonJS module | |
| 37 | 37 | const isWindows = process.platform === 'win32'; | |
| 38 | 38 | const winSepRegEx = /\//g; | |
| 39 | - translators.set('cjs', async (url) => { | ||
| 39 | + translators.set('cjs', async (url, isMain) => { | ||
| 40 | 40 | debug(`Translating CJSModule ${url}`); | |
| 41 | 41 | const pathname = internalURLModule.getPathFromURL(new URL(url)); | |
| 42 | 42 | const module = CJSModule._cache[ | |
@@ -51,7 +51,7 @@ translators.set('cjs', async (url) => { | |||
| 51 | 51 | // we don't care about the return val of _load here because Module#load | |
| 52 | 52 | // will handle it for us by checking the loader registry and filling the | |
| 53 | 53 | // exports like above | |
| 54 | - CJSModule._load(pathname); | ||
| 54 | + CJSModule._load(pathname, undefined, isMain); | ||
| 55 | 55 | }); | |
| 56 | 56 | }); | |
| 57 | 57 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,6 @@ | |||
| 1 | + // Flags: --experimental-modules | ||
| 2 | + 'use strict'; | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + exports.asdf = 'asdf'; | ||
| 6 | + assert.strictEqual(require.main.exports.asdf, 'asdf'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments