@swc/plugin-styled-jsx 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +11 -10
- package/package.json +1 -1
- package/src/lib.rs +4 -10
- package/swc_plugin_styled_jsx.wasm +0 -0
- package/transform/Cargo.toml +34 -0
- package/transform/src/lib.rs +5 -0
- package/{src → transform/src}/style.rs +0 -0
- package/{src → transform/src}/transform_css.rs +8 -1
- package/{src → transform/src}/utils.rs +0 -0
- package/{src → transform/src}/visitor.rs +0 -0
- package/{tests → transform/tests}/errors/nested-style-tags/input.js +0 -0
- package/{tests → transform/tests}/errors/nested-style-tags/output.js +0 -0
- package/{tests → transform/tests}/errors/nested-style-tags/output.stderr +0 -0
- package/{tests → transform/tests}/errors/no-child/input.js +0 -0
- package/{tests → transform/tests}/errors/no-child/output.js +0 -0
- package/{tests → transform/tests}/errors/no-child/output.stderr +0 -0
- package/{tests → transform/tests}/errors/ts-with-css-resolve/input.js +0 -0
- package/{tests → transform/tests}/errors/ts-with-css-resolve/output.js +0 -0
- package/{tests → transform/tests}/errors/ts-with-css-resolve/output.stderr +0 -0
- package/{tests → transform/tests}/errors/two-children/input.js +0 -0
- package/{tests → transform/tests}/errors/two-children/output.js +0 -0
- package/{tests → transform/tests}/errors/two-children/output.stderr +0 -0
- package/{tests → transform/tests}/errors/wrong-child-type/input.js +0 -0
- package/{tests → transform/tests}/errors/wrong-child-type/output.js +0 -0
- package/{tests → transform/tests}/errors/wrong-child-type/output.stderr +0 -0
- package/{tests → transform/tests}/errors/wrong-jsx-expression-type/input.js +0 -0
- package/{tests → transform/tests}/errors/wrong-jsx-expression-type/output.js +0 -0
- package/{tests → transform/tests}/errors/wrong-jsx-expression-type/output.stderr +0 -0
- package/{tests → transform/tests}/fixture/absent/input.js +0 -0
- package/{tests → transform/tests}/fixture/absent/output.js +0 -0
- package/{tests → transform/tests}/fixture/attribute-generation-classname-rewriting/input.js +0 -0
- package/{tests → transform/tests}/fixture/attribute-generation-classname-rewriting/output.js +0 -0
- package/{tests → transform/tests}/fixture/attribute-generation-modes/input.js +0 -0
- package/{tests → transform/tests}/fixture/attribute-generation-modes/output.js +0 -0
- package/{tests → transform/tests}/fixture/class/input.js +0 -0
- package/{tests → transform/tests}/fixture/class/output.js +0 -0
- package/{tests → transform/tests}/fixture/comments/input.js +0 -0
- package/{tests → transform/tests}/fixture/comments/output.js +0 -0
- package/{tests → transform/tests}/fixture/component-attribute/input.js +0 -0
- package/{tests → transform/tests}/fixture/component-attribute/output.js +0 -0
- package/{tests → transform/tests}/fixture/conflicts/input.js +0 -0
- package/{tests → transform/tests}/fixture/conflicts/output.js +0 -0
- package/{tests → transform/tests}/fixture/css-selector-after-pseudo/input.js +0 -0
- package/{tests → transform/tests}/fixture/css-selector-after-pseudo/output.js +0 -0
- package/{tests → transform/tests}/fixture/css-tag-same-file/input.js +0 -0
- package/{tests → transform/tests}/fixture/css-tag-same-file/output.js +0 -0
- package/{tests → transform/tests}/fixture/different-jsx-ids/input.js +0 -0
- package/{tests → transform/tests}/fixture/different-jsx-ids/output.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element/input.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element/output.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element-class/input.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element-class/output.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element-external/input.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-element-external/output.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-this-in-arrow/input.js +0 -0
- package/{tests → transform/tests}/fixture/dynamic-this-in-arrow/output.js +0 -0
- package/{tests → transform/tests}/fixture/exported-jsx-style/input.js +0 -0
- package/{tests → transform/tests}/fixture/exported-jsx-style/output.js +0 -0
- package/{tests → transform/tests}/fixture/exported-non-jsx-style/input.js +0 -0
- package/{tests → transform/tests}/fixture/exported-non-jsx-style/output.js +0 -0
- package/{tests → transform/tests}/fixture/expressions/input.js +0 -0
- package/{tests → transform/tests}/fixture/expressions/output.js +0 -0
- package/{tests → transform/tests}/fixture/external-nested-scope/input.js +0 -0
- package/{tests → transform/tests}/fixture/external-nested-scope/output.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet/input.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet/output.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet-global/input.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet-global/output.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet-multi-line/input.js +0 -0
- package/{tests → transform/tests}/fixture/external-stylesheet-multi-line/output.js +0 -0
- package/{tests → transform/tests}/fixture/fragment/input.js +0 -0
- package/{tests → transform/tests}/fixture/fragment/output.js +0 -0
- package/{tests → transform/tests}/fixture/global/input.js +0 -0
- package/{tests → transform/tests}/fixture/global/output.js +0 -0
- package/{tests → transform/tests}/fixture/global-child-selector/input.js +0 -0
- package/{tests → transform/tests}/fixture/global-child-selector/output.js +0 -0
- package/{tests → transform/tests}/fixture/global-redundant/input.js +0 -0
- package/{tests → transform/tests}/fixture/global-redundant/output.js +0 -0
- package/{tests → transform/tests}/fixture/issue-30480/input.js +0 -0
- package/{tests → transform/tests}/fixture/issue-30480/output.js +0 -0
- package/{tests → transform/tests}/fixture/issue-30570/input.js +0 -0
- package/{tests → transform/tests}/fixture/issue-30570/output.js +0 -0
- package/{tests → transform/tests}/fixture/issue-31562-interpolation-in-mdea/input.js +0 -0
- package/{tests → transform/tests}/fixture/issue-31562-interpolation-in-mdea/output.js +0 -0
- package/{tests → transform/tests}/fixture/mixed-global-scoped/input.js +0 -0
- package/{tests → transform/tests}/fixture/mixed-global-scoped/output.js +0 -0
- package/{tests → transform/tests}/fixture/multiple-jsx/input.js +0 -0
- package/{tests → transform/tests}/fixture/multiple-jsx/output.js +0 -0
- package/{tests → transform/tests}/fixture/nested-style-tags/index.js +0 -0
- package/{tests → transform/tests}/fixture/nested-style-tags/output.js +0 -0
- package/{tests → transform/tests}/fixture/non-styled-jsx-style/input.js +0 -0
- package/{tests → transform/tests}/fixture/non-styled-jsx-style/output.js +0 -0
- package/{tests → transform/tests}/fixture/not-styled-jsx-tagged-templates/input.js +0 -0
- package/{tests → transform/tests}/fixture/not-styled-jsx-tagged-templates/output.js +0 -0
- package/{tests → transform/tests}/fixture/number-after-placeholder/input.js +0 -0
- package/{tests → transform/tests}/fixture/number-after-placeholder/output.js +0 -0
- package/{tests → transform/tests}/fixture/one-off-global-selectors/input.js +0 -0
- package/{tests → transform/tests}/fixture/one-off-global-selectors/output.js +0 -0
- package/{tests → transform/tests}/fixture/source-maps/input.js +0 -0
- package/{tests → transform/tests}/fixture/source-maps/output.js +0 -0
- package/{tests → transform/tests}/fixture/stateless/input.js +0 -0
- package/{tests → transform/tests}/fixture/stateless/output.js +0 -0
- package/{tests → transform/tests}/fixture/styles/input.js +0 -0
- package/{tests → transform/tests}/fixture/styles/output.js +0 -0
- package/{tests → transform/tests}/fixture/styles-external-invalid/input.js +0 -0
- package/{tests → transform/tests}/fixture/styles-external-invalid/output.js +0 -0
- package/{tests → transform/tests}/fixture/styles-external-invalid2/input.js +0 -0
- package/{tests → transform/tests}/fixture/styles-external-invalid2/output.js +0 -0
- package/{tests → transform/tests}/fixture/styles2/input.js +0 -0
- package/{tests → transform/tests}/fixture/styles2/output.js +0 -0
- package/{tests → transform/tests}/fixture/too-many/input.js +0 -0
- package/{tests → transform/tests}/fixture/too-many/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-escape-1/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-escape-1/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-escape-2/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-escape-2/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-1-as-property/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-1-as-property/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-2-as-part-of-value/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-2-as-part-of-value/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-3-as-value/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-3-as-value/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/input.js +0 -0
- package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-complex-selector/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-complex-selector/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-global/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-global/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-media-query/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-media-query/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-normal/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-normal/output.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-nth-1/input.js +0 -0
- package/{tests → transform/tests}/fixture/transform-css-nth-1/output.js +0 -0
- package/{tests → transform/tests}/fixture/whitespace/input.js +0 -0
- package/{tests → transform/tests}/fixture/whitespace/output.js +0 -0
- package/{tests → transform/tests}/fixture.rs +1 -1
package/Cargo.toml
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
|
3
|
-
description = "SWC
|
|
3
|
+
description = "SWC Plugin for styled-jsx"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
name = "swc_plugin_styled_jsx"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.8.0"
|
|
8
8
|
|
|
9
9
|
[lib]
|
|
10
10
|
crate-type = ["cdylib", "rlib"]
|
|
11
11
|
|
|
12
12
|
[features]
|
|
13
|
-
plugin = ["swc_core/plugin_transform"]
|
|
14
13
|
custom_transform = ["swc_core/common_concurrent"]
|
|
15
14
|
|
|
16
15
|
[dependencies]
|
|
17
16
|
easy-error = "1.0.0"
|
|
18
17
|
tracing = "0.1.32"
|
|
19
18
|
|
|
20
|
-
swc_core = {
|
|
19
|
+
swc_core = {version = "0.38.1", features = [
|
|
21
20
|
"common",
|
|
22
21
|
"ecma_ast",
|
|
23
22
|
"css_ast",
|
|
@@ -28,11 +27,13 @@ swc_core = { version = "0.34.1", features = [
|
|
|
28
27
|
"ecma_parser",
|
|
29
28
|
"ecma_minifier",
|
|
30
29
|
"ecma_utils",
|
|
31
|
-
"ecma_visit"
|
|
32
|
-
]
|
|
30
|
+
"ecma_visit",
|
|
31
|
+
]}
|
|
32
|
+
|
|
33
|
+
styled_jsx = {version = "0.23.0", path = "./transform"}
|
|
33
34
|
|
|
34
35
|
[dev-dependencies]
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
swc_core = {features = [
|
|
37
|
+
"testing_transform",
|
|
38
|
+
], version = "0.38.1"}
|
|
39
|
+
testing = "0.31.8"
|
package/package.json
CHANGED
package/src/lib.rs
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
|
+
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
|
1
2
|
#![feature(box_patterns)]
|
|
2
|
-
|
|
3
|
+
|
|
4
|
+
use styled_jsx::visitor;
|
|
3
5
|
use swc_core::{
|
|
4
6
|
common::{sync::Lrc, FileName, SourceMap},
|
|
5
7
|
ecma::{ast::Program, visit::FoldWith},
|
|
6
8
|
plugin::{plugin_transform, proxies::TransformPluginProgramMetadata},
|
|
7
9
|
};
|
|
8
10
|
|
|
9
|
-
pub mod style;
|
|
10
|
-
mod transform_css;
|
|
11
|
-
mod utils;
|
|
12
|
-
pub mod visitor;
|
|
13
|
-
|
|
14
|
-
#[cfg(feature = "plugin")]
|
|
15
11
|
#[plugin_transform]
|
|
16
12
|
fn styled_jsx_plugin(program: Program, _: TransformPluginProgramMetadata) -> Program {
|
|
17
13
|
// TODO(kdy1): This is wrong, but it does not use cm
|
|
18
14
|
let cm = Lrc::new(SourceMap::default());
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
program
|
|
16
|
+
program.fold_with(&mut visitor::styled_jsx(cm, FileName::Anon))
|
|
23
17
|
}
|
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
|
3
|
+
description = "AST transforms visitor for styled-jsx"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
license = "Apache-2.0"
|
|
6
|
+
name = "styled_jsx"
|
|
7
|
+
version = "0.23.0"
|
|
8
|
+
|
|
9
|
+
[features]
|
|
10
|
+
custom_transform = ["swc_core/common_concurrent"]
|
|
11
|
+
|
|
12
|
+
[dependencies]
|
|
13
|
+
easy-error = "1.0.0"
|
|
14
|
+
tracing = "0.1.32"
|
|
15
|
+
|
|
16
|
+
swc_core = { version = "0.38.1", features = [
|
|
17
|
+
"common",
|
|
18
|
+
"ecma_ast",
|
|
19
|
+
"css_ast",
|
|
20
|
+
"css_codegen",
|
|
21
|
+
"css_parser",
|
|
22
|
+
"css_prefixer",
|
|
23
|
+
"css_visit",
|
|
24
|
+
"ecma_parser",
|
|
25
|
+
"ecma_minifier",
|
|
26
|
+
"ecma_utils",
|
|
27
|
+
"ecma_visit"
|
|
28
|
+
] }
|
|
29
|
+
|
|
30
|
+
[dev-dependencies]
|
|
31
|
+
testing = "0.31.8"
|
|
32
|
+
swc_core = { features = [
|
|
33
|
+
"testing_transform"
|
|
34
|
+
], version = "0.38.1" }
|
|
File without changes
|
|
@@ -12,7 +12,10 @@ use swc_core::{
|
|
|
12
12
|
writer::basic::{BasicCssWriter, BasicCssWriterConfig},
|
|
13
13
|
CodeGenerator, CodegenConfig, Emit,
|
|
14
14
|
},
|
|
15
|
-
parser::{
|
|
15
|
+
parser::{
|
|
16
|
+
parse_str, parse_tokens,
|
|
17
|
+
parser::{input::Tokens, ParserConfig},
|
|
18
|
+
},
|
|
16
19
|
prefixer::prefixer,
|
|
17
20
|
visit::{VisitMut, VisitMutWith},
|
|
18
21
|
},
|
|
@@ -42,6 +45,7 @@ pub fn transform_css(
|
|
|
42
45
|
style_info.css_span.hi,
|
|
43
46
|
ParserConfig {
|
|
44
47
|
allow_wrong_line_comments: true,
|
|
48
|
+
..Default::default()
|
|
45
49
|
},
|
|
46
50
|
// We ignore errors because we inject placeholders for expressions which is
|
|
47
51
|
// not a valid css.
|
|
@@ -234,6 +238,7 @@ impl Namespacer {
|
|
|
234
238
|
PseudoClassSelectorChildren::ForgivingRelativeSelectorList(v) => {
|
|
235
239
|
to_tokens(v).tokens
|
|
236
240
|
}
|
|
241
|
+
PseudoClassSelectorChildren::ComplexSelector(v) => to_tokens(v).tokens,
|
|
237
242
|
})
|
|
238
243
|
.collect::<Vec<_>>();
|
|
239
244
|
|
|
@@ -286,6 +291,7 @@ impl Namespacer {
|
|
|
286
291
|
&args,
|
|
287
292
|
ParserConfig {
|
|
288
293
|
allow_wrong_line_comments: true,
|
|
294
|
+
..Default::default()
|
|
289
295
|
},
|
|
290
296
|
// TODO(kdy1): We might be able to report syntax errors.
|
|
291
297
|
&mut vec![],
|
|
@@ -523,6 +529,7 @@ where
|
|
|
523
529
|
StringInput::new(&s, span.lo, span.hi),
|
|
524
530
|
ParserConfig {
|
|
525
531
|
allow_wrong_line_comments: true,
|
|
532
|
+
..Default::default()
|
|
526
533
|
},
|
|
527
534
|
);
|
|
528
535
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{tests → transform/tests}/fixture/attribute-generation-classname-rewriting/output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/input.js
RENAMED
|
File without changes
|
package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.js
RENAMED
|
File without changes
|
package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/input.js
RENAMED
|
File without changes
|
package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/output.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
use std::path::PathBuf;
|
|
2
2
|
|
|
3
|
+
use styled_jsx::visitor::styled_jsx;
|
|
3
4
|
use swc_core::{
|
|
4
5
|
common::{chain, FileName, Mark, Span, DUMMY_SP},
|
|
5
6
|
ecma::{
|
|
@@ -10,7 +11,6 @@ use swc_core::{
|
|
|
10
11
|
},
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
|
-
use swc_plugin_styled_jsx::visitor::styled_jsx;
|
|
14
14
|
use testing::fixture;
|
|
15
15
|
|
|
16
16
|
fn syntax() -> Syntax {
|