@@ -5,7 +5,6 @@ import { common, object, type AstTypes } from '@sveltejs/cli-core/js';
55import { parseScript } from '@sveltejs/cli-core/parsers' ;
66import { detect } from 'package-manager-detector' ;
77import type { OptionValues , PackageManager , Workspace } from '@sveltejs/cli-core' ;
8- import { TESTING } from '../../utils/env.ts' ;
98import { commonFilePaths , getPackageJson , readFile } from './utils.ts' ;
109import { getUserAgent } from '../../utils/package-manager.ts' ;
1110
@@ -20,18 +19,17 @@ export async function createWorkspace({
2019 packageManager
2120} : CreateWorkspaceOptions ) : Promise < Workspace < any > > {
2221 const resolvedCwd = path . resolve ( cwd ) ;
23- const viteConfigPath = path . join ( resolvedCwd , commonFilePaths . viteConfigTS ) ;
24- let usesTypescript = fs . existsSync ( viteConfigPath ) ;
2522
26- const viteConfigFile = usesTypescript ? commonFilePaths . viteConfigTS : commonFilePaths . viteConfig ;
23+ // Will go up and prioritize jsconfig.json as it's first in the array
24+ const tjsconfig = find . any ( [ commonFilePaths . jsconfig , commonFilePaths . tsconfig ] , { cwd } ) ;
25+ // If the file is not ending with jsconfig.json, then we are using typescript
26+ const usesTypescript = ! tjsconfig ?. endsWith ( commonFilePaths . jsconfig ) ;
2727
28- if ( TESTING ) {
29- // while executing tests, we only look into the direct `cwd`
30- // as we might detect the monorepo `tsconfig.json` otherwise.
31- usesTypescript ||= fs . existsSync ( path . join ( resolvedCwd , commonFilePaths . tsconfig ) ) ;
32- } else {
33- usesTypescript ||= find . up ( commonFilePaths . tsconfig , { cwd } ) !== undefined ;
34- }
28+ // This is not linked with typescript detection
29+ const viteConfigPath = path . join ( resolvedCwd , commonFilePaths . viteConfigTS ) ;
30+ const viteConfigFile = fs . existsSync ( viteConfigPath )
31+ ? commonFilePaths . viteConfigTS
32+ : commonFilePaths . viteConfig ;
3533
3634 let dependencies : Record < string , string > = { } ;
3735 let directory = resolvedCwd ;
0 commit comments