| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent baa280a commit c6b2f56
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,15 +4,15 @@ const { | |||
| 4 | 4 | ObjectCreate, | |
| 5 | 5 | StringPrototypeEndsWith, | |
| 6 | 6 | } = primordials; | |
| 7 | - const CJSLoader = require('internal/modules/cjs/loader'); | ||
| 8 | - const { Module, toRealPath, readPackageScope } = CJSLoader; | ||
| 7 | + | ||
| 9 | 8 | const { getOptionValue } = require('internal/options'); | |
| 10 | 9 | const path = require('path'); | |
| 11 | 10 | ||
| 12 | 11 | function resolveMainPath(main) { | |
| 13 | 12 | // Note extension resolution for the main entry point can be deprecated in a | |
| 14 | 13 | // future major. | |
| 15 | 14 | // Module._findPath is monkey-patchable here. | |
| 15 | + const { Module, toRealPath } = require('internal/modules/cjs/loader'); | ||
| 16 | 16 | let mainPath = Module._findPath(path.resolve(main), null, true); | |
| 17 | 17 | if (!mainPath) | |
| 18 | 18 | return; | |
@@ -41,6 +41,7 @@ function shouldUseESMLoader(mainPath) { | |||
| 41 | 41 | getOptionValue('--experimental-specifier-resolution'); | |
| 42 | 42 | if (esModuleSpecifierResolution === 'node') | |
| 43 | 43 | return true; | |
| 44 | + const { readPackageScope } = require('internal/modules/cjs/loader'); | ||
| 44 | 45 | // Determine the module format of the main | |
| 45 | 46 | if (mainPath && StringPrototypeEndsWith(mainPath, '.mjs')) | |
| 46 | 47 | return true; | |
@@ -83,6 +84,7 @@ function executeUserEntryPoint(main = process.argv[1]) { | |||
| 83 | 84 | runMainESM(resolvedMain || main); | |
| 84 | 85 | } else { | |
| 85 | 86 | // Module._load is the monkey-patchable CJS module loader. | |
| 87 | + const { Module } = require('internal/modules/cjs/loader'); | ||
| 86 | 88 | Module._load(main, null, true); | |
| 87 | 89 | } | |
| 88 | 90 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ Error: Should include grayed stack trace | |||
| 8 | 8 | [90m at Module._extensions..js (node:internal*modules*cjs*loader:1310:10)[39m | |
| 9 | 9 | [90m at Module.load (node:internal*modules*cjs*loader:1119:32)[39m | |
| 10 | 10 | [90m at Module._load (node:internal*modules*cjs*loader:960:12)[39m | |
| 11 | - [90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:86:12)[39m | ||
| 11 | + [90m at Function.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:88:12)[39m | ||
| 12 | 12 | [90m at node:internal*main*run_main_module:23:47[39m | |
| 13 | 13 | ||
| 14 | 14 | Node.js * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments