Unverified Commit a7601213 authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

refactor(next-core): consolidate react_refresh options (#49822)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change



### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

WEB-1049. Removes separate enable_refresh options.
parent 138a7952
This diff is collapsed.
...@@ -42,11 +42,11 @@ swc_core = { version = "0.75.41" } ...@@ -42,11 +42,11 @@ swc_core = { version = "0.75.41" }
testing = { version = "0.33.4" } testing = { version = "0.33.4" }
# Turbo crates # Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230511.3" } turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230515.2" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros.. # [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-230511.3" } turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230515.2" }
# [TODO]: need to refactor embed_directory! macro usage in next-core # [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230511.3" } turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230515.2" }
# General Deps # General Deps
......
...@@ -170,15 +170,12 @@ pub async fn get_client_module_options_context( ...@@ -170,15 +170,12 @@ pub async fn get_client_module_options_context(
let custom_rules = get_next_client_transforms_rules(next_config, ty.into_value()).await?; let custom_rules = get_next_client_transforms_rules(next_config, ty.into_value()).await?;
let resolve_options_context = let resolve_options_context =
get_client_resolve_options_context(project_path, ty, next_config, execution_context); get_client_resolve_options_context(project_path, ty, next_config, execution_context);
let enable_react_refresh =
assert_can_resolve_react_refresh(project_path, resolve_options_context)
.await?
.is_found();
let tsconfig = get_typescript_transform_options(project_path); let tsconfig = get_typescript_transform_options(project_path);
let decorators_options = get_decorators_transform_options(project_path); let decorators_options = get_decorators_transform_options(project_path);
let mdx_rs_options = *next_config.mdx_rs().await?; let mdx_rs_options = *next_config.mdx_rs().await?;
let jsx_runtime_options = get_jsx_transform_options(project_path); let jsx_runtime_options =
get_jsx_transform_options(project_path, Some(resolve_options_context));
let enable_webpack_loaders = { let enable_webpack_loaders = {
let options = &*next_config.webpack_loaders_options().await?; let options = &*next_config.webpack_loaders_options().await?;
let loaders_options = WebpackLoadersOptions { let loaders_options = WebpackLoadersOptions {
...@@ -240,7 +237,6 @@ pub async fn get_client_module_options_context( ...@@ -240,7 +237,6 @@ pub async fn get_client_module_options_context(
// the modules. // the modules.
enable_jsx: Some(jsx_runtime_options), enable_jsx: Some(jsx_runtime_options),
enable_emotion, enable_emotion,
enable_react_refresh,
enable_styled_components, enable_styled_components,
enable_styled_jsx: true, enable_styled_jsx: true,
enable_postcss_transform: postcss_transform_options, enable_postcss_transform: postcss_transform_options,
......
...@@ -294,7 +294,7 @@ pub async fn get_server_module_options_context( ...@@ -294,7 +294,7 @@ pub async fn get_server_module_options_context(
let tsconfig = get_typescript_transform_options(project_path); let tsconfig = get_typescript_transform_options(project_path);
let decorators_options = get_decorators_transform_options(project_path); let decorators_options = get_decorators_transform_options(project_path);
let mdx_rs_options = *next_config.mdx_rs().await?; let mdx_rs_options = *next_config.mdx_rs().await?;
let jsx_runtime_options = get_jsx_transform_options(project_path); let jsx_runtime_options = get_jsx_transform_options(project_path, None);
let enable_emotion = *get_emotion_compiler_config(next_config).await?; let enable_emotion = *get_emotion_compiler_config(next_config).await?;
let enable_styled_components = *get_styled_components_compiler_config(next_config).await?; let enable_styled_components = *get_styled_components_compiler_config(next_config).await?;
......
...@@ -7,6 +7,7 @@ use turbopack_binding::{ ...@@ -7,6 +7,7 @@ use turbopack_binding::{
resolve::{find_context_file, node::node_cjs_resolve_options, FindContextFileResult}, resolve::{find_context_file, node::node_cjs_resolve_options, FindContextFileResult},
source_asset::SourceAssetVc, source_asset::SourceAssetVc,
}, },
dev::react_refresh::assert_can_resolve_react_refresh,
ecmascript::typescript::resolve::{read_from_tsconfigs, read_tsconfigs, tsconfig}, ecmascript::typescript::resolve::{read_from_tsconfigs, read_tsconfigs, tsconfig},
ecmascript_plugin::transform::{ ecmascript_plugin::transform::{
emotion::{ emotion::{
...@@ -16,9 +17,12 @@ use turbopack_binding::{ ...@@ -16,9 +17,12 @@ use turbopack_binding::{
OptionStyledComponentsTransformConfigVc, StyledComponentsTransformConfig, OptionStyledComponentsTransformConfigVc, StyledComponentsTransformConfig,
}, },
}, },
turbopack::module_options::{ turbopack::{
DecoratorsKind, DecoratorsOptions, DecoratorsOptionsVc, JsxTransformOptions, module_options::{
JsxTransformOptionsVc, TypescriptTransformOptions, TypescriptTransformOptionsVc, DecoratorsKind, DecoratorsOptions, DecoratorsOptionsVc, JsxTransformOptions,
JsxTransformOptionsVc, TypescriptTransformOptions, TypescriptTransformOptionsVc,
},
resolve_options_context::ResolveOptionsContextVc,
}, },
}, },
}; };
...@@ -131,9 +135,18 @@ pub async fn get_decorators_transform_options( ...@@ -131,9 +135,18 @@ pub async fn get_decorators_transform_options(
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_jsx_transform_options( pub async fn get_jsx_transform_options(
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
resolve_options_context: Option<ResolveOptionsContextVc>,
) -> Result<JsxTransformOptionsVc> { ) -> Result<JsxTransformOptionsVc> {
let tsconfig = get_typescript_options(project_path).await; let tsconfig = get_typescript_options(project_path).await;
let enable_react_refresh = if let Some(resolve_options_context) = resolve_options_context {
assert_can_resolve_react_refresh(project_path, resolve_options_context)
.await?
.is_found()
} else {
false
};
// [NOTE]: ref: WEB-901 // [NOTE]: ref: WEB-901
// next.js does not allow to overriding react runtime config via tsconfig / // next.js does not allow to overriding react runtime config via tsconfig /
// jsconfig, it forces overrides into automatic runtime instead. // jsconfig, it forces overrides into automatic runtime instead.
...@@ -141,6 +154,7 @@ pub async fn get_jsx_transform_options( ...@@ -141,6 +154,7 @@ pub async fn get_jsx_transform_options(
let react_transform_options = JsxTransformOptions { let react_transform_options = JsxTransformOptions {
import_source: None, import_source: None,
runtime: Some("automatic".to_string()), runtime: Some("automatic".to_string()),
react_refresh: enable_react_refresh,
}; };
let react_transform_options = if let Some(tsconfig) = tsconfig { let react_transform_options = if let Some(tsconfig) = tsconfig {
......
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