From bbed9c5cb39266f9aad3925791f332968a90a259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 12 Jul 2024 16:18:52 +0900 Subject: [PATCH] build: Update `swc_core` to `v0.96.9` (vercel/turbo#8706) ### Description Update swc crates ### Testing Instructions See [next.js counterpart](https://github.com/vercel/next.js/pull/67378) - Closes https://github.com/vercel/next.js/issues/64890 - Closes https://github.com/vercel/next.js/issues/63104 --- crates/turbopack-core/src/environment.rs | 2 +- .../src/transform/modularize_imports.rs | 2 ++ .../turbopack-ecmascript-plugins/src/transform/relay.rs | 8 ++++---- crates/turbopack-ecmascript/src/parse.rs | 8 ++++---- crates/turbopack-swc-ast-explorer/src/main.rs | 4 ++-- .../crates_turbopack-tests_tests_snapshot_b36339._.js | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/turbopack-core/src/environment.rs b/crates/turbopack-core/src/environment.rs index b858816e02b4f..f75350592bd1e 100644 --- a/crates/turbopack-core/src/environment.rs +++ b/crates/turbopack-core/src/environment.rs @@ -86,7 +86,7 @@ impl Environment { ExecutionEnvironment::Browser(browser_env) => { Vc::cell(Versions::parse_versions(browserslist::resolve( browser_env.await?.browserslist_query.split(','), - &browserslist::Opts::new(), + &browserslist::Opts::default(), )?)?) } ExecutionEnvironment::EdgeWorker(_) => todo!(), diff --git a/crates/turbopack-ecmascript-plugins/src/transform/modularize_imports.rs b/crates/turbopack-ecmascript-plugins/src/transform/modularize_imports.rs index 74877d9bb9677..368e36dd4786c 100644 --- a/crates/turbopack-ecmascript-plugins/src/transform/modularize_imports.rs +++ b/crates/turbopack-ecmascript-plugins/src/transform/modularize_imports.rs @@ -42,6 +42,8 @@ impl ModularizeImportsTransformer { transform: modularize_imports::Transform::String(v.transform.clone()), prevent_full_import: v.prevent_full_import, skip_default_conversion: v.skip_default_conversion, + handle_default_import: false, + handle_namespace_import: false, }, ) }) diff --git a/crates/turbopack-ecmascript-plugins/src/transform/relay.rs b/crates/turbopack-ecmascript-plugins/src/transform/relay.rs index 60dd609fb3bde..3baf3cc58a74b 100644 --- a/crates/turbopack-ecmascript-plugins/src/transform/relay.rs +++ b/crates/turbopack-ecmascript-plugins/src/transform/relay.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{path::PathBuf, sync::Arc}; use anyhow::{Context, Result}; use async_trait::async_trait; @@ -33,7 +33,7 @@ pub enum RelayLanguage { #[derive(Debug)] pub struct RelayTransformer { - config: swc_relay::Config, + config: Arc, project_path: FileSystemPath, } @@ -53,7 +53,7 @@ impl RelayTransformer { }; Self { - config: options, + config: options.into(), project_path: project_path.clone(), } } @@ -75,7 +75,7 @@ impl CustomTransformer for RelayTransformer { let p = std::mem::replace(program, Program::Module(Module::dummy())); *program = p.fold_with(&mut swc_relay::relay( - &self.config, + self.config.clone(), FileName::Real(PathBuf::from(ctx.file_name_str)), path_to_proj, // [TODO]: pages_dir comes through next-swc-loader diff --git a/crates/turbopack-ecmascript/src/parse.rs b/crates/turbopack-ecmascript/src/parse.rs index 4bcf95214499c..7fae1353e5cbd 100644 --- a/crates/turbopack-ecmascript/src/parse.rs +++ b/crates/turbopack-ecmascript/src/parse.rs @@ -12,7 +12,7 @@ use swc_core::{ ecma::{ ast::{EsVersion, Program}, lints::{config::LintConfig, rules::LintParams}, - parser::{lexer::Lexer, EsConfig, Parser, Syntax, TsConfig}, + parser::{lexer::Lexer, EsSyntax, Parser, Syntax, TsSyntax}, transforms::base::{ helpers::{Helpers, HELPERS}, resolver, @@ -285,7 +285,7 @@ async fn parse_content( let mut parsed_program = { let lexer = Lexer::new( match ty { - EcmascriptModuleAssetType::Ecmascript => Syntax::Es(EsConfig { + EcmascriptModuleAssetType::Ecmascript => Syntax::Es(EsSyntax { jsx: true, fn_bind: true, decorators: true, @@ -298,7 +298,7 @@ async fn parse_content( explicit_resource_management: true, }), EcmascriptModuleAssetType::Typescript { tsx, .. } => { - Syntax::Typescript(TsConfig { + Syntax::Typescript(TsSyntax { decorators: true, dts: false, no_early_errors: true, @@ -307,7 +307,7 @@ async fn parse_content( }) } EcmascriptModuleAssetType::TypescriptDeclaration => { - Syntax::Typescript(TsConfig { + Syntax::Typescript(TsSyntax { decorators: true, dts: true, no_early_errors: true, diff --git a/crates/turbopack-swc-ast-explorer/src/main.rs b/crates/turbopack-swc-ast-explorer/src/main.rs index 626ef085fc071..bb8809614afe2 100644 --- a/crates/turbopack-swc-ast-explorer/src/main.rs +++ b/crates/turbopack-swc-ast-explorer/src/main.rs @@ -9,7 +9,7 @@ use swc_core::{ common::{errors::ColorConfig, source_map::FileName, Globals, SourceMap, GLOBALS}, ecma::{ ast::EsVersion, - parser::{Syntax, TsConfig}, + parser::{Syntax, TsSyntax}, }, }; @@ -30,7 +30,7 @@ fn main() -> Result<()> { let sm = Arc::new(SourceMap::default()); let file = sm.new_source_file(FileName::Anon, contents); let target = EsVersion::latest(); - let syntax = Syntax::Typescript(TsConfig { + let syntax = Syntax::Typescript(TsSyntax { tsx: true, decorators: false, dts: false, diff --git a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js index 7e35bb31cc053..22bb0e475b339 100644 --- a/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js +++ b/crates/turbopack-tests/tests/snapshot/emotion/emotion/output/crates_turbopack-tests_tests_snapshot_b36339._.js @@ -12,7 +12,7 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests ; ; const StyledButton = /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$node_modules$2f40$emotion$2f$styled$2f$index$2e$js__$5b$test$5d$__$28$ecmascript$29$__["default"])("button", { - target: "ekn3dmj0" + target: "e9t88h50" })("background:blue;"); function ClassNameButton({ children }) { return /*#__PURE__*/ (0, __TURBOPACK__imported__module__$5b$project$5d2f$crates$2f$turbopack$2d$tests$2f$tests$2f$snapshot$2f$node_modules$2f40$emotion$2f$react$2f$jsx$2d$dev$2d$runtime$2e$js__$5b$test$5d$__$28$ecmascript$29$__["jsxDEV"])("button", {