9
9
"use strict"
10
10
11
11
const path = require ( "path" )
12
- const resolver = require ( "enhanced-resolve" )
13
12
const getPackageJson = require ( "../util/get-package-json" )
14
13
const mergeVisitorsInPlace = require ( "../util/merge-visitors-in-place" )
15
14
const visitImport = require ( "../util/visit-import" )
@@ -25,15 +24,17 @@ const CORE_MODULES = new Set([
25
24
"crypto" ,
26
25
"dgram" ,
27
26
"dns" ,
28
- /* "domain", */ "events" ,
27
+ /* "domain", */
28
+ "events" ,
29
29
"fs" ,
30
30
"http" ,
31
31
"https" ,
32
32
"module" ,
33
33
"net" ,
34
34
"os" ,
35
35
"path" ,
36
- /* "punycode", */ "querystring" ,
36
+ /* "punycode", */
37
+ "querystring" ,
37
38
"readline" ,
38
39
"repl" ,
39
40
"stream" ,
@@ -112,10 +113,6 @@ module.exports = {
112
113
) ,
113
114
{
114
115
"Program:exit" ( ) {
115
- const requireResolve = resolver . create . sync ( {
116
- conditionNames : [ "node" , "import" , "require" ] ,
117
- } )
118
-
119
116
for ( const target of targets . filter (
120
117
t =>
121
118
CORE_MODULES . has ( t . moduleName ) &&
@@ -131,22 +128,20 @@ module.exports = {
131
128
continue
132
129
}
133
130
134
- try {
135
- const resolved = requireResolve ( dirPath , `${ name } /` )
136
-
137
- context . report ( {
138
- node : target . node ,
139
- loc : target . node . loc ,
140
- messageId : "unexpectedImport" ,
141
- data : {
142
- name : path
143
- . relative ( dirPath , resolved )
144
- . replace ( BACK_SLASH , "/" ) ,
145
- } ,
146
- } )
147
- } catch {
131
+ if ( target . filePath == null ) {
148
132
continue
149
133
}
134
+
135
+ context . report ( {
136
+ node : target . node ,
137
+ loc : target . node . loc ,
138
+ messageId : "unexpectedImport" ,
139
+ data : {
140
+ name : path
141
+ . relative ( dirPath , target . filePath )
142
+ . replace ( BACK_SLASH , "/" ) ,
143
+ } ,
144
+ } )
150
145
}
151
146
} ,
152
147
} ,
0 commit comments