Skip to content

Commit

Permalink
fix(turbopack): don't parse .ts files as .tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed Jan 29, 2024
1 parent 5cf4f87 commit 0b97987
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 50 deletions.
68 changes: 34 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ swc_core = { version = "0.89.4", features = [
testing = { version = "0.35.16" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240129.1" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", branch = "hrmny/pack-2302-dont-parse-ts-files-as-tsx" } # last tag: "turbopack-240129.1"
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240129.1" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", branch = "hrmny/pack-2302-dont-parse-ts-files-as-tsx" } # last tag: "turbopack-240129.1"
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240129.1" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", branch = "hrmny/pack-2302-dont-parse-ts-files-as-tsx" } # last tag: "turbopack-240129.1"

# General Deps

Expand Down
20 changes: 13 additions & 7 deletions packages/next-swc/crates/next-core/src/app_segment_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,19 @@ pub async fn parse_segment_config_from_source(

let result = &*parse(
source,
turbo_tasks::Value::new(
if path.path.ends_with(".ts") || path.path.ends_with(".tsx") {
EcmascriptModuleAssetType::Typescript
} else {
EcmascriptModuleAssetType::Ecmascript
},
),
turbo_tasks::Value::new(if path.path.ends_with(".ts") {
EcmascriptModuleAssetType::Typescript {
tsx: false,
analyze_types: false,
}
} else if path.path.ends_with(".tsx") {
EcmascriptModuleAssetType::Typescript {
tsx: true,
analyze_types: false,
}
} else {
EcmascriptModuleAssetType::Ecmascript
}),
EcmascriptInputTransforms::empty(),
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"@types/ws": "8.2.0",
"@vercel/ncc": "0.34.0",
"@vercel/nft": "0.26.2",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240129.1",
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?5b98e9c749436f16fb9b226edc01619d3f6d9245",
"acorn": "8.5.0",
"amphtml-validator": "1.0.35",
"anser": "1.4.9",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b97987

Please sign in to comment.