Skip to content

Commit

Permalink
Update swc_core
Browse files Browse the repository at this point in the history
Closes GH-11.
  • Loading branch information
jridgewell committed Jan 21, 2023
1 parent f9b50c0 commit a298980
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ serializable = ["serde"]
[dependencies]
markdown = "1.0.0-alpha.5"
serde = { version = "1", optional = true }
swc_core = { version = "0.48.0", features = [
swc_core = { version = "0.56.0", features = [
"ecma_ast",
"ecma_visit",
"ecma_codegen",
Expand Down
16 changes: 8 additions & 8 deletions src/hast_util_to_swc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ mod tests {
.module,
None
),
"<a >{\"a\"}</a>;\n",
"<a>{\"a\"}</a>;\n",
"should support an `Element` w/ children",
);

Expand All @@ -835,7 +835,7 @@ mod tests {
.module,
None
),
"<svg />;\n",
"<svg/>;\n",
"should support an `Element` in the SVG space",
);

Expand Down Expand Up @@ -897,7 +897,7 @@ mod tests {
.module,
None
),
"<a />;\n",
"<a/>;\n",
"should support an `Element` w/ a boolean (false) attribute",
);

Expand Down Expand Up @@ -1034,7 +1034,7 @@ mod tests {
.module,
None
),
"<a />;\n",
"<a/>;\n",
"should support an `MdxElement` (element, no children)",
);
assert_eq!(
Expand All @@ -1055,7 +1055,7 @@ mod tests {
.module,
None
),
"<a >{\"b\"}</a>;\n",
"<a>{\"b\"}</a>;\n",
"should support an `MdxElement` (element, children)",
);

Expand All @@ -1079,7 +1079,7 @@ mod tests {
.module,
None
),
"<a:b />;\n",
"<a:b/>;\n",
"should support an `MdxElement` (element, namespace id)",
);

Expand All @@ -1098,7 +1098,7 @@ mod tests {
.module,
None
),
"<a.b.c />;\n",
"<a.b.c/>;\n",
"should support an `MdxElement` (element, member expression)",
);

Expand All @@ -1117,7 +1117,7 @@ mod tests {
.module,
None
),
"<svg />;\n",
"<svg/>;\n",
"should support an `MdxElement` (element, `<svg>`)",
);

