@@ -107,8 +107,13 @@ const builtins = new Set([
107
107
'wasi' ,
108
108
] )
109
109
110
+ const NODE_BUILTIN_NAMESPACE = 'node:'
110
111
export function isBuiltin ( id : string ) : boolean {
111
- return builtins . has ( id . replace ( / ^ n o d e : / , '' ) )
112
+ return builtins . has (
113
+ id . startsWith ( NODE_BUILTIN_NAMESPACE )
114
+ ? id . slice ( NODE_BUILTIN_NAMESPACE . length )
115
+ : id ,
116
+ )
112
117
}
113
118
114
119
export function moduleListContains (
@@ -282,8 +287,10 @@ const knownTsOutputRE = /\.(?:js|mjs|cjs|jsx)$/
282
287
export const isTsRequest = ( url : string ) : boolean => knownTsRE . test ( url )
283
288
export const isPossibleTsOutput = ( url : string ) : boolean =>
284
289
knownTsOutputRE . test ( cleanUrl ( url ) )
290
+
291
+ const splitFilePathAndQueryRE = / ( \. (?: [ c m ] ? j s | j s x ) ) ( \? .* ) ? $ /
285
292
export function getPotentialTsSrcPaths ( filePath : string ) : string [ ] {
286
- const [ name , type , query = '' ] = filePath . split ( / ( \. (?: [ c m ] ? j s | j s x ) ) ( \? . * ) ? $ / )
293
+ const [ name , type , query = '' ] = filePath . split ( splitFilePathAndQueryRE )
287
294
const paths = [ name + type . replace ( 'js' , 'ts' ) + query ]
288
295
if ( ! type . endsWith ( 'x' ) ) {
289
296
paths . push ( name + type . replace ( 'js' , 'tsx' ) + query )
@@ -1250,7 +1257,7 @@ export function stripBase(path: string, base: string): string {
1250
1257
return '/'
1251
1258
}
1252
1259
const devBase = base . endsWith ( '/' ) ? base : base + '/'
1253
- return path . replace ( RegExp ( '^' + devBase ) , '/' )
1260
+ return path . startsWith ( devBase ) ? path . slice ( devBase . length - 1 ) : path
1254
1261
}
1255
1262
1256
1263
export function arrayEqual ( a : any [ ] , b : any [ ] ) : boolean {
0 commit comments