@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.
Files changed (141) hide show
  1. package/Cargo.toml +11 -10
  2. package/package.json +1 -1
  3. package/src/lib.rs +4 -10
  4. package/swc_plugin_styled_jsx.wasm +0 -0
  5. package/transform/Cargo.toml +34 -0
  6. package/transform/src/lib.rs +5 -0
  7. package/{src → transform/src}/style.rs +0 -0
  8. package/{src → transform/src}/transform_css.rs +8 -1
  9. package/{src → transform/src}/utils.rs +0 -0
  10. package/{src → transform/src}/visitor.rs +0 -0
  11. package/{tests → transform/tests}/errors/nested-style-tags/input.js +0 -0
  12. package/{tests → transform/tests}/errors/nested-style-tags/output.js +0 -0
  13. package/{tests → transform/tests}/errors/nested-style-tags/output.stderr +0 -0
  14. package/{tests → transform/tests}/errors/no-child/input.js +0 -0
  15. package/{tests → transform/tests}/errors/no-child/output.js +0 -0
  16. package/{tests → transform/tests}/errors/no-child/output.stderr +0 -0
  17. package/{tests → transform/tests}/errors/ts-with-css-resolve/input.js +0 -0
  18. package/{tests → transform/tests}/errors/ts-with-css-resolve/output.js +0 -0
  19. package/{tests → transform/tests}/errors/ts-with-css-resolve/output.stderr +0 -0
  20. package/{tests → transform/tests}/errors/two-children/input.js +0 -0
  21. package/{tests → transform/tests}/errors/two-children/output.js +0 -0
  22. package/{tests → transform/tests}/errors/two-children/output.stderr +0 -0
  23. package/{tests → transform/tests}/errors/wrong-child-type/input.js +0 -0
  24. package/{tests → transform/tests}/errors/wrong-child-type/output.js +0 -0
  25. package/{tests → transform/tests}/errors/wrong-child-type/output.stderr +0 -0
  26. package/{tests → transform/tests}/errors/wrong-jsx-expression-type/input.js +0 -0
  27. package/{tests → transform/tests}/errors/wrong-jsx-expression-type/output.js +0 -0
  28. package/{tests → transform/tests}/errors/wrong-jsx-expression-type/output.stderr +0 -0
  29. package/{tests → transform/tests}/fixture/absent/input.js +0 -0
  30. package/{tests → transform/tests}/fixture/absent/output.js +0 -0
  31. package/{tests → transform/tests}/fixture/attribute-generation-classname-rewriting/input.js +0 -0
  32. package/{tests → transform/tests}/fixture/attribute-generation-classname-rewriting/output.js +0 -0
  33. package/{tests → transform/tests}/fixture/attribute-generation-modes/input.js +0 -0
  34. package/{tests → transform/tests}/fixture/attribute-generation-modes/output.js +0 -0
  35. package/{tests → transform/tests}/fixture/class/input.js +0 -0
  36. package/{tests → transform/tests}/fixture/class/output.js +0 -0
  37. package/{tests → transform/tests}/fixture/comments/input.js +0 -0
  38. package/{tests → transform/tests}/fixture/comments/output.js +0 -0
  39. package/{tests → transform/tests}/fixture/component-attribute/input.js +0 -0
  40. package/{tests → transform/tests}/fixture/component-attribute/output.js +0 -0
  41. package/{tests → transform/tests}/fixture/conflicts/input.js +0 -0
  42. package/{tests → transform/tests}/fixture/conflicts/output.js +0 -0
  43. package/{tests → transform/tests}/fixture/css-selector-after-pseudo/input.js +0 -0
  44. package/{tests → transform/tests}/fixture/css-selector-after-pseudo/output.js +0 -0
  45. package/{tests → transform/tests}/fixture/css-tag-same-file/input.js +0 -0
  46. package/{tests → transform/tests}/fixture/css-tag-same-file/output.js +0 -0
  47. package/{tests → transform/tests}/fixture/different-jsx-ids/input.js +0 -0
  48. package/{tests → transform/tests}/fixture/different-jsx-ids/output.js +0 -0
  49. package/{tests → transform/tests}/fixture/dynamic-element/input.js +0 -0
  50. package/{tests → transform/tests}/fixture/dynamic-element/output.js +0 -0
  51. package/{tests → transform/tests}/fixture/dynamic-element-class/input.js +0 -0
  52. package/{tests → transform/tests}/fixture/dynamic-element-class/output.js +0 -0
  53. package/{tests → transform/tests}/fixture/dynamic-element-external/input.js +0 -0
  54. package/{tests → transform/tests}/fixture/dynamic-element-external/output.js +0 -0
  55. package/{tests → transform/tests}/fixture/dynamic-this-in-arrow/input.js +0 -0
  56. package/{tests → transform/tests}/fixture/dynamic-this-in-arrow/output.js +0 -0
  57. package/{tests → transform/tests}/fixture/exported-jsx-style/input.js +0 -0
  58. package/{tests → transform/tests}/fixture/exported-jsx-style/output.js +0 -0
  59. package/{tests → transform/tests}/fixture/exported-non-jsx-style/input.js +0 -0
  60. package/{tests → transform/tests}/fixture/exported-non-jsx-style/output.js +0 -0
  61. package/{tests → transform/tests}/fixture/expressions/input.js +0 -0
  62. package/{tests → transform/tests}/fixture/expressions/output.js +0 -0
  63. package/{tests → transform/tests}/fixture/external-nested-scope/input.js +0 -0
  64. package/{tests → transform/tests}/fixture/external-nested-scope/output.js +0 -0
  65. package/{tests → transform/tests}/fixture/external-stylesheet/input.js +0 -0
  66. package/{tests → transform/tests}/fixture/external-stylesheet/output.js +0 -0
  67. package/{tests → transform/tests}/fixture/external-stylesheet-global/input.js +0 -0
  68. package/{tests → transform/tests}/fixture/external-stylesheet-global/output.js +0 -0
  69. package/{tests → transform/tests}/fixture/external-stylesheet-multi-line/input.js +0 -0
  70. package/{tests → transform/tests}/fixture/external-stylesheet-multi-line/output.js +0 -0
  71. package/{tests → transform/tests}/fixture/fragment/input.js +0 -0
  72. package/{tests → transform/tests}/fixture/fragment/output.js +0 -0
  73. package/{tests → transform/tests}/fixture/global/input.js +0 -0
  74. package/{tests → transform/tests}/fixture/global/output.js +0 -0
  75. package/{tests → transform/tests}/fixture/global-child-selector/input.js +0 -0
  76. package/{tests → transform/tests}/fixture/global-child-selector/output.js +0 -0
  77. package/{tests → transform/tests}/fixture/global-redundant/input.js +0 -0
  78. package/{tests → transform/tests}/fixture/global-redundant/output.js +0 -0
  79. package/{tests → transform/tests}/fixture/issue-30480/input.js +0 -0
  80. package/{tests → transform/tests}/fixture/issue-30480/output.js +0 -0
  81. package/{tests → transform/tests}/fixture/issue-30570/input.js +0 -0
  82. package/{tests → transform/tests}/fixture/issue-30570/output.js +0 -0
  83. package/{tests → transform/tests}/fixture/issue-31562-interpolation-in-mdea/input.js +0 -0
  84. package/{tests → transform/tests}/fixture/issue-31562-interpolation-in-mdea/output.js +0 -0
  85. package/{tests → transform/tests}/fixture/mixed-global-scoped/input.js +0 -0
  86. package/{tests → transform/tests}/fixture/mixed-global-scoped/output.js +0 -0
  87. package/{tests → transform/tests}/fixture/multiple-jsx/input.js +0 -0
  88. package/{tests → transform/tests}/fixture/multiple-jsx/output.js +0 -0
  89. package/{tests → transform/tests}/fixture/nested-style-tags/index.js +0 -0
  90. package/{tests → transform/tests}/fixture/nested-style-tags/output.js +0 -0
  91. package/{tests → transform/tests}/fixture/non-styled-jsx-style/input.js +0 -0
  92. package/{tests → transform/tests}/fixture/non-styled-jsx-style/output.js +0 -0
  93. package/{tests → transform/tests}/fixture/not-styled-jsx-tagged-templates/input.js +0 -0
  94. package/{tests → transform/tests}/fixture/not-styled-jsx-tagged-templates/output.js +0 -0
  95. package/{tests → transform/tests}/fixture/number-after-placeholder/input.js +0 -0
  96. package/{tests → transform/tests}/fixture/number-after-placeholder/output.js +0 -0
  97. package/{tests → transform/tests}/fixture/one-off-global-selectors/input.js +0 -0
  98. package/{tests → transform/tests}/fixture/one-off-global-selectors/output.js +0 -0
  99. package/{tests → transform/tests}/fixture/source-maps/input.js +0 -0
  100. package/{tests → transform/tests}/fixture/source-maps/output.js +0 -0
  101. package/{tests → transform/tests}/fixture/stateless/input.js +0 -0
  102. package/{tests → transform/tests}/fixture/stateless/output.js +0 -0
  103. package/{tests → transform/tests}/fixture/styles/input.js +0 -0
  104. package/{tests → transform/tests}/fixture/styles/output.js +0 -0
  105. package/{tests → transform/tests}/fixture/styles-external-invalid/input.js +0 -0
  106. package/{tests → transform/tests}/fixture/styles-external-invalid/output.js +0 -0
  107. package/{tests → transform/tests}/fixture/styles-external-invalid2/input.js +0 -0
  108. package/{tests → transform/tests}/fixture/styles-external-invalid2/output.js +0 -0
  109. package/{tests → transform/tests}/fixture/styles2/input.js +0 -0
  110. package/{tests → transform/tests}/fixture/styles2/output.js +0 -0
  111. package/{tests → transform/tests}/fixture/too-many/input.js +0 -0
  112. package/{tests → transform/tests}/fixture/too-many/output.js +0 -0
  113. package/{tests → transform/tests}/fixture/tpl-escape-1/input.js +0 -0
  114. package/{tests → transform/tests}/fixture/tpl-escape-1/output.js +0 -0
  115. package/{tests → transform/tests}/fixture/tpl-escape-2/input.js +0 -0
  116. package/{tests → transform/tests}/fixture/tpl-escape-2/output.js +0 -0
  117. package/{tests → transform/tests}/fixture/tpl-placeholder-1-as-property/input.js +0 -0
  118. package/{tests → transform/tests}/fixture/tpl-placeholder-1-as-property/output.js +0 -0
  119. package/{tests → transform/tests}/fixture/tpl-placeholder-2-as-part-of-value/input.js +0 -0
  120. package/{tests → transform/tests}/fixture/tpl-placeholder-2-as-part-of-value/output.js +0 -0
  121. package/{tests → transform/tests}/fixture/tpl-placeholder-3-as-value/input.js +0 -0
  122. package/{tests → transform/tests}/fixture/tpl-placeholder-3-as-value/output.js +0 -0
  123. package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/input.js +0 -0
  124. package/{tests → transform/tests}/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.js +0 -0
  125. package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/input.js +0 -0
  126. package/{tests → transform/tests}/fixture/tpl-placeholder-5-values-of-multiple-properties/output.js +0 -0
  127. package/{tests → transform/tests}/fixture/transform-css/input.js +0 -0
  128. package/{tests → transform/tests}/fixture/transform-css/output.js +0 -0
  129. package/{tests → transform/tests}/fixture/transform-css-complex-selector/input.js +0 -0
  130. package/{tests → transform/tests}/fixture/transform-css-complex-selector/output.js +0 -0
  131. package/{tests → transform/tests}/fixture/transform-css-global/input.js +0 -0
  132. package/{tests → transform/tests}/fixture/transform-css-global/output.js +0 -0
  133. package/{tests → transform/tests}/fixture/transform-css-media-query/input.js +0 -0
  134. package/{tests → transform/tests}/fixture/transform-css-media-query/output.js +0 -0
  135. package/{tests → transform/tests}/fixture/transform-css-normal/input.js +0 -0
  136. package/{tests → transform/tests}/fixture/transform-css-normal/output.js +0 -0
  137. package/{tests → transform/tests}/fixture/transform-css-nth-1/input.js +0 -0
  138. package/{tests → transform/tests}/fixture/transform-css-nth-1/output.js +0 -0
  139. package/{tests → transform/tests}/fixture/whitespace/input.js +0 -0
  140. package/{tests → transform/tests}/fixture/whitespace/output.js +0 -0
  141. 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 plugin for styled-jsx"
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.6.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 = { version = "0.34.1", features = [
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
- testing = "0.31.5"
36
- swc_core = { features = [
37
- "testing_transform"
38
- ], version = "0.34.1" }
36
+ swc_core = {features = [
37
+ "testing_transform",
38
+ ], version = "0.38.1"}
39
+ testing = "0.31.8"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swc/plugin-styled-jsx",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "SWC plugin for styled-jsx",
5
5
  "main": "swc_plugin_styled_jsx.wasm",
6
6
  "scripts": {
package/src/lib.rs CHANGED
@@ -1,23 +1,17 @@
1
+ #![allow(clippy::not_unsafe_ptr_arg_deref)]
1
2
  #![feature(box_patterns)]
2
- #[cfg(feature = "plugin")]
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
- let program = program.fold_with(&mut visitor::styled_jsx(cm, FileName::Anon));
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" }
@@ -0,0 +1,5 @@
1
+ #![feature(box_patterns)]
2
+ pub mod style;
3
+ mod transform_css;
4
+ mod utils;
5
+ pub mod visitor;
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::{parse_str, parse_tokens, parser::ParserConfig},
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
@@ -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 {