Expand Down
8 changes: 4 additions & 4 deletions src/mdx_plugin_recma_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ mod tests {
assert_eq!(
compile("# hi\n\nAlpha *bravo* **charlie**.")?,
"function _createMdxContent(props) {
return <><h1 >{\"hi\"}</h1>{\"\\n\"}<p >{\"Alpha \"}<em >{\"bravo\"}</em>{\" \"}<strong >{\"charlie\"}</strong>{\".\"}</p></>;
return <><h1>{\"hi\"}</h1>{\"\\n\"}<p>{\"Alpha \"}<em>{\"bravo\"}</em>{\" \"}<strong>{\"charlie\"}</strong>{\".\"}</p></>;
}
function MDXContent(props = {}) {
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props}/></MDXLayout> : _createMdxContent(props);
Expand All @@ -603,7 +603,7 @@ export default MDXContent;
compile("import a from 'b'\n\n# {a}")?,
"import a from 'b';
function _createMdxContent(props) {
return <h1 >{a}</h1>;
return <h1>{a}</h1>;
}
function MDXContent(props = {}) {
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props}/></MDXLayout> : _createMdxContent(props);
Expand All @@ -622,7 +622,7 @@ export default MDXContent;
compile("export * from 'a'\n\n# b")?,
"export * from 'a';
function _createMdxContent(props) {
return <h1 >{\"b\"}</h1>;
return <h1>{\"b\"}</h1>;
}
function MDXContent(props = {}) {
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props}/></MDXLayout> : _createMdxContent(props);
Expand Down Expand Up @@ -1011,7 +1011,7 @@ export default MDXContent;
assert_eq!(
serialize(&mut program.module, None),
"function _createMdxContent(props) {
return <a >b</a>;
return <a>b</a>;
}
function MDXContent(props = {}) {
return MDXLayout ? <MDXLayout {...props}><_createMdxContent {...props}/></MDXLayout> : _createMdxContent(props);
Expand Down
52 changes: 26 additions & 26 deletions src/mdx_plugin_recma_jsx_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ export default MDXContent;
const _components = Object.assign({
h1: \"h1\"
}, props.components);
return <_components.h1 >{\"hi\"}</_components.h1>;
return <_components.h1>{\"hi\"}</_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1076,7 +1076,7 @@ export default MDXContent;
const _components = Object.assign({
\"a:b\": \"a:b\"
}, props.components), _component0 = _components[\"a:b\"];
return <_component0 />;
return <_component0/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1103,7 +1103,7 @@ function _createMdxContent(props) {
const _components = Object.assign({
h1: \"h1\"
}, props.components);
return <_components.h1 >{\"hi\"}</_components.h1>;
return <_components.h1>{\"hi\"}</_components.h1>;
}
function MDXContent(props = {}) {
return <MDXLayout {...props}><_createMdxContent {...props}/></MDXLayout>;
Expand All @@ -1125,7 +1125,7 @@ export default MDXContent;
h1: \"h1\"
}, props.components), { Hi } = _components;
if (!Hi) _missingMdxReference(\"Hi\", true);
return <_components.h1 ><Hi /></_components.h1>;
return <_components.h1><Hi/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand Down Expand Up @@ -1158,7 +1158,7 @@ function _missingMdxReference(id, component) {
if (!a.b) _missingMdxReference(\"a.b\", true);
if (!a.b.c) _missingMdxReference(\"a.b.c\", false);
if (!a.b.c.d) _missingMdxReference(\"a.b.c.d\", true);
return <_components.p ><X />{\", \"}<X.y />{\", \"}<Y.Z />{\", \"}<a.b.c.d />{\", \"}<a.b /></_components.p>;
return <_components.p><X/>{\", \"}<X.y/>{\", \"}<Y.Z/>{\", \"}<a.b.c.d/>{\", \"}<a.b/></_components.p>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand Down Expand Up @@ -1187,7 +1187,7 @@ function _missingMdxReference(id, component) {
}, props.components), _component0 = _components[\"a-b\"], _component1 = _components[\"qwe-rty\"], _component2 = _components[\"c-d\"];
if (!_component2) _missingMdxReference(\"c-d\", false);
if (!_component2[\"e-f\"]) _missingMdxReference(\"c-d.e-f\", true);
return <_components.h1 ><_component0 />{\", \"}<_component1 />{\", \"}<_component0 />{\", \"}<_component2.e-f /></_components.h1>;
return <_components.h1><_component0/>{\", \"}<_component1/>{\", \"}<_component0/>{\", \"}<_component2.e-f/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1213,7 +1213,7 @@ function _createMdxContent(props) {
const _components = Object.assign({
h1: \"h1\"
}, props.components);
return <_components.h1 ><Hi /></_components.h1>;
return <_components.h1><Hi/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1236,7 +1236,7 @@ export default MDXContent;
)?,
"import * as X from './a.js';
function _createMdxContent(props) {
return <X />;
return <X/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1263,10 +1263,10 @@ export default MDXContent;
&Options::default(), true
)?,
"export function A() {
return <B />;
return <B/>;
}
function _createMdxContent(props) {
return <A />;
return <A/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand All @@ -1293,7 +1293,7 @@ export default MDXContent;
"export class A {
}
function _createMdxContent(props) {
return <A />;
return <A/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand Down Expand Up @@ -1323,7 +1323,7 @@ function _createMdxContent(props) {
h1: \"h1\"
}, _provideComponents(), props.components), { Hi } = _components;
if (!Hi) _missingMdxReference(\"Hi\", true);
return <_components.h1 ><Hi /></_components.h1>;
return <_components.h1><Hi/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = Object.assign({}, _provideComponents(), props.components);
Expand Down Expand Up @@ -1385,10 +1385,10 @@ export default MDXContent;
export function A() {
const { B } = _provideComponents();
if (!B) _missingMdxReference(\"B\", true);
return <B />;
return <B/>;
}
function _createMdxContent(props) {
return <A />;
return <A/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = Object.assign({}, _provideComponents(), props.components);
Expand Down Expand Up @@ -1433,7 +1433,7 @@ export function X(x) {
let { ...D } = x;
let { _: E } = x;
let { F =_ } = x;
return <><A /><B /><C /><D /><E /><F /><G /></>;
return <><A/><B/><C/><D/><E/><F/><G/></>;
}
function _createMdxContent(props) {
return <></>;
Expand Down Expand Up @@ -1546,7 +1546,7 @@ export function A() {
let B = true;
})();
((B)=>{})();
return <B />;
return <B/>;
}
function _createMdxContent(props) {
return <></>;
Expand Down Expand Up @@ -1585,7 +1585,7 @@ function _createMdxContent(props) {
if (!X.y) _missingMdxReference(\"X.y\", true);
if (!Y) _missingMdxReference(\"Y\", false);
if (!Y.Z) _missingMdxReference(\"Y.Z\", true);
return <_components.p ><X />{\", \"}<X.y />{\", \"}<Y.Z /></_components.p>;
return <_components.p><X/>{\", \"}<X.y/>{\", \"}<Y.Z/></_components.p>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = Object.assign({}, _provideComponents(), props.components);
Expand Down Expand Up @@ -1624,10 +1624,10 @@ export function A() {
if (!X.y) _missingMdxReference(\"X.y\", true);
if (!Y) _missingMdxReference(\"Y\", false);
if (!Y.Z) _missingMdxReference(\"Y.Z\", true);
return <X />, <X.y />, <Y.Z />;
return <X/>, <X.y/>, <Y.Z/>;
}
function _createMdxContent(props) {
return <A />;
return <A/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = Object.assign({}, _provideComponents(), props.components);
Expand Down Expand Up @@ -1658,7 +1658,7 @@ function _missingMdxReference(id, component) {
export const A = ()=>{
const { B } = _provideComponents();
if (!B) _missingMdxReference(\"B\", true);
return <B />;
return <B/>;
};
function _createMdxContent(props) {
return <></>;
Expand Down Expand Up @@ -1692,7 +1692,7 @@ function _missingMdxReference(id, component) {
export const A = function B() {
const { C } = _provideComponents();
if (!C) _missingMdxReference(\"C\", true);
return <C />;
return <C/>;
};
function _createMdxContent(props) {
return <></>;
Expand Down Expand Up @@ -1732,10 +1732,10 @@ export function A() {
const _components = Object.assign({
\"b-c\": \"b-c\"
}, _provideComponents());
return <_components.b-c />;
return <_components.b-c/>;
}
function _createMdxContent(props) {
return <A />;
return <A/>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = Object.assign({}, _provideComponents(), props.components);
Expand All @@ -1761,7 +1761,7 @@ export default MDXContent;
h1: \"h1\"
}, props.components), { Hi } = _components;
if (!Hi) _missingMdxReference(\"Hi\", true, \"1:3-1:9\");
return <_components.h1 ><Hi /></_components.h1>;
return <_components.h1><Hi/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand Down Expand Up @@ -1790,7 +1790,7 @@ function _missingMdxReference(id, component, place) {
h1: \"h1\"
}, props.components), { Hi } = _components;
if (!Hi) _missingMdxReference(\"Hi\", true, \"1:3-1:9\");
return <_components.h1 ><Hi /></_components.h1>;
return <_components.h1><Hi/></_components.h1>;
}
function MDXContent(props = {}) {
const { wrapper: MDXLayout } = props.components || {};
Expand Down Expand Up @@ -1845,7 +1845,7 @@ function _missingMdxReference(id, component, place) {
mdx_plugin_recma_jsx_rewrite(&mut program, &Options::default(), None);
assert_eq!(
serialize(&mut program.module, None),
"let a = <b />;\n",
"let a = <b/>;\n",
"should not rewrite JSX outside of components"
);
}
Expand Down

0 comments on commit a298980

Please sign in to comment.