@@ -5,7 +5,6 @@ import { common, object, type AstTypes } from '@sveltejs/cli-core/js';
5
5
import { parseScript } from '@sveltejs/cli-core/parsers' ;
6
6
import { detect } from 'package-manager-detector' ;
7
7
import type { OptionValues , PackageManager , Workspace } from '@sveltejs/cli-core' ;
8
- import { TESTING } from '../../utils/env.ts' ;
9
8
import { commonFilePaths , getPackageJson , readFile } from './utils.ts' ;
10
9
import { getUserAgent } from '../../utils/package-manager.ts' ;
11
10
@@ -20,18 +19,17 @@ export async function createWorkspace({
20
19
packageManager
21
20
} : CreateWorkspaceOptions ) : Promise < Workspace < any > > {
22
21
const resolvedCwd = path . resolve ( cwd ) ;
23
- const viteConfigPath = path . join ( resolvedCwd , commonFilePaths . viteConfigTS ) ;
24
- let usesTypescript = fs . existsSync ( viteConfigPath ) ;
25
22
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 ) ;
27
27
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 ;
35
33
36
34
let dependencies : Record < string , string > = { } ;
37
35
let directory = resolvedCwd ;
0 commit comments