vite-plugin-react-deck 1.0.7 → 1.0.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/index.cjs +5 -7
- package/index.mjs +5 -7
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -31,12 +31,10 @@ var import_mdx = require("@mdx-js/mdx");
|
|
|
31
31
|
|
|
32
32
|
// src/codegen.ts
|
|
33
33
|
var Patterns = {
|
|
34
|
-
FragmentProd:
|
|
35
|
-
FragmentDev:
|
|
34
|
+
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\);/g,
|
|
35
|
+
FragmentDev: /^\s*<>\s*|\s*<\/>;\s*$/g
|
|
36
36
|
};
|
|
37
|
-
function extractMainCodeAsChildren(source, {
|
|
38
|
-
isJsx
|
|
39
|
-
}) {
|
|
37
|
+
function extractMainCodeAsChildren(source, { isJsx }) {
|
|
40
38
|
const start = source.indexOf("const _components = {");
|
|
41
39
|
const end = source.indexOf("\n}", start);
|
|
42
40
|
const components = source.slice(start, end);
|
|
@@ -48,13 +46,13 @@ function extractMainCodeAsChildren(source, {
|
|
|
48
46
|
const header = lines.slice(0, returnPos).join("\n");
|
|
49
47
|
const footer = lines.slice(returnPos).join("\n").replace("return", "");
|
|
50
48
|
if (isJsx) {
|
|
51
|
-
const finalFooter2 = footer.replace(Patterns.FragmentDev, "");
|
|
49
|
+
const finalFooter2 = footer.replace(Patterns.FragmentDev, " ").replace(/;$/, "");
|
|
52
50
|
return `${header}
|
|
53
51
|
const {wrapper: MDXLayout} = _components;
|
|
54
52
|
return <MDXLayout {...props}>${finalFooter2}</MDXLayout>;
|
|
55
53
|
`.trim();
|
|
56
54
|
}
|
|
57
|
-
const finalFooter = footer.match(/^\s*_jsxs?\(_Fragment,/gm) ? footer.replace(Patterns.FragmentProd, "") : footer;
|
|
55
|
+
const finalFooter = footer.match(/^\s*_jsxs?\(_Fragment,/gm) ? footer.replace(Patterns.FragmentProd, " ") : footer;
|
|
58
56
|
return `
|
|
59
57
|
${header}
|
|
60
58
|
const _content = ${finalFooter};
|
package/index.mjs
CHANGED
|
@@ -8,12 +8,10 @@ import { compile } from "@mdx-js/mdx";
|
|
|
8
8
|
|
|
9
9
|
// src/codegen.ts
|
|
10
10
|
var Patterns = {
|
|
11
|
-
FragmentProd:
|
|
12
|
-
FragmentDev:
|
|
11
|
+
FragmentProd: /^\s*_jsxs\(_Fragment, {\s*children:|\s*\}\);/g,
|
|
12
|
+
FragmentDev: /^\s*<>\s*|\s*<\/>;\s*$/g
|
|
13
13
|
};
|
|
14
|
-
function extractMainCodeAsChildren(source, {
|
|
15
|
-
isJsx
|
|
16
|
-
}) {
|
|
14
|
+
function extractMainCodeAsChildren(source, { isJsx }) {
|
|
17
15
|
const start = source.indexOf("const _components = {");
|
|
18
16
|
const end = source.indexOf("\n}", start);
|
|
19
17
|
const components = source.slice(start, end);
|
|
@@ -25,13 +23,13 @@ function extractMainCodeAsChildren(source, {
|
|
|
25
23
|
const header = lines.slice(0, returnPos).join("\n");
|
|
26
24
|
const footer = lines.slice(returnPos).join("\n").replace("return", "");
|
|
27
25
|
if (isJsx) {
|
|
28
|
-
const finalFooter2 = footer.replace(Patterns.FragmentDev, "");
|
|
26
|
+
const finalFooter2 = footer.replace(Patterns.FragmentDev, " ").replace(/;$/, "");
|
|
29
27
|
return `${header}
|
|
30
28
|
const {wrapper: MDXLayout} = _components;
|
|
31
29
|
return <MDXLayout {...props}>${finalFooter2}</MDXLayout>;
|
|
32
30
|
`.trim();
|
|
33
31
|
}
|
|
34
|
-
const finalFooter = footer.match(/^\s*_jsxs?\(_Fragment,/gm) ? footer.replace(Patterns.FragmentProd, "") : footer;
|
|
32
|
+
const finalFooter = footer.match(/^\s*_jsxs?\(_Fragment,/gm) ? footer.replace(Patterns.FragmentProd, " ") : footer;
|
|
35
33
|
return `
|
|
36
34
|
${header}
|
|
37
35
|
const _content = ${finalFooter};
|