File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
packages/@vue/cli/lib/util Expand file tree Collapse file tree 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+
133exports . resolveModule = function ( request , context ) {
234 let resolvedPath
335 try {
4- resolvedPath = require . resolve ( request , {
36+ resolvedPath = resolve ( request , {
537 paths : [ context ]
638 } )
739 } catch ( e ) { }
You can’t perform that action at this time.
0 commit comments