File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 55 filename_dts_to ,
66 filename_js_to_dts ,
77 filename_ts_to_dts ,
8+ isRelative ,
89 RE_DTS ,
910 RE_JS ,
1011 RE_NODE_MODULES ,
@@ -206,10 +207,10 @@ export function createGeneratePlugin({
206207
207208 // link to the original module
208209 let resolution = await this . resolve ( id , filename_dts_to ( importer , 'ts' ) )
209- if ( ! resolution || resolution . external ) return resolution
210+ if ( ! resolution ) return
210211
211212 // resolve dependency
212- if ( RE_NODE_MODULES . test ( resolution . id ) ) {
213+ if ( RE_NODE_MODULES . test ( resolution . id ) || ! isRelative ( resolution . id ) ) {
213214 let shouldResolve : boolean
214215 if ( typeof resolve === 'boolean' ) {
215216 shouldResolve = resolve
@@ -224,6 +225,8 @@ export function createGeneratePlugin({
224225 } else {
225226 return { id, external : true , meta }
226227 }
228+ } else if ( resolution . external ) {
229+ return resolution
227230 }
228231
229232 let dtsId : string
Original file line number Diff line number Diff line change 1+ import path from 'node:path'
2+
13export const RE_JS : RegExp = / \. ( [ c m ] ? ) j s x ? $ /
24export const RE_TS : RegExp = / \. ( [ c m ] ? ) t s x ? $ /
35export const RE_DTS : RegExp = / \. d \. ( [ c m ] ? ) t s $ /
@@ -12,3 +14,7 @@ export function filename_ts_to_dts(id: string): string {
1214export function filename_dts_to ( id : string , ext : 'js' | 'ts' ) : string {
1315 return id . replace ( RE_DTS , `.$1${ ext } ` )
1416}
17+
18+ export function isRelative ( id : string ) : boolean {
19+ return path . isAbsolute ( id ) || id [ 0 ] === '.'
20+ }
You can’t perform that action at this time.
0 commit comments