Skip to content

Commit 4f5ed65

Browse files
authored
fix(styled-components): Use stable hash (#142)
- Closes #136. - Closes #140.
1 parent 8363a71 commit 4f5ed65

14 files changed

Lines changed: 20 additions & 25 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/emotion/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-emotion",
3-
"version": "2.5.38",
3+
"version": "2.5.39",
44
"description": "SWC plugin for emotion css-in-js library",
55
"main": "swc_plugin_emotion.wasm",
66
"scripts": {

packages/emotion/transform/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55
license = "Apache-2.0"
66
name = "swc_emotion"
77
repository = "https://github.com/swc-project/plugins.git"
8-
version = "0.29.2"
8+
version = "0.29.3"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

packages/jest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-jest",
3-
"version": "1.5.38",
3+
"version": "1.5.39",
44
"description": "SWC plugin for jest",
55
"main": "swc_plugin_jest.wasm",
66
"scripts": {

packages/loadable-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-loadable-components",
3-
"version": "0.3.38",
3+
"version": "0.3.39",
44
"description": "SWC plugin for `@loadable/components`",
55
"main": "swc_plugin_loadable_components.wasm",
66
"scripts": {

packages/noop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-noop",
3-
"version": "1.5.36",
3+
"version": "1.5.37",
44
"description": "Noop SWC plugin, for debugging",
55
"main": "swc_plugin_noop.wasm",
66
"scripts": {

packages/relay/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-relay",
3-
"version": "1.5.38",
3+
"version": "1.5.39",
44
"description": "SWC plugin for relay",
55
"main": "swc_plugin_relay.wasm",
66
"types": "./types.d.ts",

packages/styled-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-styled-components",
3-
"version": "1.5.38",
3+
"version": "1.5.39",
44
"description": "SWC plugin for styled-components",
55
"main": "swc_plugin_styled_components.wasm",
66
"scripts": {

packages/styled-components/src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#![allow(clippy::not_unsafe_ptr_arg_deref)]
22

3-
use std::{
4-
collections::hash_map::DefaultHasher,
5-
hash::{Hash, Hasher},
6-
};
7-
83
use styled_components::Config;
4+
use swc_common::{SourceMapper, Spanned};
95
use swc_core::{
106
common::FileName,
117
ecma::{ast::Program, visit::VisitMutWith},
@@ -29,11 +25,10 @@ fn styled_components(mut program: Program, data: TransformPluginProgramMetadata)
2925
None => FileName::Anon,
3026
};
3127

32-
let mut hasher = DefaultHasher::default();
33-
program.hash(&mut hasher);
34-
let src_file_hash = hasher.finish() as _;
28+
let pos = data.source_map.lookup_char_pos(program.span().lo);
29+
let hash = pos.file.src_hash;
3530

36-
let mut pass = styled_components::styled_components(file_name, src_file_hash, config);
31+
let mut pass = styled_components::styled_components(file_name, hash, config);
3732

3833
program.visit_mut_with(&mut pass);
3934

packages/styled-components/transform/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
66
license = "Apache-2.0"
77
name = "styled_components"
88
repository = "https://github.com/swc-project/plugins.git"
9-
version = "0.53.2"
9+
version = "0.53.3"
1010

1111
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1212

0 commit comments

Comments
 (0)