Unverified Commit e57d621f authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

feat(next-swc): Update crates (#35133)

This PR updates crates related to ecmascript to https://github.com/swc-project/swc/commit/d62ef6498dbc169b83f97ff224437d9a70ceddf6

I'll update css crates separately.


This PR also reduces the size of binary.
parent f14f6283
This diff is collapsed.
...@@ -15,19 +15,19 @@ fxhash = "0.2.1" ...@@ -15,19 +15,19 @@ fxhash = "0.2.1"
pathdiff = "0.2.0" pathdiff = "0.2.0"
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
styled_components = "0.17.0" styled_components = "0.18.0"
swc = "0.138.0" swc = "0.146.0"
swc_atoms = "0.2.7" swc_atoms = "0.2.7"
swc_common = { version = "0.17.9", features = ["concurrent", "sourcemap"] } swc_common = { version = "0.17.11", features = ["concurrent", "sourcemap"] }
swc_css = "0.94.0" swc_css = "0.98.0"
swc_ecma_loader = { version = "0.28.0", features = ["node", "lru"] } swc_ecma_loader = { version = "0.29.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.123.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] } swc_ecmascript = { version = "0.130.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_node_base = "0.5.1" swc_node_base = "0.5.1"
swc_stylis = "0.90.0" swc_stylis = "0.94.3"
tracing = {version = "0.1.28", features = ["release_max_level_off"]} tracing = {version = "0.1.28", features = ["release_max_level_off"]}
regex = "1.5" regex = "1.5"
[dev-dependencies] [dev-dependencies]
swc_ecma_transforms_testing = "0.65.0" swc_ecma_transforms_testing = "0.68.0"
testing = "0.18.1" testing = "0.18.1"
walkdir = "2.3.2" walkdir = "2.3.2"
...@@ -39,11 +39,9 @@ use swc::config::ModuleConfig; ...@@ -39,11 +39,9 @@ use swc::config::ModuleConfig;
use swc_common::{self, chain, pass::Optional}; use swc_common::{self, chain, pass::Optional};
use swc_common::{SourceFile, SourceMap}; use swc_common::{SourceFile, SourceMap};
use swc_ecmascript::ast::EsVersion; use swc_ecmascript::ast::EsVersion;
use swc_ecmascript::parser::parse_file_as_module;
use swc_ecmascript::transforms::pass::noop; use swc_ecmascript::transforms::pass::noop;
use swc_ecmascript::{ use swc_ecmascript::visit::Fold;
parser::{lexer::Lexer, Parser, StringInput},
visit::Fold,
};
pub mod amp_attributes; pub mod amp_attributes;
mod auto_cjs; mod auto_cjs;
...@@ -178,9 +176,8 @@ impl TransformOptions { ...@@ -178,9 +176,8 @@ impl TransformOptions {
self.swc.config.module.is_none() && fm.src.contains("module.exports") && { self.swc.config.module.is_none() && fm.src.contains("module.exports") && {
let syntax = self.swc.config.jsc.syntax.unwrap_or_default(); let syntax = self.swc.config.jsc.syntax.unwrap_or_default();
let target = self.swc.config.jsc.target.unwrap_or_else(EsVersion::latest); let target = self.swc.config.jsc.target.unwrap_or_else(EsVersion::latest);
let lexer = Lexer::new(syntax, target, StringInput::from(&*fm), None);
let mut p = Parser::new_from(lexer); parse_file_as_module(fm, syntax, target, None, &mut vec![])
p.parse_module()
.map(|m| contains_cjs(&m)) .map(|m| contains_cjs(&m))
.unwrap_or_default() .unwrap_or_default()
}; };
......
import _JSXStyle from "styled-jsx/style"; import _JSXStyle from "styled-jsx/style";
import styles from "./styles"; import styles from "./styles";
const styles2 = require("./styles2"); const styles2 = require("./styles2");
// external only
export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}> export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>
<p className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>external only</p> <p className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>external only</p>
...@@ -11,6 +12,7 @@ export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__h ...@@ -11,6 +12,7 @@ export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__h
</div> </div>
; ;
// external and static
export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}> export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>
<p className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>external and static</p> <p className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>external and static</p>
...@@ -21,6 +23,7 @@ export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles ...@@ -21,6 +23,7 @@ export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles
</div> </div>
; ;
// external and dynamic
export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
[ [
"332b21af86b0ec6", "332b21af86b0ec6",
...@@ -47,6 +50,7 @@ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " ...@@ -47,6 +50,7 @@ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " "
</div> </div>
; ;
// external, static and dynamic
export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"ec8f36d08fa7aa2c", "ec8f36d08fa7aa2c",
...@@ -75,6 +79,7 @@ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " js ...@@ -75,6 +79,7 @@ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " js
</div> </div>
; ;
// static only
export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}> export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}>
<p className={"jsx-df0159ebd3f9fb6f"}>static only</p> <p className={"jsx-df0159ebd3f9fb6f"}>static only</p>
...@@ -85,6 +90,7 @@ export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}> ...@@ -85,6 +90,7 @@ export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}>
</div> </div>
; ;
// static and dynamic
export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"ec8f36d08fa7aa2c", "ec8f36d08fa7aa2c",
...@@ -111,6 +117,7 @@ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JS ...@@ -111,6 +117,7 @@ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JS
</div> </div>
; ;
// dynamic only
export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
[ [
"332b21af86b0ec6", "332b21af86b0ec6",
...@@ -135,6 +142,7 @@ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([ ...@@ -135,6 +142,7 @@ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
</div> </div>
; ;
// dynamic with scoped compound variable
export const Test8 = ({ color })=>{ export const Test8 = ({ color })=>{
if (color) { if (color) {
const innerProps = { const innerProps = {
...@@ -165,6 +173,7 @@ export const Test8 = ({ color })=>{ ...@@ -165,6 +173,7 @@ export const Test8 = ({ color })=>{
</div>; </div>;
} }
}; };
// dynamic with compound variable
export const Test9 = ({ color })=>{ export const Test9 = ({ color })=>{
const innerProps = { const innerProps = {
color color
...@@ -194,6 +203,7 @@ export const Test9 = ({ color })=>{ ...@@ -194,6 +203,7 @@ export const Test9 = ({ color })=>{
</div>; </div>;
}; };
const foo = "red"; const foo = "red";
// dynamic with constant variable
export const Test10 = ()=><div className={"jsx-64eb0b4e09da0dd3"}> export const Test10 = ()=><div className={"jsx-64eb0b4e09da0dd3"}>
<p className={"jsx-64eb0b4e09da0dd3"}>dynamic with constant variable</p> <p className={"jsx-64eb0b4e09da0dd3"}>dynamic with constant variable</p>
...@@ -202,6 +212,7 @@ export const Test10 = ()=><div className={"jsx-64eb0b4e09da0dd3"}> ...@@ -202,6 +212,7 @@ export const Test10 = ()=><div className={"jsx-64eb0b4e09da0dd3"}>
</div> </div>
; ;
// dynamic with complex scope
export const Test11 = ({ color })=>{ export const Test11 = ({ color })=>{
const items = Array.from({ const items = Array.from({
length: 5 length: 5
......
import _JSXStyle from "styled-jsx/style"; import _JSXStyle from "styled-jsx/style";
function NavigationItem({ active , className }) { function NavigationItem({ active , className , }) {
return <span className={"jsx-2342aae4628612c6" + " " + (cn({ return <span className={"jsx-2342aae4628612c6" + " " + (cn({
active active
}, className, "navigation-item") || "")}> }, className, "navigation-item") || "")}>
......
...@@ -75,9 +75,9 @@ export default (({ display })=><div className={"jsx-1ada4ad4dab7822f " + _JSXSt ...@@ -75,9 +75,9 @@ export default (({ display })=><div className={"jsx-1ada4ad4dab7822f " + _JSXSt
<_JSXStyle id={"4e4be2da62837c76"}>{`@media(min-width:${mediumScreen}){p.jsx-1ada4ad4dab7822f{color:green}p.jsx-1ada4ad4dab7822f{color:${`red`}}}p.jsx-1ada4ad4dab7822f{color:red}`}</_JSXStyle> <_JSXStyle id={"4e4be2da62837c76"}>{`@media(min-width:${mediumScreen}){p.jsx-1ada4ad4dab7822f{color:green}p.jsx-1ada4ad4dab7822f{color:${`red`}}}p.jsx-1ada4ad4dab7822f{color:red}`}</_JSXStyle>
<_JSXStyle id={"27040f0829fb73d4"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation-duration:${animationDuration};animation-duration:${animationDuration}}`}</_JSXStyle> <_JSXStyle id={"27040f0829fb73d4"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation-duration:${animationDuration};-moz-animation-duration:${animationDuration};-o-animation-duration:${animationDuration};animation-duration:${animationDuration}}`}</_JSXStyle>
<_JSXStyle id={"3e72d735e703a530"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation:${animationDuration} forwards ${animationName};animation:${animationDuration} forwards ${animationName}}div.jsx-1ada4ad4dab7822f{background:${color}}`}</_JSXStyle> <_JSXStyle id={"3e72d735e703a530"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation:${animationDuration} forwards ${animationName};-moz-animation:${animationDuration} forwards ${animationName};-o-animation:${animationDuration} forwards ${animationName};animation:${animationDuration} forwards ${animationName}}div.jsx-1ada4ad4dab7822f{background:${color}}`}</_JSXStyle>
......
import _JSXStyle from "styled-jsx/style"; import _JSXStyle from "styled-jsx/style";
const Test = ()=><div className={"jsx-d47d6adadf14e957"}> const Test = ()=><div className={"jsx-d47d6adadf14e957"}>
<_JSXStyle id={"d47d6adadf14e957"}>{"body{color:red}:hover{color:red;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-animation:foo 1s ease-out;animation:foo 1s ease-out}div a{display:none}[data-test]>div{color:red}"}</_JSXStyle> <_JSXStyle id={"d47d6adadf14e957"}>{"body{color:red}:hover{color:red;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-animation:foo 1s ease-out;-moz-animation:foo 1s ease-out;-o-animation:foo 1s ease-out;animation:foo 1s ease-out}div a{display:none}[data-test]>div{color:red}"}</_JSXStyle>
</div> </div>
; ;
......
import _JSXStyle from "styled-jsx/style"; import _JSXStyle from "styled-jsx/style";
export const Red = ({ Component ="button" })=>{ export const Red = ({ Component ="button" , })=>{
return <Component className={_JSXStyle.dynamic([ return <Component className={_JSXStyle.dynamic([
[ [
"ca900d186ad0e495", "ca900d186ad0e495",
......
...@@ -3,7 +3,7 @@ export default (()=><div className={"jsx-713499aa363d6373"}> ...@@ -3,7 +3,7 @@ export default (()=><div className={"jsx-713499aa363d6373"}>
<p className={"jsx-713499aa363d6373"}>test</p> <p className={"jsx-713499aa363d6373"}>test</p>
<_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;animation:hahaha 3s ease forwards infinite;-webkit-animation-name:hahaha;animation-name:hahaha;animation-delay:100ms}p.jsx-713499aa363d6373{-webkit-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}@keyframes hahaha{from{top:0}to{top: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:-ms-inline-flexbox;display:inline-flex}.flex.jsx-713499aa363d6373{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.test.jsx-713499aa363d6373{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> <_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}@keyframes hahaha{from{top:0}to{top: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{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>
</div> </div>
); );
...@@ -3,7 +3,7 @@ export default (()=><div className={"jsx-768337a97aceabd1"}> ...@@ -3,7 +3,7 @@ export default (()=><div className={"jsx-768337a97aceabd1"}>
<p className={"jsx-768337a97aceabd1"}>test</p> <p className={"jsx-768337a97aceabd1"}>test</p>
<_JSXStyle id={"768337a97aceabd1"}>{"html.jsx-768337a97aceabd1{background-image:linear-gradient(0deg,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg)}p{color:blue}p{color:blue}p,a.jsx-768337a97aceabd1{color:blue}.foo+a{color:red}body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif}p.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1{color:red}*.jsx-768337a97aceabd1{color:blue}[href=\"woot\"].jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1 a.jsx-768337a97aceabd1 span.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1 span{background:blue}p.jsx-768337a97aceabd1 a[title=\"'w ' ' t'\"].jsx-768337a97aceabd1{margin:auto}p.jsx-768337a97aceabd1 span:not(.test){color:green}p.jsx-768337a97aceabd1,h1.jsx-768337a97aceabd1{color:blue;-webkit-animation:hahaha 3s ease forwards infinite;animation:hahaha 3s ease forwards infinite;-webkit-animation-name:hahaha;animation-name:hahaha;animation-delay:100ms}p.jsx-768337a97aceabd1{-webkit-animation:hahaha 1s,hehehe 2s;animation:hahaha 1s,hehehe 2s}p.jsx-768337a97aceabd1:hover{color:red}p.jsx-768337a97aceabd1::before{color:red}.jsx-768337a97aceabd1:hover{color:red}.jsx-768337a97aceabd1::before{color:red}.jsx-768337a97aceabd1:hover p.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1+a.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1~a.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1>a.jsx-768337a97aceabd1{color:red}@keyframes hahaha{from{top:0}to{top:100}}@keyframes hehehe{from{left:0}to{left:100}}@media(min-width:500px){.test.jsx-768337a97aceabd1{color:red}}.test.jsx-768337a97aceabd1{display:block}.inline-flex.jsx-768337a97aceabd1{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex}.flex.jsx-768337a97aceabd1{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex}.test.jsx-768337a97aceabd1{box-shadow:0 0 10px black,inset 0 0 5px black}.test[title=\",\"].jsx-768337a97aceabd1{display:inline-block}.test.is-status.jsx-768337a97aceabd1 .test.jsx-768337a97aceabd1{color:red}.a-selector.jsx-768337a97aceabd1:hover,.a-selector.jsx-768337a97aceabd1:focus{outline:none}@media(min-width:1px)and (max-width:768px){[class*=\"grid__col--\"].jsx-768337a97aceabd1{margin-top:12px;margin-bottom:12px}}@media(max-width:64em){.test.jsx-768337a97aceabd1{margin-bottom:1em}@supports(-moz-appearance:none)and (display:contents){.test.jsx-768337a97aceabd1{margin-bottom:2rem}}}"}</_JSXStyle> <_JSXStyle id={"768337a97aceabd1"}>{"html.jsx-768337a97aceabd1{background-image:linear-gradient(0deg,rgba(255,255,255,.8),rgba(255,255,255,.8)),url(/static/background.svg)}p{color:blue}p{color:blue}p,a.jsx-768337a97aceabd1{color:blue}.foo+a{color:red}body{font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif}p.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1{color:red}*.jsx-768337a97aceabd1{color:blue}[href=\"woot\"].jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1 a.jsx-768337a97aceabd1 span.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1 span{background:blue}p.jsx-768337a97aceabd1 a[title=\"'w ' ' t'\"].jsx-768337a97aceabd1{margin:auto}p.jsx-768337a97aceabd1 span:not(.test){color:green}p.jsx-768337a97aceabd1,h1.jsx-768337a97aceabd1{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-768337a97aceabd1{-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-768337a97aceabd1:hover{color:red}p.jsx-768337a97aceabd1::before{color:red}.jsx-768337a97aceabd1:hover{color:red}.jsx-768337a97aceabd1::before{color:red}.jsx-768337a97aceabd1:hover p.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1+a.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1~a.jsx-768337a97aceabd1{color:red}p.jsx-768337a97aceabd1>a.jsx-768337a97aceabd1{color:red}@keyframes hahaha{from{top:0}to{top:100}}@keyframes hehehe{from{left:0}to{left:100}}@media(min-width:500px){.test.jsx-768337a97aceabd1{color:red}}.test.jsx-768337a97aceabd1{display:block}.inline-flex.jsx-768337a97aceabd1{display:-webkit-inline-box;display:-webkit-inline-flex;display:-moz-inline-box;display:-ms-inline-flexbox;display:inline-flex}.flex.jsx-768337a97aceabd1{display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex}.test.jsx-768337a97aceabd1{box-shadow:0 0 10px black,inset 0 0 5px black}.test[title=\",\"].jsx-768337a97aceabd1{display:inline-block}.test.is-status.jsx-768337a97aceabd1 .test.jsx-768337a97aceabd1{color:red}.a-selector.jsx-768337a97aceabd1:hover,.a-selector.jsx-768337a97aceabd1:focus{outline:none}@media(min-width:1px)and (max-width:768px){[class*=\"grid__col--\"].jsx-768337a97aceabd1{margin-top:12px;margin-bottom:12px}}@media(max-width:64em){.test.jsx-768337a97aceabd1{margin-bottom:1em}@supports(-moz-appearance:none)and (display:contents){.test.jsx-768337a97aceabd1{margin-bottom:2rem}}}"}</_JSXStyle>
</div> </div>
); );
...@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style"; ...@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
export default function Foo() { export default function Foo() {
return(/*#__PURE__*/ React.createElement("div", { return(/*#__PURE__*/ React.createElement("div", {
render: function(v) { render: function(v) {
/*#__PURE__*/ return(React.createElement("form", { return(/*#__PURE__*/ React.createElement("form", {
className: "jsx-eb368961fd3b0a99" className: "jsx-eb368961fd3b0a99"
})); }));
}, },
......
...@@ -16,12 +16,12 @@ once_cell = "1.8.0" ...@@ -16,12 +16,12 @@ once_cell = "1.8.0"
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
next-swc = { version = "0.0.0", path = "../core" } next-swc = { version = "0.0.0", path = "../core" }
swc = "0.138.0" swc = "0.146.0"
swc_atoms = "0.2.7" swc_atoms = "0.2.7"
swc_bundler = { version = "0.114.0", features = ["concurrent"] } swc_bundler = { version = "0.120.0", features = ["concurrent"] }
swc_common = { version = "0.17.9", features = ["concurrent", "sourcemap"] } swc_common = { version = "0.17.11", features = ["concurrent", "sourcemap"] }
swc_ecma_loader = { version = "0.28.0", features = ["node", "lru"] } swc_ecma_loader = { version = "0.29.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.123.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] } swc_ecmascript = { version = "0.130.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_node_base = "0.5.1" swc_node_base = "0.5.1"
[build-dependencies] [build-dependencies]
......
...@@ -7,10 +7,7 @@ use napi::{CallContext, JsObject, Task}; ...@@ -7,10 +7,7 @@ use napi::{CallContext, JsObject, Task};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::Deserialize; use serde::Deserialize;
use std::{collections::HashMap, path::PathBuf, sync::Arc}; use std::{collections::HashMap, path::PathBuf, sync::Arc};
use swc::{ use swc::{config::SourceMapsConfig, try_with_handler, TransformOutput};
config::{util::BoolOrObject, SourceMapsConfig},
try_with_handler, TransformOutput,
};
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_bundler::{Bundler, ModuleData, ModuleRecord}; use swc_bundler::{Bundler, ModuleData, ModuleRecord};
use swc_common::{collections::AHashMap, errors::Handler, BytePos, FileName, SourceMap, Span}; use swc_common::{collections::AHashMap, errors::Handler, BytePos, FileName, SourceMap, Span};
...@@ -62,6 +59,7 @@ impl Task for BundleTask { ...@@ -62,6 +59,7 @@ impl Task for BundleTask {
.map(JsWord::from) .map(JsWord::from)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let comments = self.c.comments().clone();
// //
let mut bundler = Bundler::new( let mut bundler = Bundler::new(
self.c.globals(), self.c.globals(),
...@@ -114,7 +112,7 @@ impl Task for BundleTask { ...@@ -114,7 +112,7 @@ impl Task for BundleTask {
&source_map_names, &source_map_names,
None, None,
false, false,
Some(BoolOrObject::Bool(true)), Some(&comments),
)?; )?;
Ok(code) Ok(code)
......
...@@ -3,7 +3,7 @@ use anyhow::Context as _; ...@@ -3,7 +3,7 @@ use anyhow::Context as _;
use napi::{CallContext, Either, Env, JsObject, JsString, JsUndefined, Task}; use napi::{CallContext, Either, Env, JsObject, JsString, JsUndefined, Task};
use std::sync::Arc; use std::sync::Arc;
use swc::{config::ParseOptions, try_with_handler}; use swc::{config::ParseOptions, try_with_handler};
use swc_common::{FileName, FilePathMapping, SourceMap}; use swc_common::{comments::Comments, FileName, FilePathMapping, SourceMap};
pub struct ParseTask { pub struct ParseTask {
pub filename: FileName, pub filename: FileName,
...@@ -23,6 +23,12 @@ impl Task for ParseTask { ...@@ -23,6 +23,12 @@ impl Task for ParseTask {
let c = swc::Compiler::new(Arc::new(SourceMap::new(FilePathMapping::empty()))); let c = swc::Compiler::new(Arc::new(SourceMap::new(FilePathMapping::empty())));
let options: ParseOptions = deserialize_json(&self.options).convert_err()?; let options: ParseOptions = deserialize_json(&self.options).convert_err()?;
let comments = c.comments().clone();
let comments: Option<&dyn Comments> = if options.comments {
Some(&comments)
} else {
None
};
let fm = let fm =
c.cm.new_source_file(self.filename.clone(), self.src.clone()); c.cm.new_source_file(self.filename.clone(), self.src.clone());
let program = try_with_handler(c.cm.clone(), false, |handler| { let program = try_with_handler(c.cm.clone(), false, |handler| {
...@@ -32,7 +38,7 @@ impl Task for ParseTask { ...@@ -32,7 +38,7 @@ impl Task for ParseTask {
options.target, options.target,
options.syntax, options.syntax,
options.is_module, options.is_module,
options.comments, comments,
) )
}) })
.convert_err()?; .convert_err()?;
......
...@@ -16,9 +16,9 @@ path-clean = "0.1" ...@@ -16,9 +16,9 @@ path-clean = "0.1"
serde = {version = "1", features = ["derive"]} serde = {version = "1", features = ["derive"]}
serde_json = "1" serde_json = "1"
next-swc = { version = "0.0.0", path = "../core" } next-swc = { version = "0.0.0", path = "../core" }
swc = "0.138.0" swc = "0.146.0"
swc_common = { version = "0.17.9", features = ["concurrent", "sourcemap"] } swc_common = { version = "0.17.11", features = ["concurrent", "sourcemap"] }
swc_ecmascript = { version = "0.123.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] } swc_ecmascript = { version = "0.130.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
tracing = {version = "0.1.28", features = ["release_max_level_off"]} tracing = {version = "0.1.28", features = ["release_max_level_off"]}
wasm-bindgen = {version = "0.2", features = ["serde-serialize"]} wasm-bindgen = {version = "0.2", features = ["serde-serialize"]}
wasm-bindgen-futures = "0.4.8" wasm-bindgen-futures = "0.4.8"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment