Skip to content

Commit

Permalink
Revert "Implement styled-jsx with swc's styled_jsx" (vercel#366)
Browse files Browse the repository at this point in the history
Revert "Implement styled-jsx with swc's styled_jsx (vercel#354)"

This reverts commit b82d6fa.
  • Loading branch information
wbinnssmith authored Sep 15, 2022
1 parent 0c63cd3 commit c9743d0
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 145 deletions.
37 changes: 0 additions & 37 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion crates/next-core/src/server_rendered_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ pub async fn create_server_rendered_source(
};
let client_module_options_context = ModuleOptionsContext {
enable_react_refresh,
enable_styled_jsx: true,
}
.cell();
let next_client_transition = NextClientTransition {
Expand Down
1 change: 0 additions & 1 deletion crates/next-core/src/web_entry_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub async fn create_web_entry_source(
// we try resolve it once at the root and pass down a context to all
// the modules.
enable_react_refresh,
enable_styled_jsx: true,
}
.into(),
)
Expand Down

This file was deleted.

5 changes: 1 addition & 4 deletions crates/next-dev/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"private": true,
"devDependencies": {
"expect": "^24.5.0",
"jest-circus-browser": "^1.0.7",
"react": "^18.2.0",
"react-test-renderer": "^18.2.0",
"styled-jsx": "^5.0.7"
"jest-circus-browser": "^1.0.7"
},
"installConfig": {
"hoistingLimits": "workspaces"
Expand Down
1 change: 0 additions & 1 deletion crates/turbopack-ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ regex = "1.5.4"
serde = "1.0.136"
serde_json = "1.0.81"
serde_regex = "1.1.0"
styled_jsx = "0.17.1"
#swc_ecma_transforms_module = "0.141.0"
tokio = "1.11.0"
turbo-tasks = { path = "../turbo-tasks" }
Expand Down
14 changes: 3 additions & 11 deletions crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ use swc_core::{
errors::{Handler, HANDLER},
input::StringInput,
sync::Lrc,
util::take::Take,
FileName, Globals, Mark, SourceMap, GLOBALS,
},
ecma::{
ast::{EsVersion, Module, Program},
ast::{EsVersion, Program},
parser::{lexer::Lexer, EsConfig, Parser, Syntax, TsConfig},
transforms::{
base::{helpers::Helpers, resolver},
react::react,
},
visit::{FoldWith, VisitMutWith},
visit::VisitMutWith,
},
};
use turbo_tasks::{Value, ValueToString};
Expand All @@ -41,7 +40,6 @@ pub enum EcmascriptInputTransform {
refresh: bool,
},
CommonJs,
StyledJsx,
Custom,
}

Expand Down Expand Up @@ -163,8 +161,7 @@ pub async fn parse(
},
);

let file_name = FileName::Custom(fs_path);
let fm = cm.new_source_file(file_name.clone(), string);
let fm = cm.new_source_file(FileName::Custom(fs_path), string);

let comments = SingleThreadedComments::default();
let lexer = Lexer::new(
Expand Down Expand Up @@ -267,11 +264,6 @@ pub async fn parse(
),
);
},
EcmascriptInputTransform::StyledJsx => {
// Modeled after https://github.com/swc-project/plugins/blob/ae735894cdb7e6cfd776626fe2bc580d3e80fed9/packages/styled-jsx/src/lib.rs
let real_parsed_program = std::mem::replace(&mut parsed_program, Program::Module(Module::dummy()));
parsed_program = real_parsed_program.fold_with(&mut styled_jsx::styled_jsx(cm.clone(), file_name.clone()));
},
EcmascriptInputTransform::Custom => todo!()
}
}
Expand Down
17 changes: 4 additions & 13 deletions crates/turbopack/src/module_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@ impl ModuleOptionsVc {
_path: FileSystemPathVc,
context: ModuleOptionsContextVc,
) -> Result<ModuleOptionsVc> {
let context_value = context.await?;
let mut transforms = vec![];

// Order of transforms is important. e.g. if the React transform occurs before
// Styled JSX, there won't be JSX nodes for Styled JSX to transform.
if context_value.enable_styled_jsx {
transforms.push(EcmascriptInputTransform::StyledJsx)
}
transforms.append(&mut vec![EcmascriptInputTransform::React {
refresh: context_value.enable_react_refresh,
}]);

let app_transforms = EcmascriptInputTransformsVc::cell(transforms);
let app_transforms =
EcmascriptInputTransformsVc::cell(vec![EcmascriptInputTransform::React {
refresh: context.await?.enable_react_refresh,
}]);
let no_transforms = EcmascriptInputTransformsVc::cell(Vec::new());
Ok(ModuleOptionsVc::cell(ModuleOptions {
rules: vec![
Expand Down
3 changes: 0 additions & 3 deletions crates/turbopack/src/module_options/module_options_context.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use turbopack_ecmascript::EcmascriptInputTransform;

#[turbo_tasks::value(shared)]
#[derive(Default)]
pub struct ModuleOptionsContext {
pub enable_react_refresh: bool,
pub enable_styled_jsx: bool,
}

#[turbo_tasks::value_impl]
Expand Down
49 changes: 0 additions & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22130,13 +22130,6 @@ __metadata:
languageName: node
linkType: hard

"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.2.0":
version: 18.2.0
resolution: "react-is@npm:18.2.0"
checksum: e72d0ba81b5922759e4aff17e0252bd29988f9642ed817f56b25a3e217e13eea8a7f2322af99a06edb779da12d5d636e9fda473d620df9a3da0df2a74141d53e
languageName: node
linkType: hard

"react-is@npm:^16.13.1, react-is@npm:^16.8.4":
version: 16.13.1
resolution: "react-is@npm:16.13.1"
Expand All @@ -22151,31 +22144,6 @@ __metadata:
languageName: node
linkType: hard

"react-shallow-renderer@npm:^16.15.0":
version: 16.15.0
resolution: "react-shallow-renderer@npm:16.15.0"
dependencies:
object-assign: ^4.1.1
react-is: ^16.12.0 || ^17.0.0 || ^18.0.0
peerDependencies:
react: ^16.0.0 || ^17.0.0 || ^18.0.0
checksum: 6052c7e3e9627485120ebd8257f128aad8f56386fe8d42374b7743eac1be457c33506d153c7886b4e32923c0c352d402ab805ef9ca02dbcd8393b2bdeb6e5af8
languageName: node
linkType: hard

"react-test-renderer@npm:^18.2.0":
version: 18.2.0
resolution: "react-test-renderer@npm:18.2.0"
dependencies:
react-is: ^18.2.0
react-shallow-renderer: ^16.15.0
scheduler: ^0.23.0
peerDependencies:
react: ^18.2.0
checksum: 6b6980ced93fa2b72662d5e4ab3b4896833586940047ce52ca9aca801e5432adf05fcbe28289b0af3ce6a2a7c590974e25dcc8aa43d0de658bfe8bbcd686f958
languageName: node
linkType: hard

"react@npm:^16.14.0":
version: 16.14.0
resolution: "react@npm:16.14.0"
Expand Down Expand Up @@ -24982,20 +24950,6 @@ __metadata:
languageName: node
linkType: hard

"styled-jsx@npm:^5.0.7":
version: 5.0.7
resolution: "styled-jsx@npm:5.0.7"
peerDependencies:
react: ">= 16.8.0 || 17.x.x || ^18.0.0-0"
peerDependenciesMeta:
"@babel/core":
optional: true
babel-plugin-macros:
optional: true
checksum: 61959993915f4b1662a682dbbefb3512de9399cf6901969bcadd26ba5441d2b5ca5c1021b233bbd573da2541b41efb45d56c6f618dbc8d88a381ebc62461fefe
languageName: node
linkType: hard

"subarg@npm:^1.0.0":
version: 1.0.0
resolution: "subarg@npm:1.0.0"
Expand Down Expand Up @@ -25349,9 +25303,6 @@ __metadata:
dependencies:
expect: ^24.5.0
jest-circus-browser: ^1.0.7
react: ^18.2.0
react-test-renderer: ^18.2.0
styled-jsx: ^5.0.7
languageName: unknown
linkType: soft

Expand Down

0 comments on commit c9743d0

Please sign in to comment.