File tree 1 file changed +33
-1
lines changed
packages/@vue/cli/lib/util
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change
1
+ const semver = require ( 'semver' )
2
+
3
+ function resolveFallback ( request , options ) {
4
+ const Module = require ( 'module' )
5
+ const isMain = false
6
+ const fakeParent = new Module ( '' , null )
7
+
8
+ const paths = [ ]
9
+
10
+ for ( let i = 0 ; i < options . paths . length ; i ++ ) {
11
+ const path = options . paths [ i ]
12
+ fakeParent . paths = Module . _nodeModulePaths ( path )
13
+ const lookupPaths = Module . _resolveLookupPaths ( request , fakeParent , true )
14
+
15
+ if ( ! paths . includes ( path ) ) paths . push ( path )
16
+
17
+ for ( let j = 0 ; j < lookupPaths . length ; j ++ ) {
18
+ if ( ! paths . includes ( lookupPaths [ j ] ) ) paths . push ( lookupPaths [ j ] )
19
+ }
20
+ }
21
+
22
+ const filename = Module . _findPath ( request , paths , isMain )
23
+ if ( ! filename ) {
24
+ const err = new Error ( `Cannot find module '${ request } '` )
25
+ err . code = 'MODULE_NOT_FOUND'
26
+ throw err
27
+ }
28
+ return filename
29
+ }
30
+
31
+ const resolve = semver . satisfies ( process . version , '>=8.10.0' ) ? require . resolve : resolveFallback
32
+
1
33
exports . resolveModule = function ( request , context ) {
2
34
let resolvedPath
3
35
try {
4
- resolvedPath = require . resolve ( request , {
36
+ resolvedPath = resolve ( request , {
5
37
paths : [ context ]
6
38
} )
7
39
} catch ( e ) { }
You can’t perform that action at this time.
0 commit comments