Skip to content

Commit a8fa2bb

Browse files
authored
Add support for jsconfig.json resolution (#3409)
There doesn't appear to be any issues with just returning a `jsconfig.json` when we're looking for a `tsconfig.json` (provided one didn't exist). Finding this gives a `TsConfigReferenceVc` (used for finding type definitions only) and enables the `paths`/`baseUrl` resolution options. Fixes WEB-230
1 parent 2a8832b commit a8fa2bb

14 files changed

+1153
-20
lines changed

crates/turbopack-ecmascript/src/references/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ pub(crate) async fn analyze_ecmascript_module(
423423
this: JsValue,
424424
args: Vec<JsValue>,
425425
link_value: &'a F,
426-
analyze_types: bool,
427426
analysis: &'a mut AnalyzeEcmascriptModuleResultBuilder,
428427
environment: EnvironmentVc,
429428
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>> {
@@ -437,7 +436,6 @@ pub(crate) async fn analyze_ecmascript_module(
437436
this,
438437
args,
439438
link_value,
440-
analyze_types,
441439
analysis,
442440
environment,
443441
))
@@ -456,7 +454,6 @@ pub(crate) async fn analyze_ecmascript_module(
456454
this: JsValue,
457455
args: Vec<JsValue>,
458456
link_value: &F,
459-
analyze_types: bool,
460457
analysis: &mut AnalyzeEcmascriptModuleResultBuilder,
461458
environment: EnvironmentVc,
462459
) -> Result<()> {
@@ -477,7 +474,6 @@ pub(crate) async fn analyze_ecmascript_module(
477474
this.clone(),
478475
args.clone(),
479476
link_value,
480-
analyze_types,
481477
analysis,
482478
environment,
483479
)
@@ -503,7 +499,6 @@ pub(crate) async fn analyze_ecmascript_module(
503499
JsValue::Unknown(None, "no this provided"),
504500
args,
505501
link_value,
506-
analyze_types,
507502
analysis,
508503
environment,
509504
)
@@ -1104,7 +1099,6 @@ pub(crate) async fn analyze_ecmascript_module(
11041099
JsValue::Unknown(None, "no this provided"),
11051100
args,
11061101
&link_value,
1107-
analyze_types,
11081102
&mut analysis,
11091103
environment,
11101104
)
@@ -1135,7 +1129,6 @@ pub(crate) async fn analyze_ecmascript_module(
11351129
obj,
11361130
args,
11371131
&link_value,
1138-
analyze_types,
11391132
&mut analysis,
11401133
environment,
11411134
)

crates/turbopack-ecmascript/src/typescript/resolve.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ pub async fn tsconfig_resolve_options(
216216

217217
#[turbo_tasks::function]
218218
pub fn tsconfig() -> StringsVc {
219-
StringsVc::cell(vec!["tsconfig.json".to_string()])
219+
StringsVc::cell(vec![
220+
"tsconfig.json".to_string(),
221+
"jsconfig.json".to_string(),
222+
])
220223
}
221224

222225
#[turbo_tasks::function]

crates/turbopack-tests/tests/snapshot/tsconfig/baseurl/output/crates_turbopack-tests_tests_snapshot_tsconfig_baseurl_input_index_5906e5.js.map

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { prop as globalFoo } from "foo";
2+
import { prop as localFoo } from "./foo";
3+
import { prop as atFoo } from "@/foo";
4+
5+
console.log(globalFoo, localFoo, atFoo);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"foo": ["./prop"],
6+
"./foo": ["./prop"],
7+
"@/*": ["./*"],
8+
}
9+
},
10+
"include": ["./*.ts"]
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const prop = 1;

0 commit comments

Comments
 (0)