This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
17
17
tsExtensionsPattern ,
18
18
getFormatFromFileUrl ,
19
19
fileProtocol ,
20
+ isJsonPattern ,
20
21
type MaybePromise ,
21
22
type NodeError ,
22
23
} from './utils.js' ;
@@ -32,7 +33,7 @@ const _getFormat: getFormat = async function (
32
33
context ,
33
34
defaultGetFormat ,
34
35
) {
35
- if ( url . endsWith ( '.json' ) ) {
36
+ if ( isJsonPattern . test ( url ) ) {
36
37
return { format : 'module' } ;
37
38
}
38
39
@@ -80,7 +81,7 @@ const _transformSource: transformSource = async function (
80
81
}
81
82
82
83
if (
83
- url . endsWith ( '.json' )
84
+ isJsonPattern . test ( url )
84
85
|| tsExtensionsPattern . test ( url )
85
86
) {
86
87
const transformed = await transform (
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ import {
16
16
tsconfigPathsMatcher ,
17
17
fileMatcher ,
18
18
tsExtensionsPattern ,
19
+ isJsonPattern ,
19
20
getFormatFromFileUrl ,
20
21
fileProtocol ,
21
22
type MaybePromise ,
22
23
type NodeError ,
23
24
} from './utils.js' ;
24
25
25
- const isJsonPattern = / \. j s o n (?: $ | \? ) / ;
26
26
const isDirectoryPattern = / \/ (?: $ | \? ) / ;
27
27
28
28
type NextResolve = (
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ export const fileProtocol = 'file://';
27
27
28
28
export const tsExtensionsPattern = / \. ( [ c m ] ? t s | [ t j ] s x ) ( $ | \? ) / ;
29
29
30
+ export const isJsonPattern = / \. j s o n (?: $ | \? ) / ;
31
+
30
32
const getFormatFromExtension = ( fileUrl : string ) : ModuleFormat | undefined => {
31
33
const extension = path . extname ( fileUrl ) ;
32
34
You can’t perform that action at this time.
0 commit comments