Skip to content

Commit

Permalink
Update swc_core to v0.75.22 (vercel/turborepo#4470)
Browse files Browse the repository at this point in the history
### Description

This update includes an improvement of `@swc/helpers`, so we need to
update `@swc/helpers` too when updating next-swc.

### Testing Instructions

Fix WEB-744
Fix WEB-859

---

 - Fixes #2825.
 - Fixes #4092.
  • Loading branch information
kdy1 authored Apr 18, 2023
1 parent defcf8d commit 1416e31
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 28 deletions.
1 change: 1 addition & 0 deletions crates/turbopack-css/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ turbopack-swc-utils = { workspace = true }
swc_core = { workspace = true, features = [
"ecma_ast",
"css_ast",
"css_ast_serde",
"css_codegen",
"css_parser",
"css_utils",
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-css/src/module_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ impl ModuleCssModuleAssetVc {
for export_class_name in export_class_names {
export.push(match export_class_name {
CssClassName::Import { from, name } => ModuleCssClass::Import {
original: name.to_string(),
original: name.value.to_string(),
from: CssModuleComposeReferenceVc::new(
self.as_resolve_origin(),
RequestVc::parse(Value::new(from.to_string().into())),
),
},
CssClassName::Local { name } => ModuleCssClass::Local {
name: name.to_string(),
name: name.value.to_string(),
},
CssClassName::Global { name } => ModuleCssClass::Global {
name: name.to_string(),
name: name.value.to_string(),
},
})
}
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-css/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async fn parse_content(
let config = ParserConfig {
css_modules: matches!(ty, CssModuleAssetType::Module),
legacy_nesting: true,
legacy_ie: true,
..Default::default()
};

Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-ecmascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ url = { workspace = true }

swc_core = { workspace = true, features = [
"ecma_ast",
"ecma_ast_serde",
"common",
"common_concurrent",
"common_sourcemap",
Expand Down
15 changes: 14 additions & 1 deletion crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
mod server_to_client_proxy;
mod util;

use std::{fmt::Debug, path::Path, sync::Arc};
use std::{
collections::hash_map::DefaultHasher,
fmt::Debug,
hash::{Hash, Hasher},
path::Path,
sync::Arc,
};

use anyhow::Result;
use swc_core::{
Expand Down Expand Up @@ -183,6 +189,7 @@ impl EcmascriptInputTransform {
Some(comments.clone()),
config,
top_level_mark,
unresolved_mark,
));
}
EcmascriptInputTransform::CommonJs => {
Expand Down Expand Up @@ -215,9 +222,15 @@ impl EcmascriptInputTransform {
..Default::default()
};
let p = std::mem::replace(program, Program::Module(Module::dummy()));
let hash = {
let mut hasher = DefaultHasher::new();
p.hash(&mut hasher);
hasher.finish()
};
*program = p.fold_with(&mut swc_emotion::emotion(
options,
Path::new(file_name_str),
hash as u32,
source_map.clone(),
comments.clone(),
))
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-swc-utils/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Emitter for IssueEmitter {
let mut message = db
.message
.iter()
.map(|(s, _)| s.as_ref())
.map(|s| s.0.as_ref())
.collect::<Vec<_>>()
.join("");
let code = db.code.as_ref().map(|d| match d {
Expand Down

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

This file was deleted.

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

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

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_21f811.js",
"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_48e74f.js",
{},
]);
(globalThis.TURBOPACK_CHUNK_LISTS = globalThis.TURBOPACK_CHUNK_LISTS || []).push({
"path": "output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_21f811.js",
"path": "output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_48e74f.js",
"chunks": [
"output/63a02_@swc_helpers_src__class_call_check.mjs_f682d0._.js",
"output/63a02_@swc_helpers____class_call_check_f08d44.js",
"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_b53fce.js"
],
"source": "entry"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(globalThis.TURBOPACK = globalThis.TURBOPACK || []).push([
"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_e2f660.js",
"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_9dcfd0.js",
{},
{"otherChunks":[{"path":"output/63a02_@swc_helpers_src__class_call_check.mjs_f682d0._.js","included":["[project]/crates/turbopack-tests/tests/node_modules/@swc/helpers/src/_class_call_check.mjs (ecmascript)"]},{"path":"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_b53fce.js","included":["[project]/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/input/index.js (ecmascript)"]}],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/input/index.js (ecmascript)"]}
{"otherChunks":[{"path":"output/63a02_@swc_helpers____class_call_check_f08d44.js","included":["[project]/crates/turbopack-tests/tests/node_modules/@swc/helpers/_/_class_call_check.js (ecmascript)"]},{"path":"output/79fb1_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_b53fce.js","included":["[project]/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/input/index.js (ecmascript)"]}],"runtimeModuleIds":["[project]/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/input/index.js (ecmascript)"]}
]);
(() => {
if (!Array.isArray(globalThis.TURBOPACK)) {
Expand Down

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

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

0 comments on commit 1416e31

Please sign in to comment.