Skip to content

Commit

Permalink
Implement typeof window inlining feature: vercel/turborepo#8211
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed May 25, 2024
1 parent 329f366 commit 3d3bc8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use turbopack_binding::{
condition::ContextCondition,
module_options::{
module_options_context::ModuleOptionsContext, JsxTransformOptions, ModuleRule,
TypescriptTransformOptions,
TypeofWindow, TypescriptTransformOptions,
},
resolve_options_context::ResolveOptionsContext,
},
Expand Down Expand Up @@ -270,6 +270,7 @@ pub async fn get_client_module_options_context(
let enable_foreign_postcss_transform = Some(postcss_foreign_transform_options.cell());

let module_options_context = ModuleOptionsContext {
enable_typeof_window_inlining: Some(TypeofWindow::Object),
preset_env_versions: Some(env),
execution_context: Some(execution_context),
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
Expand All @@ -280,6 +281,7 @@ pub async fn get_client_module_options_context(

// node_modules context
let foreign_codes_options_context = ModuleOptionsContext {
enable_typeof_window_inlining: None,
enable_webpack_loaders: foreign_enable_webpack_loaders,
enable_postcss_transform: enable_foreign_postcss_transform,
custom_rules: foreign_next_client_rules,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use turbopack_binding::{
turbopack::{
condition::ContextCondition,
module_options::{
JsxTransformOptions, ModuleOptionsContext, ModuleRule, TypescriptTransformOptions,
JsxTransformOptions, ModuleOptionsContext, ModuleRule, TypeofWindow,
TypescriptTransformOptions,
},
resolve_options_context::ResolveOptionsContext,
transition::Transition,
Expand Down Expand Up @@ -461,6 +462,7 @@ pub async fn get_server_module_options_context(
let styled_jsx_transform_rule = get_styled_jsx_transform_rule(next_config, versions).await?;

let module_options_context = ModuleOptionsContext {
enable_typeof_window_inlining: Some(TypeofWindow::Undefined),
execution_context: Some(execution_context),
use_swc_css,
tree_shaking_mode: Some(TreeShakingMode::ReexportsOnly),
Expand Down Expand Up @@ -509,6 +511,7 @@ pub async fn get_server_module_options_context(
};

let foreign_code_module_options_context = ModuleOptionsContext {
enable_typeof_window_inlining: None,
custom_rules: foreign_next_server_rules.clone(),
enable_webpack_loaders: foreign_enable_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
Expand Down Expand Up @@ -563,6 +566,7 @@ pub async fn get_server_module_options_context(
next_server_rules.extend(source_transform_rules);

let foreign_code_module_options_context = ModuleOptionsContext {
enable_typeof_window_inlining: None,
custom_rules: foreign_next_server_rules.clone(),
enable_webpack_loaders: foreign_enable_webpack_loaders,
// NOTE(WEB-1016) PostCSS transforms should also apply to foreign code.
Expand Down

0 comments on commit 3d3bc8b

Please sign in to comment.