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 {
1717 tsExtensionsPattern ,
1818 getFormatFromFileUrl ,
1919 fileProtocol ,
20+ isJsonPattern ,
2021 type MaybePromise ,
2122 type NodeError ,
2223} from './utils.js' ;
@@ -32,7 +33,7 @@ const _getFormat: getFormat = async function (
3233 context ,
3334 defaultGetFormat ,
3435) {
35- if ( url . endsWith ( '.json' ) ) {
36+ if ( isJsonPattern . test ( url ) ) {
3637 return { format : 'module' } ;
3738 }
3839
@@ -80,7 +81,7 @@ const _transformSource: transformSource = async function (
8081 }
8182
8283 if (
83- url . endsWith ( '.json' )
84+ isJsonPattern . test ( url )
8485 || tsExtensionsPattern . test ( url )
8586 ) {
8687 const transformed = await transform (
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ import {
1616 tsconfigPathsMatcher ,
1717 fileMatcher ,
1818 tsExtensionsPattern ,
19+ isJsonPattern ,
1920 getFormatFromFileUrl ,
2021 fileProtocol ,
2122 type MaybePromise ,
2223 type NodeError ,
2324} from './utils.js' ;
2425
25- const isJsonPattern = / \. j s o n (?: $ | \? ) / ;
2626const isDirectoryPattern = / \/ (?: $ | \? ) / ;
2727
2828type NextResolve = (
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ export const fileProtocol = 'file://';
2727
2828export const tsExtensionsPattern = / \. ( [ c m ] ? t s | [ t j ] s x ) ( $ | \? ) / ;
2929
30+ export const isJsonPattern = / \. j s o n (?: $ | \? ) / ;
31+
3032const getFormatFromExtension = ( fileUrl : string ) : ModuleFormat | undefined => {
3133 const extension = path . extname ( fileUrl ) ;
3234
You can’t perform that action at this time.
0 commit comments