Skip to content

Commit 6d1a6e5

Browse files
committed
Optimize
1 parent 36cd484 commit 6d1a6e5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

lib/internal/modules/run_main.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const path = require('path');
1212
* @param {string} main - Entry point path
1313
*/
1414
function resolveMainPath(main) {
15+
if (getOptionValue('--preserve-symlinks-main')) { return; }
16+
1517
const defaultType = getOptionValue('--experimental-default-type');
1618
/** @type {string} */
1719
let mainPath;
@@ -25,21 +27,18 @@ function resolveMainPath(main) {
2527
}
2628
if (!mainPath) { return; }
2729

28-
const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
29-
if (!preserveSymlinksMain) {
30-
const { toRealPath } = require('internal/modules/helpers');
31-
try {
32-
mainPath = toRealPath(mainPath);
33-
} catch (err) {
34-
if (err.code === 'ENOENT' && defaultType === 'module') {
35-
const { decorateErrorWithCommonJSHints } = require('internal/modules/esm/resolve');
36-
const { getCWDURL } = require('internal/util');
37-
decorateErrorWithCommonJSHints(err, mainPath, getCWDURL());
38-
}
39-
throw err;
30+
// Follow symlinks
31+
const { toRealPath } = require('internal/modules/helpers');
32+
try {
33+
mainPath = toRealPath(mainPath);
34+
} catch (err) {
35+
if (err.code === 'ENOENT' && defaultType === 'module') {
36+
const { decorateErrorWithCommonJSHints } = require('internal/modules/esm/resolve');
37+
const { getCWDURL } = require('internal/util');
38+
decorateErrorWithCommonJSHints(err, mainPath, getCWDURL());
4039
}
40+
throw err;
4141
}
42-
4342
return mainPath;
4443
}
4544

0 commit comments

Comments
 (0)