@swc/plugin-styled-jsx 1.5.76 → 1.5.78
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 +12 -11
- package/package.json +1 -1
- package/src/lib.rs +10 -3
- package/swc_plugin_styled_jsx.wasm +0 -0
- package/transform/Cargo.toml +19 -12
- package/transform/src/lib.rs +2 -1
- package/transform/src/style.rs +2 -1
- package/transform/src/{transform_css.rs → transform_css_lightningcss.rs} +5 -5
- package/transform/src/transform_css_swc.rs +392 -0
- package/transform/src/utils.rs +2 -1
- package/transform/src/visitor.rs +50 -21
- package/transform/tests/errors/nested-style-tags/output.js +31 -4
- package/transform/tests/errors/ts-with-css-resolve/output.js +1 -1
- package/transform/tests/fixture/absent/output.swc.js +7 -0
- package/transform/tests/fixture/attribute-generation-classname-rewriting/output.swc.js +112 -0
- package/transform/tests/fixture/attribute-generation-modes/output.swc.js +228 -0
- package/transform/tests/fixture/class/output.swc.js +12 -0
- package/transform/tests/fixture/comments/output.swc.js +12 -0
- package/transform/tests/fixture/component-attribute/output.swc.js +10 -0
- package/transform/tests/fixture/conflicts/output.swc.js +14 -0
- package/transform/tests/fixture/css-selector-after-pseudo/output.swc.js +11 -0
- package/transform/tests/fixture/css-tag-same-file/output.swc.js +21 -0
- package/transform/tests/fixture/different-jsx-ids/output.swc.js +24 -0
- package/transform/tests/fixture/dynamic-element/output.swc.js +40 -0
- package/transform/tests/fixture/dynamic-element-class/output.swc.js +25 -0
- package/transform/tests/fixture/dynamic-element-external/output.swc.js +12 -0
- package/transform/tests/fixture/dynamic-this-in-arrow/output.swc.js +39 -0
- package/transform/tests/fixture/exported-jsx-style/output.swc.js +1 -0
- package/transform/tests/fixture/exported-non-jsx-style/output.swc.js +1 -0
- package/transform/tests/fixture/external-nested-scope/output.swc.js +7 -0
- package/transform/tests/fixture/external-stylesheet/output.swc.js +34 -0
- package/transform/tests/fixture/external-stylesheet-global/output.swc.js +18 -0
- package/transform/tests/fixture/external-stylesheet-multi-line/output.swc.js +9 -0
- package/transform/tests/fixture/fragment/output.swc.js +47 -0
- package/transform/tests/fixture/global/output.swc.js +7 -0
- package/transform/tests/fixture/global-child-selector/output.swc.js +8 -0
- package/transform/tests/fixture/global-redundant/output.swc.js +10 -0
- package/transform/tests/fixture/issue-30480/output.swc.js +15 -0
- package/transform/tests/fixture/issue-30570/output.swc.js +12 -0
- package/transform/tests/fixture/issue-31562-interpolation-in-mdea/output.swc.js +43 -0
- package/transform/tests/fixture/mixed-global-scoped/output.swc.js +11 -0
- package/transform/tests/fixture/multiple-jsx/output.swc.js +32 -0
- package/transform/tests/fixture/next-54653/output.swc.js +3 -0
- package/transform/tests/fixture/non-styled-jsx-style/output.swc.js +12 -0
- package/transform/tests/fixture/not-styled-jsx-tagged-templates/{output.js → output.lightningcss.js} +1 -2
- package/transform/tests/fixture/not-styled-jsx-tagged-templates/output.swc.js +23 -0
- package/transform/tests/fixture/number-after-placeholder/output.swc.js +17 -0
- package/transform/tests/fixture/one-off-global-selectors/output.swc.js +8 -0
- package/transform/tests/fixture/source-maps/output.swc.js +8 -0
- package/transform/tests/fixture/styles/output.swc.js +39 -0
- package/transform/tests/fixture/styles-external-invalid/output.swc.js +9 -0
- package/transform/tests/fixture/styles-external-invalid2/output.swc.js +8 -0
- package/transform/tests/fixture/styles2/output.swc.js +5 -0
- package/transform/tests/fixture/too-many/output.swc.js +49 -0
- package/transform/tests/fixture/tpl-escape-1/output.swc.js +12 -0
- package/transform/tests/fixture/tpl-escape-2/output.swc.js +17 -0
- package/transform/tests/fixture/tpl-placeholder-1-as-property/output.swc.js +28 -0
- package/transform/tests/fixture/tpl-placeholder-2-as-part-of-value/output.swc.js +34 -0
- package/transform/tests/fixture/tpl-placeholder-3-as-value/output.swc.js +28 -0
- package/transform/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/output.swc.js +31 -0
- package/transform/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/output.swc.js +31 -0
- package/transform/tests/fixture/transform-css/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-complex-selector/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-complex-selector-2/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-global/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-media-query/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-normal/output.swc.js +8 -0
- package/transform/tests/fixture/transform-css-nth-1/output.swc.js +8 -0
- package/transform/tests/fixture/whitespace/output.lightningcss.js +12 -0
- package/transform/tests/fixture/whitespace/output.swc.js +12 -0
- package/transform/tests/fixture.rs +60 -49
- package/transform/tests/fixture/.expressions/output.js +0 -91
- package/transform/tests/fixture/nested-style-tags/output.js +0 -0
- /package/transform/tests/fixture/absent/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/attribute-generation-classname-rewriting/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/attribute-generation-modes/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/class/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/comments/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/component-attribute/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/conflicts/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/css-selector-after-pseudo/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/css-tag-same-file/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/different-jsx-ids/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/dynamic-element/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/dynamic-element-class/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/dynamic-element-external/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/dynamic-this-in-arrow/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/exported-jsx-style/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/exported-non-jsx-style/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/external-nested-scope/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/external-stylesheet/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/external-stylesheet-global/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/external-stylesheet-multi-line/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/fragment/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/global/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/global-child-selector/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/global-redundant/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/issue-30480/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/issue-30570/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/issue-31562-interpolation-in-mdea/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/mixed-global-scoped/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/multiple-jsx/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/next-54653/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/non-styled-jsx-style/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/number-after-placeholder/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/one-off-global-selectors/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/source-maps/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/stateless/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/{whitespace/output.js → stateless/output.swc.js} +0 -0
- /package/transform/tests/fixture/styles/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/styles-external-invalid/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/styles-external-invalid2/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/styles2/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/too-many/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-escape-1/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-escape-2/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-placeholder-1-as-property/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-placeholder-2-as-part-of-value/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-placeholder-3-as-value/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-placeholder-4-as-part-of-value-in-multiple/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/tpl-placeholder-5-values-of-multiple-properties/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-complex-selector/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-complex-selector-2/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-global/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-media-query/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-normal/{output.js → output.lightningcss.js} +0 -0
- /package/transform/tests/fixture/transform-css-nth-1/{output.js → output.lightningcss.js} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-4a27e5cf1c34b3df"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-4a27e5cf1c34b3df"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"4a27e5cf1c34b3df"}>{'html.jsx-4a27e5cf1c34b3df{background-image:-webkit-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:-moz-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:-o-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:linear-gradient(0deg,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg)}p{color:#001}p{color:#002}p,a.jsx-4a27e5cf1c34b3df{color:#003}.foo+a{color:#004}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}p.jsx-4a27e5cf1c34b3df{color:#005}p.jsx-4a27e5cf1c34b3df{color:#006}*.jsx-4a27e5cf1c34b3df{color:#007}[href="woot"].jsx-4a27e5cf1c34b3df{color:#008}p.jsx-4a27e5cf1c34b3df a.jsx-4a27e5cf1c34b3df span.jsx-4a27e5cf1c34b3df{color:#009}p.jsx-4a27e5cf1c34b3df span{background:#00a}p.jsx-4a27e5cf1c34b3df a[title="\'w \' \' t\'"].jsx-4a27e5cf1c34b3df{margin:auto}p.jsx-4a27e5cf1c34b3df span:not(.test){color:#00b}p.jsx-4a27e5cf1c34b3df,h1.jsx-4a27e5cf1c34b3df{color:#00c;-webkit-animation:hahaha 3s ease forwards infinite;-moz-animation:hahaha 3s ease forwards infinite;-o-animation:hahaha 3s ease forwards infinite;animation:hahaha 3s ease forwards infinite;-webkit-animation-name:hahaha;-moz-animation-name:hahaha;-o-animation-name:hahaha;animation-name:hahaha;-webkit-animation-delay:100ms;-moz-animation-delay:100ms;-o-animation-delay:100ms;animation-delay:100ms}p.jsx-4a27e5cf1c34b3df{-webkit-animation:hahaha 1s,hehehe 2s;-moz-animation:hahaha 1s,hehehe 2s;-o-animation:hahaha 1s,hehehe 2s;animation:hahaha 1s,hehehe 2s}p.jsx-4a27e5cf1c34b3df:hover{color:#00d}p.jsx-4a27e5cf1c34b3df::before{color:#00e}.jsx-4a27e5cf1c34b3df:hover{color:#00f}.jsx-4a27e5cf1c34b3df::before{color:#010}.jsx-4a27e5cf1c34b3df:hover p.jsx-4a27e5cf1c34b3df{color:#011}p.jsx-4a27e5cf1c34b3df+a.jsx-4a27e5cf1c34b3df{color:#012}p.jsx-4a27e5cf1c34b3df~a.jsx-4a27e5cf1c34b3df{color:#013}p.jsx-4a27e5cf1c34b3df>a.jsx-4a27e5cf1c34b3df{color:#014}@-webkit-keyframes hahaha{from{top:0}to{top:100}}@-moz-keyframes hahaha{from{top:0}to{top:100}}@-o-keyframes hahaha{from{top:0}to{top:100}}@keyframes hahaha{from{top:0}to{top:100}}@-webkit-keyframes hehehe{from{left:0}to{left:100}}@-moz-keyframes hehehe{from{left:0}to{left:100}}@-o-keyframes hehehe{from{left:0}to{left:100}}@keyframes hehehe{from{left:0}to{left:100}}@media(min-width:500px){.test.jsx-4a27e5cf1c34b3df{color:#015}}.test.jsx-4a27e5cf1c34b3df{display:block}.inline-flex.jsx-4a27e5cf1c34b3df{display:-webkit-inline-box;display:-webkit-inline-flex;display:-moz-inline-box;display:-ms-inline-flexbox;display:inline-flex}.flex.jsx-4a27e5cf1c34b3df{display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex}.test.jsx-4a27e5cf1c34b3df{-webkit-box-shadow:0 0 10px black,inset 0 0 5px black;-moz-box-shadow:0 0 10px black,inset 0 0 5px black;box-shadow:0 0 10px black,inset 0 0 5px black}.test[title=","].jsx-4a27e5cf1c34b3df{display:inline-block}.test.is-status.jsx-4a27e5cf1c34b3df .test.jsx-4a27e5cf1c34b3df{color:#016}.a-selector.jsx-4a27e5cf1c34b3df:hover,.a-selector.jsx-4a27e5cf1c34b3df:focus{outline:none}@media(min-width:1px)and (max-width:768px){[class*="grid__col--"].jsx-4a27e5cf1c34b3df{margin-top:12px;margin-bottom:12px}}@media(max-width:64em){.test.jsx-4a27e5cf1c34b3df{margin-bottom:1em}@supports(-moz-appearance:none)and (display:contents){.test.jsx-4a27e5cf1c34b3df{margin-bottom:2rem}}}'}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-713499aa363d6373"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-713499aa363d6373"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"713499aa363d6373"}>{"p.jsx-713499aa363d6373 a.jsx-713499aa363d6373 span.jsx-713499aa363d6373{color:red}p.jsx-713499aa363d6373 span{background:blue}p.jsx-713499aa363d6373 a[title=\"'w ' ' t'\"].jsx-713499aa363d6373{margin:auto}p.jsx-713499aa363d6373 span:not(.test){color:green}p.jsx-713499aa363d6373,h1.jsx-713499aa363d6373{color:blue;-webkit-animation:hahaha 3s ease forwards infinite;-moz-animation:hahaha 3s ease forwards infinite;-o-animation:hahaha 3s ease forwards infinite;animation:hahaha 3s ease forwards infinite;-webkit-animation-name:hahaha;-moz-animation-name:hahaha;-o-animation-name:hahaha;animation-name:hahaha;-webkit-animation-delay:100ms;-moz-animation-delay:100ms;-o-animation-delay:100ms;animation-delay:100ms}p.jsx-713499aa363d6373{-webkit-animation:hahaha 1s,hehehe 2s;-moz-animation:hahaha 1s,hehehe 2s;-o-animation:hahaha 1s,hehehe 2s;animation:hahaha 1s,hehehe 2s}p.jsx-713499aa363d6373:hover{color:red}p.jsx-713499aa363d6373::before{color:red}.jsx-713499aa363d6373:hover{color:red}.jsx-713499aa363d6373::before{color:red}.jsx-713499aa363d6373:hover p.jsx-713499aa363d6373{color:red}p.jsx-713499aa363d6373+a.jsx-713499aa363d6373{color:red}p.jsx-713499aa363d6373~a.jsx-713499aa363d6373{color:red}p.jsx-713499aa363d6373>a.jsx-713499aa363d6373{color:red}@-webkit-keyframes hahaha{from{top:0}to{top:100}}@-moz-keyframes hahaha{from{top:0}to{top:100}}@-o-keyframes hahaha{from{top:0}to{top:100}}@keyframes hahaha{from{top:0}to{top:100}}@-webkit-keyframes hehehe{from{left:0}to{left:100}}@-moz-keyframes hehehe{from{left:0}to{left:100}}@-o-keyframes hehehe{from{left:0}to{left:100}}@keyframes hehehe{from{left:0}to{left:100}}@media(min-width:500px){.test.jsx-713499aa363d6373{color:red}}.test.jsx-713499aa363d6373{display:block}.inline-flex.jsx-713499aa363d6373{display:-webkit-inline-box;display:-webkit-inline-flex;display:-moz-inline-box;display:-ms-inline-flexbox;display:inline-flex}.flex.jsx-713499aa363d6373{display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex}.test.jsx-713499aa363d6373{-webkit-box-shadow:0 0 10px black,inset 0 0 5px black;-moz-box-shadow:0 0 10px black,inset 0 0 5px black;box-shadow:0 0 10px black,inset 0 0 5px black}.test[title=\",\"].jsx-713499aa363d6373{display:inline-block}.test.is-status.jsx-713499aa363d6373 .test.jsx-713499aa363d6373{color:red}.a-selector.jsx-713499aa363d6373:hover,.a-selector.jsx-713499aa363d6373:focus{outline:none}"}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-efc590d693035654"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-efc590d693035654"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"efc590d693035654"}>{".a-selector.jsx-efc590d693035654:hover,.a-selector.jsx-efc590d693035654:focus{outline:none}"}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-6881055ff9b1aeb6"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-6881055ff9b1aeb6"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"6881055ff9b1aeb6"}>{'html.jsx-6881055ff9b1aeb6{background-image:-webkit-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:-moz-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:-o-linear-gradient(bottom,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg);background-image:linear-gradient(0deg,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg)}p{color:#001}h1{color:#002}h2,a.jsx-6881055ff9b1aeb6{color:#003}.foo+a{color:#004}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}'}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-1f7963ae04c6466a"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-1f7963ae04c6466a"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"1f7963ae04c6466a"}>{'@media(min-width:1px)and (max-width:768px){[class*="grid__col--"].jsx-1f7963ae04c6466a{margin-top:12px;margin-bottom:12px}}@media(max-width:64em){.test.jsx-1f7963ae04c6466a{margin-bottom:1em}@supports(-moz-appearance:none)and (display:contents){.test.jsx-1f7963ae04c6466a{margin-bottom:2rem}}}'}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-1a19bb4817c105dd"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-1a19bb4817c105dd"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"1a19bb4817c105dd"}>{'p.jsx-1a19bb4817c105dd{color:red}p.jsx-1a19bb4817c105dd{color:red}*.jsx-1a19bb4817c105dd{color:blue}[href="woot"].jsx-1a19bb4817c105dd{color:red}'}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-938ca197692ef624"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-938ca197692ef624"}>test</p>
|
|
5
|
+
|
|
6
|
+
<_JSXStyle id={"938ca197692ef624"}>{"li.jsx-938ca197692ef624:nth-child(2){color:lime}"}</_JSXStyle>
|
|
7
|
+
|
|
8
|
+
</div>);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-94239b6d6b42c9b5"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-94239b6d6b42c9b5"}>test</p>
|
|
5
|
+
|
|
6
|
+
<p className={"jsx-94239b6d6b42c9b5"}>woot</p>
|
|
7
|
+
|
|
8
|
+
<p className={"jsx-94239b6d6b42c9b5"}>woot</p>
|
|
9
|
+
|
|
10
|
+
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-94239b6d6b42c9b5{color:red}"}</_JSXStyle>
|
|
11
|
+
|
|
12
|
+
</div>);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import _JSXStyle from "styled-jsx/style";
|
|
2
|
+
export default (()=><div className={"jsx-94239b6d6b42c9b5"}>
|
|
3
|
+
|
|
4
|
+
<p className={"jsx-94239b6d6b42c9b5"}>test</p>
|
|
5
|
+
|
|
6
|
+
<p className={"jsx-94239b6d6b42c9b5"}>woot</p>
|
|
7
|
+
|
|
8
|
+
<p className={"jsx-94239b6d6b42c9b5"}>woot</p>
|
|
9
|
+
|
|
10
|
+
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-94239b6d6b42c9b5{color:red}"}</_JSXStyle>
|
|
11
|
+
|
|
12
|
+
</div>);
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
use std::path::PathBuf;
|
|
2
2
|
|
|
3
3
|
use styled_jsx::visitor::styled_jsx;
|
|
4
|
-
use
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
transforms::{
|
|
9
|
-
base::resolver,
|
|
10
|
-
testing::{test_fixture, FixtureTestConfig},
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
4
|
+
use swc_common::{chain, FileName, Mark, Span, DUMMY_SP};
|
|
5
|
+
use swc_ecma_parser::{EsConfig, Syntax};
|
|
6
|
+
use swc_ecma_transforms::resolver;
|
|
7
|
+
use swc_ecma_transforms_testing::{test_fixture, FixtureTestConfig};
|
|
14
8
|
use testing::fixture;
|
|
15
9
|
|
|
16
10
|
fn syntax() -> Syntax {
|
|
@@ -22,51 +16,60 @@ fn syntax() -> Syntax {
|
|
|
22
16
|
|
|
23
17
|
#[fixture("tests/fixture/**/input.js")]
|
|
24
18
|
fn styled_jsx_fixture(input: PathBuf) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
for use_lightningcss in [true, false] {
|
|
20
|
+
let output = input.parent().unwrap().join(if use_lightningcss {
|
|
21
|
+
"output.lightningcss.js"
|
|
22
|
+
} else {
|
|
23
|
+
"output.swc.js"
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test_fixture(
|
|
27
|
+
syntax(),
|
|
28
|
+
&|t| {
|
|
29
|
+
chain!(
|
|
30
|
+
resolver(Mark::new(), Mark::new(), false),
|
|
31
|
+
styled_jsx(
|
|
32
|
+
t.cm.clone(),
|
|
33
|
+
FileName::Real(PathBuf::from("/some-project/src/some-file.js")),
|
|
34
|
+
styled_jsx::visitor::Config { use_lightningcss }
|
|
35
|
+
)
|
|
34
36
|
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
);
|
|
37
|
+
},
|
|
38
|
+
&input,
|
|
39
|
+
&output,
|
|
40
|
+
Default::default(),
|
|
41
|
+
);
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
test_fixture(
|
|
44
|
+
syntax(),
|
|
45
|
+
&|t| {
|
|
46
|
+
// `resolver` uses `Mark` which is stored in a thread-local storage (namely
|
|
47
|
+
// swc_common::GLOBALS), and this loop will make `Mark` to be different from the
|
|
48
|
+
// invocation above.
|
|
49
|
+
//
|
|
50
|
+
// 1000 is used because in future I (kdy1) may optimize logic of resolver.
|
|
51
|
+
for _ in 0..1000 {
|
|
52
|
+
let _mark = Mark::fresh(Mark::root());
|
|
53
|
+
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
chain!(
|
|
56
|
+
resolver(Mark::new(), Mark::new(), false),
|
|
57
|
+
styled_jsx(
|
|
58
|
+
t.cm.clone(),
|
|
59
|
+
FileName::Real(PathBuf::from("/some-project/src/some-file.js")),
|
|
60
|
+
styled_jsx::visitor::Config { use_lightningcss }
|
|
61
|
+
)
|
|
59
62
|
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
},
|
|
64
|
+
&input,
|
|
65
|
+
&output,
|
|
66
|
+
Default::default(),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
pub struct DropSpan;
|
|
69
|
-
impl
|
|
72
|
+
impl swc_ecma_visit::VisitMut for DropSpan {
|
|
70
73
|
fn visit_mut_span(&mut self, span: &mut Span) {
|
|
71
74
|
*span = DUMMY_SP
|
|
72
75
|
}
|
|
@@ -82,7 +85,15 @@ fn styled_jsx_errors(input: PathBuf) {
|
|
|
82
85
|
|
|
83
86
|
test_fixture(
|
|
84
87
|
syntax(),
|
|
85
|
-
&|t|
|
|
88
|
+
&|t| {
|
|
89
|
+
styled_jsx(
|
|
90
|
+
t.cm.clone(),
|
|
91
|
+
file_name.clone(),
|
|
92
|
+
styled_jsx::visitor::Config {
|
|
93
|
+
use_lightningcss: false,
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
},
|
|
86
97
|
&input,
|
|
87
98
|
&output,
|
|
88
99
|
FixtureTestConfig {
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
const darken = (c)=>c;
|
|
3
|
-
const color = 'red';
|
|
4
|
-
const otherColor = 'green';
|
|
5
|
-
const mediumScreen = '680px';
|
|
6
|
-
const animationDuration = '200ms';
|
|
7
|
-
const animationName = 'my-cool-animation';
|
|
8
|
-
const obj = {
|
|
9
|
-
display: 'block'
|
|
10
|
-
};
|
|
11
|
-
export default (({ display })=><div className={"jsx-b452af554142d27 " + _JSXStyle.dynamic([
|
|
12
|
-
[
|
|
13
|
-
"469c0b1cc43512b8",
|
|
14
|
-
[
|
|
15
|
-
display ? 'block' : 'none'
|
|
16
|
-
]
|
|
17
|
-
],
|
|
18
|
-
[
|
|
19
|
-
"d05e300c372f73ee",
|
|
20
|
-
[
|
|
21
|
-
darken(color) + 2
|
|
22
|
-
]
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
"72e421eb2017491a",
|
|
26
|
-
[
|
|
27
|
-
darken(color)
|
|
28
|
-
]
|
|
29
|
-
]
|
|
30
|
-
])}>
|
|
31
|
-
|
|
32
|
-
<p className={"jsx-b452af554142d27 " + _JSXStyle.dynamic([
|
|
33
|
-
[
|
|
34
|
-
"469c0b1cc43512b8",
|
|
35
|
-
[
|
|
36
|
-
display ? 'block' : 'none'
|
|
37
|
-
]
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
"d05e300c372f73ee",
|
|
41
|
-
[
|
|
42
|
-
darken(color) + 2
|
|
43
|
-
]
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
"72e421eb2017491a",
|
|
47
|
-
[
|
|
48
|
-
darken(color)
|
|
49
|
-
]
|
|
50
|
-
]
|
|
51
|
-
])}>test</p>
|
|
52
|
-
|
|
53
|
-
<_JSXStyle id={"cb56eab0db38d266"}>{`p.${color}.jsx-b452af554142d27{color:${otherColor};display:${obj.display}}`}</_JSXStyle>
|
|
54
|
-
|
|
55
|
-
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-b452af554142d27{color:red}"}</_JSXStyle>
|
|
56
|
-
|
|
57
|
-
<_JSXStyle id={"e66306ac259712aa"}>{`body{background:${color}}`}</_JSXStyle>
|
|
58
|
-
|
|
59
|
-
<_JSXStyle id={"e66306ac259712aa"}>{`body{background:${color}}`}</_JSXStyle>
|
|
60
|
-
|
|
61
|
-
// TODO: the next two should have the same hash
|
|
62
|
-
|
|
63
|
-
<_JSXStyle id={"f08108daf927b99d"}>{`p.jsx-b452af554142d27{color:${color}}`}</_JSXStyle>
|
|
64
|
-
|
|
65
|
-
<_JSXStyle id={"f08108daf927b99d"}>{`p.jsx-b452af554142d27{color:${color}}`}</_JSXStyle>
|
|
66
|
-
|
|
67
|
-
<_JSXStyle id={"72e421eb2017491a"} dynamic={[
|
|
68
|
-
darken(color)
|
|
69
|
-
]}>{`p.__jsx-style-dynamic-selector{color:${darken(color)}}`}</_JSXStyle>
|
|
70
|
-
|
|
71
|
-
<_JSXStyle id={"d05e300c372f73ee"} dynamic={[
|
|
72
|
-
darken(color) + 2
|
|
73
|
-
]}>{`p.__jsx-style-dynamic-selector{color:${darken(color) + 2}}`}</_JSXStyle>
|
|
74
|
-
|
|
75
|
-
<_JSXStyle id={"7c5c5bde49d6c65d"}>{`@media(min-width:${mediumScreen}){p.jsx-b452af554142d27{color:green}p.jsx-b452af554142d27{color:${`red`}}}p.jsx-b452af554142d27{color:red}`}</_JSXStyle>
|
|
76
|
-
|
|
77
|
-
<_JSXStyle id={"c5506be0b4762e0b"}>{`p.jsx-b452af554142d27{-webkit-animation-duration:${animationDuration};-moz-animation-duration:${animationDuration};-o-animation-duration:${animationDuration};animation-duration:${animationDuration}}`}</_JSXStyle>
|
|
78
|
-
|
|
79
|
-
<_JSXStyle id={"ed798aa885be9084"}>{`p.jsx-b452af554142d27{-webkit-animation:${animationDuration} forwards ${animationName};-moz-animation:${animationDuration} forwards ${animationName};-o-animation:${animationDuration} forwards ${animationName};animation:${animationDuration} forwards ${animationName}}div.jsx-b452af554142d27{background:${color}}`}</_JSXStyle>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<_JSXStyle id={"469c0b1cc43512b8"} dynamic={[
|
|
84
|
-
display ? 'block' : 'none'
|
|
85
|
-
]}>{`span.__jsx-style-dynamic-selector{display:${display ? 'block' : 'none'}}`}</_JSXStyle>
|
|
86
|
-
|
|
87
|
-
// TODO: causes bad syntax
|
|
88
|
-
|
|
89
|
-
{}
|
|
90
|
-
|
|
91
|
-
</div>);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/attribute-generation-modes/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/css-selector-after-pseudo/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/dynamic-element-external/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/exported-non-jsx-style/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/external-stylesheet-global/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
/package/transform/tests/fixture/external-stylesheet-multi-line/{output.js → output.lightningcss.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
|
/package/transform/tests/fixture/number-after-placeholder/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
/package/transform/tests/fixture/one-off-global-selectors/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/styles-external-invalid/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
/package/transform/tests/fixture/styles-external-invalid2/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/tpl-placeholder-1-as-property/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/tpl-placeholder-3-as-value/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/transform-css-complex-selector/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/transform/tests/fixture/transform-css-media-query/{output.js → output.lightningcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|