File tree 1 file changed +12
-13
lines changed
1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ const path = require('path');
12
12
* @param {string } main - Entry point path
13
13
*/
14
14
function resolveMainPath ( main ) {
15
+ if ( getOptionValue ( '--preserve-symlinks-main' ) ) { return ; }
16
+
15
17
const defaultType = getOptionValue ( '--experimental-default-type' ) ;
16
18
/** @type {string } */
17
19
let mainPath ;
@@ -25,21 +27,18 @@ function resolveMainPath(main) {
25
27
}
26
28
if ( ! mainPath ) { return ; }
27
29
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 ( ) ) ;
40
39
}
40
+ throw err ;
41
41
}
42
-
43
42
return mainPath ;
44
43
}
45
44
You can’t perform that action at this time.
0 commit comments