Unverified Commit af962cb2 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Turbopack: Remove passing jsConfig (#83331)

## What?

These values were only provided to emit events and not for the actual
handling of jsconfig/tsconfig `paths` and such, those are handled
separately by Turbopack itself. This removes the events as they're no
longer relevant and it's not worth slowing down dev/build for them.
parent 07847a4b
...@@ -146,9 +146,6 @@ pub struct NapiProjectOptions { ...@@ -146,9 +146,6 @@ pub struct NapiProjectOptions {
/// The contents of next.config.js, serialized to JSON. /// The contents of next.config.js, serialized to JSON.
pub next_config: RcStr, pub next_config: RcStr,
/// The contents of ts/config read by load-jsconfig, serialized to JSON.
pub js_config: RcStr,
/// A map of environment variables to use when compiling code. /// A map of environment variables to use when compiling code.
pub env: Vec<NapiEnvVar>, pub env: Vec<NapiEnvVar>,
...@@ -204,9 +201,6 @@ pub struct NapiPartialProjectOptions { ...@@ -204,9 +201,6 @@ pub struct NapiPartialProjectOptions {
/// The contents of next.config.js, serialized to JSON. /// The contents of next.config.js, serialized to JSON.
pub next_config: Option<RcStr>, pub next_config: Option<RcStr>,
/// The contents of ts/config read by load-jsconfig, serialized to JSON.
pub js_config: Option<RcStr>,
/// A map of environment variables to use when compiling code. /// A map of environment variables to use when compiling code.
pub env: Option<Vec<NapiEnvVar>>, pub env: Option<Vec<NapiEnvVar>>,
...@@ -276,7 +270,6 @@ impl From<NapiProjectOptions> for ProjectOptions { ...@@ -276,7 +270,6 @@ impl From<NapiProjectOptions> for ProjectOptions {
project_path: val.project_path, project_path: val.project_path,
watch: val.watch.into(), watch: val.watch.into(),
next_config: val.next_config, next_config: val.next_config,
js_config: val.js_config,
env: val env: val
.env .env
.into_iter() .into_iter()
...@@ -301,7 +294,6 @@ impl From<NapiPartialProjectOptions> for PartialProjectOptions { ...@@ -301,7 +294,6 @@ impl From<NapiPartialProjectOptions> for PartialProjectOptions {
project_path: val.project_path, project_path: val.project_path,
watch: val.watch.map(From::from), watch: val.watch.map(From::from),
next_config: val.next_config, next_config: val.next_config,
js_config: val.js_config,
env: val env: val
.env .env
.map(|env| env.into_iter().map(|var| (var.name, var.value)).collect()), .map(|env| env.into_iter().map(|var| (var.name, var.value)).collect()),
......
...@@ -192,7 +192,6 @@ impl HmrBenchmark { ...@@ -192,7 +192,6 @@ impl HmrBenchmark {
root_path: RcStr::from(root_path), root_path: RcStr::from(root_path),
project_path: RcStr::from(project_path.clone()), project_path: RcStr::from(project_path.clone()),
next_config: load_next_config(), next_config: load_next_config(),
js_config: rcstr!("{}"),
env: vec![], env: vec![],
define_env: DefineEnv { define_env: DefineEnv {
client: vec![], client: vec![],
......
...@@ -13,7 +13,7 @@ use next_core::{ ...@@ -13,7 +13,7 @@ use next_core::{
next_client::{ next_client::{
ClientChunkingContextOptions, get_client_chunking_context, get_client_compile_time_info, ClientChunkingContextOptions, get_client_chunking_context, get_client_compile_time_info,
}, },
next_config::{JsConfig, ModuleIds as ModuleIdStrategyConfig, NextConfig}, next_config::{ModuleIds as ModuleIdStrategyConfig, NextConfig},
next_edge::context::EdgeChunkingContextOptions, next_edge::context::EdgeChunkingContextOptions,
next_server::{ next_server::{
ServerChunkingContextOptions, ServerContextType, get_server_chunking_context, ServerChunkingContextOptions, ServerContextType, get_server_chunking_context,
...@@ -160,9 +160,6 @@ pub struct ProjectOptions { ...@@ -160,9 +160,6 @@ pub struct ProjectOptions {
/// The contents of next.config.js, serialized to JSON. /// The contents of next.config.js, serialized to JSON.
pub next_config: RcStr, pub next_config: RcStr,
/// The contents of ts/config read by load-jsconfig, serialized to JSON.
pub js_config: RcStr,
/// A map of environment variables to use when compiling code. /// A map of environment variables to use when compiling code.
pub env: Vec<(RcStr, RcStr)>, pub env: Vec<(RcStr, RcStr)>,
...@@ -212,9 +209,6 @@ pub struct PartialProjectOptions { ...@@ -212,9 +209,6 @@ pub struct PartialProjectOptions {
/// The contents of next.config.js, serialized to JSON. /// The contents of next.config.js, serialized to JSON.
pub next_config: Option<RcStr>, pub next_config: Option<RcStr>,
/// The contents of ts/config read by load-jsconfig, serialized to JSON.
pub js_config: Option<RcStr>,
/// A map of environment variables to use when compiling code. /// A map of environment variables to use when compiling code.
pub env: Option<Vec<(RcStr, RcStr)>>, pub env: Option<Vec<(RcStr, RcStr)>>,
...@@ -341,7 +335,6 @@ impl ProjectContainer { ...@@ -341,7 +335,6 @@ impl ProjectContainer {
root_path, root_path,
project_path, project_path,
next_config, next_config,
js_config,
env, env,
define_env, define_env,
watch, watch,
...@@ -368,9 +361,6 @@ impl ProjectContainer { ...@@ -368,9 +361,6 @@ impl ProjectContainer {
if let Some(next_config) = next_config { if let Some(next_config) = next_config {
new_options.next_config = next_config; new_options.next_config = next_config;
} }
if let Some(js_config) = js_config {
new_options.js_config = js_config;
}
if let Some(env) = env { if let Some(env) = env {
new_options.env = env; new_options.env = env;
} }
...@@ -443,7 +433,6 @@ impl ProjectContainer { ...@@ -443,7 +433,6 @@ impl ProjectContainer {
let env_map: Vc<EnvMap>; let env_map: Vc<EnvMap>;
let next_config; let next_config;
let define_env; let define_env;
let js_config;
let root_path; let root_path;
let project_path; let project_path;
let watch; let watch;
...@@ -467,7 +456,6 @@ impl ProjectContainer { ...@@ -467,7 +456,6 @@ impl ProjectContainer {
} }
.cell(); .cell();
next_config = NextConfig::from_string(Vc::cell(options.next_config.clone())); next_config = NextConfig::from_string(Vc::cell(options.next_config.clone()));
js_config = JsConfig::from_string(Vc::cell(options.js_config.clone()));
root_path = options.root_path.clone(); root_path = options.root_path.clone();
project_path = options.project_path.clone(); project_path = options.project_path.clone();
watch = options.watch; watch = options.watch;
...@@ -491,7 +479,6 @@ impl ProjectContainer { ...@@ -491,7 +479,6 @@ impl ProjectContainer {
project_path, project_path,
watch, watch,
next_config: next_config.to_resolved().await?, next_config: next_config.to_resolved().await?,
js_config: js_config.to_resolved().await?,
dist_dir, dist_dir,
env: ResolvedVc::upcast(env_map.to_resolved().await?), env: ResolvedVc::upcast(env_map.to_resolved().await?),
define_env: define_env.to_resolved().await?, define_env: define_env.to_resolved().await?,
...@@ -562,9 +549,6 @@ pub struct Project { ...@@ -562,9 +549,6 @@ pub struct Project {
/// Next config. /// Next config.
next_config: ResolvedVc<NextConfig>, next_config: ResolvedVc<NextConfig>,
/// Js/Tsconfig read by load-jsconfig
js_config: ResolvedVc<JsConfig>,
/// A map of environment variables to use when compiling code. /// A map of environment variables to use when compiling code.
env: ResolvedVc<Box<dyn ProcessEnv>>, env: ResolvedVc<Box<dyn ProcessEnv>>,
...@@ -796,11 +780,6 @@ impl Project { ...@@ -796,11 +780,6 @@ impl Project {
Ok(Vc::cell(*self.mode.await? == NextMode::Development)) Ok(Vc::cell(*self.mode.await? == NextMode::Development))
} }
#[turbo_tasks::function]
pub(super) fn js_config(&self) -> Vc<JsConfig> {
*self.js_config
}
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn encryption_key(&self) -> Vc<RcStr> { pub(super) fn encryption_key(&self) -> Vc<RcStr> {
Vc::cell(self.encryption_key.clone()) Vc::cell(self.encryption_key.clone())
...@@ -1138,21 +1117,6 @@ impl Project { ...@@ -1138,21 +1117,6 @@ impl Project {
// it is always using SWC so we don't check swc here. // it is always using SWC so we don't check swc here.
emit_event(env!("VERGEN_CARGO_TARGET_TRIPLE"), true); emit_event(env!("VERGEN_CARGO_TARGET_TRIPLE"), true);
// Go over jsconfig and report enabled features.
let compiler_options = self.js_config().compiler_options().await?;
let compiler_options = compiler_options.as_object();
let experimental_decorators_enabled = compiler_options
.as_ref()
.and_then(|compiler_options| compiler_options.get("experimentalDecorators"))
.is_some();
let jsx_import_source_enabled = compiler_options
.as_ref()
.and_then(|compiler_options| compiler_options.get("jsxImportSource"))
.is_some();
emit_event("swcExperimentalDecorators", experimental_decorators_enabled);
emit_event("swcImportSource", jsx_import_source_enabled);
// Go over config and report enabled features. // Go over config and report enabled features.
// [TODO]: useSwcLoader is not being reported as it is not directly corresponds (it checks babel config existence) // [TODO]: useSwcLoader is not being reported as it is not directly corresponds (it checks babel config existence)
// need to confirm what we'll do with turbopack. // need to confirm what we'll do with turbopack.
......
...@@ -169,7 +169,6 @@ fn main() { ...@@ -169,7 +169,6 @@ fn main() {
dev: true, dev: true,
encryption_key: rcstr!("deadbeef"), encryption_key: rcstr!("deadbeef"),
env: vec![], env: vec![],
js_config: include_str!("../jsConfig.json").into(),
next_config: include_str!("../nextConfig.json").into(), next_config: include_str!("../nextConfig.json").into(),
preview_props: next_api::project::DraftModeOptions { preview_props: next_api::project::DraftModeOptions {
preview_mode_encryption_key: rcstr!("deadbeef"), preview_mode_encryption_key: rcstr!("deadbeef"),
......
...@@ -184,17 +184,19 @@ pub async fn get_client_resolve_options_context( ...@@ -184,17 +184,19 @@ pub async fn get_client_resolve_options_context(
..Default::default() ..Default::default()
}; };
let tsconfig_path = next_config
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?;
Ok(ResolveOptionsContext { Ok(ResolveOptionsContext {
enable_typescript: true, enable_typescript: true,
enable_react: true, enable_react: true,
enable_mjs_extension: true, enable_mjs_extension: true,
custom_extensions: next_config.resolve_extension().owned().await?, custom_extensions: next_config.resolve_extension().owned().await?,
tsconfig_path: next_config tsconfig_path,
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?,
rules: vec![( rules: vec![(
foreign_code_context_condition(next_config, project_path).await?, foreign_code_context_condition(next_config, project_path).await?,
resolve_options_context.clone().resolved_cell(), resolve_options_context.clone().resolved_cell(),
...@@ -223,10 +225,18 @@ pub async fn get_client_module_options_context( ...@@ -223,10 +225,18 @@ pub async fn get_client_module_options_context(
*execution_context, *execution_context,
); );
let tsconfig = get_typescript_transform_options(project_path.clone()) let tsconfig_path = next_config
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?;
let tsconfig = get_typescript_transform_options(project_path.clone(), tsconfig_path.clone())
.to_resolved() .to_resolved()
.await?; .await?;
let decorators_options = get_decorators_transform_options(project_path.clone()); let decorators_options =
get_decorators_transform_options(project_path.clone(), tsconfig_path.clone());
let enable_mdx_rs = *next_config.mdx_rs().await?; let enable_mdx_rs = *next_config.mdx_rs().await?;
let jsx_runtime_options = get_jsx_transform_options( let jsx_runtime_options = get_jsx_transform_options(
project_path.clone(), project_path.clone(),
...@@ -234,6 +244,7 @@ pub async fn get_client_module_options_context( ...@@ -234,6 +244,7 @@ pub async fn get_client_module_options_context(
Some(resolve_options_context), Some(resolve_options_context),
false, false,
next_config, next_config,
tsconfig_path,
) )
.to_resolved() .to_resolved()
.await?; .await?;
......
...@@ -329,17 +329,19 @@ pub async fn get_server_resolve_options_context( ...@@ -329,17 +329,19 @@ pub async fn get_server_resolve_options_context(
..Default::default() ..Default::default()
}; };
let tsconfig_path = next_config
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?;
Ok(ResolveOptionsContext { Ok(ResolveOptionsContext {
enable_typescript: true, enable_typescript: true,
enable_react: true, enable_react: true,
enable_mjs_extension: true, enable_mjs_extension: true,
custom_extensions: next_config.resolve_extension().owned().await?, custom_extensions: next_config.resolve_extension().owned().await?,
tsconfig_path: next_config tsconfig_path,
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?,
rules: vec![( rules: vec![(
foreign_code_context_condition, foreign_code_context_condition,
resolve_options_context.clone().resolved_cell(), resolve_options_context.clone().resolved_cell(),
...@@ -520,11 +522,19 @@ pub async fn get_server_module_options_context( ...@@ -520,11 +522,19 @@ pub async fn get_server_module_options_context(
.await?; .await?;
let css_versions = environment.css_runtime_versions(); let css_versions = environment.css_runtime_versions();
let tsconfig_path = next_config
.typescript_tsconfig_path()
.await?
.as_ref()
.map(|p| project_path.join(p))
.transpose()?;
// ModuleOptionsContext related options // ModuleOptionsContext related options
let tsconfig = get_typescript_transform_options(project_path.clone()) let tsconfig = get_typescript_transform_options(project_path.clone(), tsconfig_path.clone())
.to_resolved() .to_resolved()
.await?; .await?;
let decorators_options = get_decorators_transform_options(project_path.clone()); let decorators_options =
get_decorators_transform_options(project_path.clone(), tsconfig_path.clone());
let enable_mdx_rs = *next_config.mdx_rs().await?; let enable_mdx_rs = *next_config.mdx_rs().await?;
// Get the jsx transform options for the `client` side. // Get the jsx transform options for the `client` side.
...@@ -534,14 +544,26 @@ pub async fn get_server_module_options_context( ...@@ -534,14 +544,26 @@ pub async fn get_server_module_options_context(
// //
// This enables correct emotion transform and other hydration between server and // This enables correct emotion transform and other hydration between server and
// client bundles. ref: https://github.com/vercel/next.js/blob/4bbf9b6c70d2aa4237defe2bebfa790cdb7e334e/packages/next/src/build/webpack-config.ts#L1421-L1426 // client bundles. ref: https://github.com/vercel/next.js/blob/4bbf9b6c70d2aa4237defe2bebfa790cdb7e334e/packages/next/src/build/webpack-config.ts#L1421-L1426
let jsx_runtime_options = let jsx_runtime_options = get_jsx_transform_options(
get_jsx_transform_options(project_path.clone(), mode, None, false, next_config) project_path.clone(),
.to_resolved() mode,
.await?; None,
let rsc_jsx_runtime_options = false,
get_jsx_transform_options(project_path.clone(), mode, None, true, next_config) next_config,
.to_resolved() tsconfig_path.clone(),
.await?; )
.to_resolved()
.await?;
let rsc_jsx_runtime_options = get_jsx_transform_options(
project_path.clone(),
mode,
None,
true,
next_config,
tsconfig_path,
)
.to_resolved()
.await?;
// A set of custom ecma transform rules being applied to server context. // A set of custom ecma transform rules being applied to server context.
let source_transform_rules: Vec<ModuleRule> = vec![ let source_transform_rules: Vec<ModuleRule> = vec![
......
...@@ -20,18 +20,31 @@ use crate::{mode::NextMode, next_config::NextConfig}; ...@@ -20,18 +20,31 @@ use crate::{mode::NextMode, next_config::NextConfig};
async fn get_typescript_options( async fn get_typescript_options(
project_path: FileSystemPath, project_path: FileSystemPath,
tsconfig_path: Option<FileSystemPath>,
) -> Result<Option<Vec<(Vc<FileJsonContent>, ResolvedVc<Box<dyn Source>>)>>> { ) -> Result<Option<Vec<(Vc<FileJsonContent>, ResolvedVc<Box<dyn Source>>)>>> {
let tsconfig = find_context_file(project_path, tsconfig()); if let Some(tsconfig_path) = tsconfig_path {
Ok(match tsconfig.await.ok().as_deref() { let tsconfigs = read_tsconfigs(
Some(FindContextFileResult::Found(path, _)) => read_tsconfigs( tsconfig_path.read(),
path.read(), ResolvedVc::upcast(FileSource::new(tsconfig_path.clone()).to_resolved().await?),
ResolvedVc::upcast(FileSource::new(path.clone()).to_resolved().await?), node_cjs_resolve_options(tsconfig_path.root().owned().await?),
node_cjs_resolve_options(path.root().owned().await?),
) )
.await .await
.ok(), .ok();
Some(FindContextFileResult::NotFound(_)) | None => None,
}) Ok(tsconfigs)
} else {
let tsconfig = find_context_file(project_path, tsconfig());
Ok(match tsconfig.await.ok().as_deref() {
Some(FindContextFileResult::Found(path, _)) => read_tsconfigs(
path.read(),
ResolvedVc::upcast(FileSource::new(path.clone()).to_resolved().await?),
node_cjs_resolve_options(path.root().owned().await?),
)
.await
.ok(),
Some(FindContextFileResult::NotFound(_)) | None => None,
})
}
} }
/// Build the transform options for specifically for the typescript's runtime /// Build the transform options for specifically for the typescript's runtime
...@@ -39,8 +52,9 @@ async fn get_typescript_options( ...@@ -39,8 +52,9 @@ async fn get_typescript_options(
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_typescript_transform_options( pub async fn get_typescript_transform_options(
project_path: FileSystemPath, project_path: FileSystemPath,
tsconfig_path: Option<FileSystemPath>,
) -> Result<Vc<TypescriptTransformOptions>> { ) -> Result<Vc<TypescriptTransformOptions>> {
let tsconfig = get_typescript_options(project_path).await?; let tsconfig = get_typescript_options(project_path, tsconfig_path).await?;
let use_define_for_class_fields = if let Some(tsconfig) = tsconfig { let use_define_for_class_fields = if let Some(tsconfig) = tsconfig {
read_from_tsconfigs(&tsconfig, |json, _| { read_from_tsconfigs(&tsconfig, |json, _| {
...@@ -60,12 +74,13 @@ pub async fn get_typescript_transform_options( ...@@ -60,12 +74,13 @@ pub async fn get_typescript_transform_options(
} }
/// Build the transform options for the decorators. /// Build the transform options for the decorators.
/// **TODO** Currnently only typescript's legacy decorators are supported /// **TODO** Currently only typescript's legacy decorators are supported
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_decorators_transform_options( pub async fn get_decorators_transform_options(
project_path: FileSystemPath, project_path: FileSystemPath,
tsconfig_path: Option<FileSystemPath>,
) -> Result<Vc<DecoratorsOptions>> { ) -> Result<Vc<DecoratorsOptions>> {
let tsconfig = get_typescript_options(project_path).await?; let tsconfig = get_typescript_options(project_path, tsconfig_path).await?;
let experimental_decorators = if let Some(ref tsconfig) = tsconfig { let experimental_decorators = if let Some(ref tsconfig) = tsconfig {
read_from_tsconfigs(tsconfig, |json, _| { read_from_tsconfigs(tsconfig, |json, _| {
...@@ -135,8 +150,9 @@ pub async fn get_jsx_transform_options( ...@@ -135,8 +150,9 @@ pub async fn get_jsx_transform_options(
resolve_options_context: Option<Vc<ResolveOptionsContext>>, resolve_options_context: Option<Vc<ResolveOptionsContext>>,
is_rsc_context: bool, is_rsc_context: bool,
next_config: Vc<NextConfig>, next_config: Vc<NextConfig>,
tsconfig_path: Option<FileSystemPath>,
) -> Result<Vc<JsxTransformOptions>> { ) -> Result<Vc<JsxTransformOptions>> {
let tsconfig = get_typescript_options(project_path.clone()).await?; let tsconfig = get_typescript_options(project_path.clone(), tsconfig_path).await?;
let is_react_development = mode.await?.is_react_development(); let is_react_development = mode.await?.is_react_development();
let enable_react_refresh = if is_react_development { let enable_react_refresh = if is_react_development {
......
...@@ -65,19 +65,17 @@ export default async function loadJsConfig( ...@@ -65,19 +65,17 @@ export default async function loadJsConfig(
]) ])
typeScriptPath = deps.resolved.get('typescript') typeScriptPath = deps.resolved.get('typescript')
} catch {} } catch {}
const tsConfigPath = path.join(dir, config.typescript.tsconfigPath) const tsConfigFileName = config.typescript.tsconfigPath || 'tsconfig.json'
const tsConfigPath = path.join(dir, tsConfigFileName)
const useTypeScript = Boolean(typeScriptPath && fs.existsSync(tsConfigPath)) const useTypeScript = Boolean(typeScriptPath && fs.existsSync(tsConfigPath))
let implicitBaseurl let implicitBaseurl
let jsConfig: { compilerOptions: Record<string, any> } | undefined let jsConfig: { compilerOptions: Record<string, any> } | undefined
// jsconfig is a subset of tsconfig // jsconfig is a subset of tsconfig
if (useTypeScript) { if (useTypeScript) {
if ( if (tsConfigFileName !== 'tsconfig.json' && TSCONFIG_WARNED === false) {
config.typescript.tsconfigPath !== 'tsconfig.json' &&
TSCONFIG_WARNED === false
) {
TSCONFIG_WARNED = true TSCONFIG_WARNED = true
Log.info(`Using tsconfig file: ${config.typescript.tsconfigPath}`) Log.info(`Using tsconfig file: ${tsConfigFileName}`)
} }
const ts = (await Promise.resolve( const ts = (await Promise.resolve(
......
...@@ -120,8 +120,6 @@ export interface NapiProjectOptions { ...@@ -120,8 +120,6 @@ export interface NapiProjectOptions {
watch: NapiWatchOptions watch: NapiWatchOptions
/** The contents of next.config.js, serialized to JSON. */ /** The contents of next.config.js, serialized to JSON. */
nextConfig: RcStr nextConfig: RcStr
/** The contents of ts/config read by load-jsconfig, serialized to JSON. */
jsConfig: RcStr
/** A map of environment variables to use when compiling code. */ /** A map of environment variables to use when compiling code. */
env: Array<NapiEnvVar> env: Array<NapiEnvVar>
/** /**
...@@ -172,8 +170,6 @@ export interface NapiPartialProjectOptions { ...@@ -172,8 +170,6 @@ export interface NapiPartialProjectOptions {
watch?: NapiWatchOptions watch?: NapiWatchOptions
/** The contents of next.config.js, serialized to JSON. */ /** The contents of next.config.js, serialized to JSON. */
nextConfig?: RcStr nextConfig?: RcStr
/** The contents of ts/config read by load-jsconfig, serialized to JSON. */
jsConfig?: RcStr
/** A map of environment variables to use when compiling code. */ /** A map of environment variables to use when compiling code. */
env?: Array<NapiEnvVar> env?: Array<NapiEnvVar>
/** /**
......
...@@ -625,7 +625,6 @@ function bindingToApi( ...@@ -625,7 +625,6 @@ function bindingToApi(
options.nextConfig, options.nextConfig,
path.join(options.rootPath, options.projectPath) path.join(options.rootPath, options.projectPath)
), ),
jsConfig: JSON.stringify(options.jsConfig),
env: rustifyEnv(options.env), env: rustifyEnv(options.env),
} }
} }
...@@ -641,7 +640,6 @@ function bindingToApi( ...@@ -641,7 +640,6 @@ function bindingToApi(
options.nextConfig, options.nextConfig,
path.join(options.rootPath!, options.projectPath!) path.join(options.rootPath!, options.projectPath!)
)), )),
jsConfig: options.jsConfig && JSON.stringify(options.jsConfig),
env: options.env && rustifyEnv(options.env), env: options.env && rustifyEnv(options.env),
} }
} }
......
...@@ -378,17 +378,6 @@ export interface ProjectOptions { ...@@ -378,17 +378,6 @@ export interface ProjectOptions {
*/ */
nextConfig: NextConfigComplete nextConfig: NextConfigComplete
/**
* Jsconfig, or tsconfig contents.
*
* Next.js implicitly requires to read it to support few options
* https://nextjs.org/docs/architecture/nextjs-compiler#legacy-decorators
* https://nextjs.org/docs/architecture/nextjs-compiler#importsource
*/
jsConfig: {
compilerOptions: object
}
/** /**
* A map of environment variables to use when compiling code. * A map of environment variables to use when compiling code.
*/ */
......
...@@ -2,7 +2,6 @@ import path from 'path' ...@@ -2,7 +2,6 @@ import path from 'path'
import { validateTurboNextConfig } from '../../lib/turbopack-warning' import { validateTurboNextConfig } from '../../lib/turbopack-warning'
import { import {
formatIssue, formatIssue,
getTurbopackJsConfig,
isPersistentCachingEnabled, isPersistentCachingEnabled,
isRelevantWarning, isRelevantWarning,
} from '../../shared/lib/turbopack/utils' } from '../../shared/lib/turbopack/utils'
...@@ -60,7 +59,6 @@ export async function turbopackBuild(): Promise<{ ...@@ -60,7 +59,6 @@ export async function turbopackBuild(): Promise<{
projectPath: normalizePath(path.relative(rootPath, dir) || '.'), projectPath: normalizePath(path.relative(rootPath, dir) || '.'),
distDir, distDir,
nextConfig: config, nextConfig: config,
jsConfig: await getTurbopackJsConfig(dir, config),
watch: { watch: {
enable: false, enable: false,
}, },
......
...@@ -23,7 +23,7 @@ function verifyTypeScriptSetup( ...@@ -23,7 +23,7 @@ function verifyTypeScriptSetup(
distDir: string, distDir: string,
intentDirs: string[], intentDirs: string[],
typeCheckPreflight: boolean, typeCheckPreflight: boolean,
tsconfigPath: string, tsconfigPath: string | undefined,
disableStaticImages: boolean, disableStaticImages: boolean,
cacheDir: string | undefined, cacheDir: string | undefined,
enableWorkerThreads: boolean | undefined, enableWorkerThreads: boolean | undefined,
......
...@@ -835,7 +835,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() { ...@@ -835,7 +835,7 @@ const nextAppLoader: AppLoader = async function nextAppLoader() {
const [createdRootLayout, rootLayoutPath] = await verifyRootLayout({ const [createdRootLayout, rootLayoutPath] = await verifyRootLayout({
appDir: appDir, appDir: appDir,
dir: rootDir!, dir: rootDir!,
tsconfigPath: tsconfigPath!, tsconfigPath: tsconfigPath,
pagePath, pagePath,
pageExtensions, pageExtensions,
}) })
......
...@@ -63,7 +63,7 @@ export async function verifyRootLayout({ ...@@ -63,7 +63,7 @@ export async function verifyRootLayout({
}: { }: {
dir: string dir: string
appDir: string appDir: string
tsconfigPath: string tsconfigPath: string | undefined
pagePath: string pagePath: string
pageExtensions: PageExtensions pageExtensions: PageExtensions
}): Promise<[boolean, string | undefined]> { }): Promise<[boolean, string | undefined]> {
...@@ -112,7 +112,8 @@ export async function verifyRootLayout({ ...@@ -112,7 +112,8 @@ export async function verifyRootLayout({
} }
if (typeof availableDir === 'string') { if (typeof availableDir === 'string') {
const resolvedTsConfigPath = path.join(dir, tsconfigPath) const tsConfigFileName = tsconfigPath || 'tsconfig.json'
const resolvedTsConfigPath = path.join(dir, tsConfigFileName)
const hasTsConfig = await fs.access(resolvedTsConfigPath).then( const hasTsConfig = await fs.access(resolvedTsConfigPath).then(
() => true, () => true,
() => false () => false
......
...@@ -47,18 +47,19 @@ export async function verifyTypeScriptSetup({ ...@@ -47,18 +47,19 @@ export async function verifyTypeScriptSetup({
dir: string dir: string
distDir: string distDir: string
cacheDir?: string cacheDir?: string
tsconfigPath: string tsconfigPath: string | undefined
intentDirs: string[] intentDirs: string[]
typeCheckPreflight: boolean typeCheckPreflight: boolean
disableStaticImages: boolean disableStaticImages: boolean
hasAppDir: boolean hasAppDir: boolean
hasPagesDir: boolean hasPagesDir: boolean
}): Promise<{ result?: TypeCheckResult; version: string | null }> { }): Promise<{ result?: TypeCheckResult; version: string | null }> {
const resolvedTsConfigPath = path.join(dir, tsconfigPath) const tsConfigFileName = tsconfigPath || 'tsconfig.json'
const resolvedTsConfigPath = path.join(dir, tsConfigFileName)
try { try {
// Check if the project uses TypeScript: // Check if the project uses TypeScript:
const intent = await getTypeScriptIntent(dir, intentDirs, tsconfigPath) const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)
if (!intent) { if (!intent) {
return { version: null } return { version: null }
} }
......
...@@ -33,7 +33,7 @@ import type { FallbackRouteParam } from '../build/static-paths/types' ...@@ -33,7 +33,7 @@ import type { FallbackRouteParam } from '../build/static-paths/types'
export type NextConfigComplete = Required<NextConfig> & { export type NextConfigComplete = Required<NextConfig> & {
images: Required<ImageConfigComplete> images: Required<ImageConfigComplete>
typescript: Required<TypeScriptConfig> typescript: TypeScriptConfig
configOrigin?: string configOrigin?: string
configFile?: string configFile?: string
configFileName: string configFileName: string
...@@ -1456,7 +1456,7 @@ export const defaultConfig = Object.freeze({ ...@@ -1456,7 +1456,7 @@ export const defaultConfig = Object.freeze({
}, },
typescript: { typescript: {
ignoreBuildErrors: false, ignoreBuildErrors: false,
tsconfigPath: 'tsconfig.json', tsconfigPath: undefined,
}, },
typedRoutes: false, typedRoutes: false,
distDir: '.next', distDir: '.next',
......
...@@ -84,7 +84,6 @@ import { setBundlerFindSourceMapImplementation } from '../patch-error-inspect' ...@@ -84,7 +84,6 @@ import { setBundlerFindSourceMapImplementation } from '../patch-error-inspect'
import { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware' import { getNextErrorFeedbackMiddleware } from '../../next-devtools/server/get-next-error-feedback-middleware'
import { import {
formatIssue, formatIssue,
getTurbopackJsConfig,
isPersistentCachingEnabled, isPersistentCachingEnabled,
isWellKnownError, isWellKnownError,
processIssues, processIssues,
...@@ -224,7 +223,6 @@ export async function createHotReloaderTurbopack( ...@@ -224,7 +223,6 @@ export async function createHotReloaderTurbopack(
projectPath: normalizePath(relative(rootPath, projectPath) || '.'), projectPath: normalizePath(relative(rootPath, projectPath) || '.'),
distDir, distDir,
nextConfig: opts.nextConfig, nextConfig: opts.nextConfig,
jsConfig: await getTurbopackJsConfig(projectPath, nextConfig),
watch: { watch: {
enable: dev, enable: dev,
pollIntervalMs: nextConfig.watchOptions?.pollIntervalMs, pollIntervalMs: nextConfig.watchOptions?.pollIntervalMs,
......
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
import type { EntryKey } from './entry-key' import type { EntryKey } from './entry-key'
import * as Log from '../../../build/output/log' import * as Log from '../../../build/output/log'
import type { NextConfigComplete } from '../../../server/config-shared' import type { NextConfigComplete } from '../../../server/config-shared'
import loadJsConfig from '../../../build/load-jsconfig'
type IssueKey = `${Issue['severity']}-${Issue['filePath']}-${string}-${string}` type IssueKey = `${Issue['severity']}-${Issue['filePath']}-${string}-${string}`
export type IssuesMap = Map<IssueKey, Issue> export type IssuesMap = Map<IssueKey, Issue>
...@@ -53,14 +52,6 @@ export function getIssueKey(issue: Issue): IssueKey { ...@@ -53,14 +52,6 @@ export function getIssueKey(issue: Issue): IssueKey {
)}-${JSON.stringify(issue.description)}` )}-${JSON.stringify(issue.description)}`
} }
export async function getTurbopackJsConfig(
dir: string,
nextConfig: NextConfigComplete
) {
const { jsConfig } = await loadJsConfig(dir, nextConfig)
return jsConfig ?? { compilerOptions: {} }
}
export function processIssues( export function processIssues(
currentEntryIssues: EntryIssuesMap, currentEntryIssues: EntryIssuesMap,
key: EntryKey, key: EntryKey,
......
...@@ -100,20 +100,6 @@ exports[`next.rs api should detect the correct routes: diagnostics 1`] = ` ...@@ -100,20 +100,6 @@ exports[`next.rs api should detect the correct routes: diagnostics 1`] = `
"swcEmotion": "false", "swcEmotion": "false",
}, },
}, },
{
"category": "NextFeatureTelemetry_category_tbd",
"name": "EVENT_BUILD_FEATURE_USAGE",
"payload": {
"swcExperimentalDecorators": "false",
},
},
{
"category": "NextFeatureTelemetry_category_tbd",
"name": "EVENT_BUILD_FEATURE_USAGE",
"payload": {
"swcImportSource": "false",
},
},
{ {
"category": "NextFeatureTelemetry_category_tbd", "category": "NextFeatureTelemetry_category_tbd",
"name": "EVENT_BUILD_FEATURE_USAGE", "name": "EVENT_BUILD_FEATURE_USAGE",
......
...@@ -195,9 +195,6 @@ describe('next.rs api', () => { ...@@ -195,9 +195,6 @@ describe('next.rs api', () => {
const distDir = '.next' const distDir = '.next'
project = await bindings.turbo.createProject({ project = await bindings.turbo.createProject({
env: {}, env: {},
jsConfig: {
compilerOptions: {},
},
nextConfig: nextConfig, nextConfig: nextConfig,
rootPath, rootPath,
projectPath: path.relative(rootPath, next.testDir) || '.', projectPath: path.relative(rootPath, next.testDir) || '.',
......
...@@ -25,8 +25,16 @@ describe('jsconfig.json', () => { ...@@ -25,8 +25,16 @@ describe('jsconfig.json', () => {
}) })
try { try {
const res = await nextBuild(appDir, [], { stderr: true }) const res = await nextBuild(appDir, [], { stderr: true })
expect(res.stderr).toMatch(/Error: Failed to parse "/) if (process.env.IS_TURBOPACK_TEST) {
expect(res.stderr).toMatch(/JSON5: invalid end of input at 1:2/) expect(res.stderr).toMatch(/An issue occurred while parsing/)
expect(res.stderr).toMatch(/jsconfig.json:1:1/)
expect(res.stderr).toMatch(
/tsconfig is not parseable: invalid JSON: Unterminated object/
)
} else {
expect(res.stderr).toMatch(/Error: Failed to parse "/)
expect(res.stderr).toMatch(/JSON5: invalid end of input at 1:2/)
}
} finally { } finally {
await fs.writeFile(jsconfigPath, originalJsconfig, { await fs.writeFile(jsconfigPath, originalJsconfig, {
encoding: 'utf-8', encoding: 'utf-8',
......
...@@ -7,17 +7,20 @@ const appDir = join(__dirname, '..') ...@@ -7,17 +7,20 @@ const appDir = join(__dirname, '..')
const warnMessage = /Using tsconfig file:/ const warnMessage = /Using tsconfig file:/
describe('Custom TypeScript Config', () => { ;(process.env.IS_TURBOPACK_TEST ? describe.skip : describe)(
;(process.env.TURBOPACK_DEV ? describe.skip : describe)( 'Custom TypeScript Config',
'production mode', () => {
() => { ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
it('should warn when using custom typescript path', async () => { 'production mode',
const { stdout } = await nextBuild(appDir, [], { () => {
stdout: true, it('should warn when using custom typescript path', async () => {
}) const { stdout } = await nextBuild(appDir, [], {
stdout: true,
})
expect(stdout).toMatch(warnMessage) expect(stdout).toMatch(warnMessage)
}) })
} }
) )
}) }
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment