@shaper.org/vite-react-plugin 1.0.15 → 1.0.16
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/dist/index.mjs +18 -1
- package/package.json +1 -1
- package/templates/main.ts +6 -2
package/dist/index.mjs
CHANGED
|
@@ -1814,13 +1814,30 @@ function jsxSourcePlugin(options = {}) {
|
|
|
1814
1814
|
ExportNamedDeclaration(path) {
|
|
1815
1815
|
const decl = path.node.declaration;
|
|
1816
1816
|
if (t.isFunctionDeclaration(decl) && decl.id) injectAtProgramEnd(decl.id.name);
|
|
1817
|
+
if (t.isClassDeclaration(decl) && decl.id) injectAtProgramEnd(decl.id.name);
|
|
1817
1818
|
if (t.isVariableDeclaration(decl)) {
|
|
1818
1819
|
for (const d of decl.declarations) if (t.isIdentifier(d.id) && (t.isArrowFunctionExpression(d.init) || t.isFunctionExpression(d.init))) injectAtProgramEnd(d.id.name);
|
|
1819
1820
|
}
|
|
1821
|
+
for (const spec of path.node.specifiers) if (t.isExportSpecifier(spec)) injectAtProgramEnd(spec.local.name);
|
|
1820
1822
|
},
|
|
1821
1823
|
ExportDefaultDeclaration(path) {
|
|
1822
1824
|
const decl = path.node.declaration;
|
|
1823
|
-
if (t.
|
|
1825
|
+
if (t.isFunctionDeclaration(decl) && decl.id) {
|
|
1826
|
+
injectAtProgramEnd(decl.id.name);
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
if (t.isClassDeclaration(decl) && decl.id) {
|
|
1830
|
+
injectAtProgramEnd(decl.id.name);
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1833
|
+
if (t.isIdentifier(decl)) {
|
|
1834
|
+
injectAtProgramEnd(decl.name);
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
if (t.isExportSpecifier?.(decl)) {
|
|
1838
|
+
injectAtProgramEnd(decl.local.name);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1824
1841
|
}
|
|
1825
1842
|
});
|
|
1826
1843
|
},
|
package/package.json
CHANGED
package/templates/main.ts
CHANGED
|
@@ -142,9 +142,11 @@ export class ReactRouteMonitor {
|
|
|
142
142
|
const routes = validRoutes.map((route) => ({
|
|
143
143
|
name: route.path,
|
|
144
144
|
path: route.path,
|
|
145
|
-
file: route.element.type.__file,
|
|
145
|
+
file: route.element.type.__file || "src/",
|
|
146
146
|
}));
|
|
147
147
|
|
|
148
|
+
console.log(routes);
|
|
149
|
+
|
|
148
150
|
this.iframeClient.sendAllRoutes(routes);
|
|
149
151
|
}
|
|
150
152
|
|
|
@@ -182,7 +184,7 @@ export class ReactRouteMonitor {
|
|
|
182
184
|
const routeInfo = {
|
|
183
185
|
name: toPathname,
|
|
184
186
|
path: toPathname,
|
|
185
|
-
file: to.element.type
|
|
187
|
+
file: to.element.type.__file || "src/",
|
|
186
188
|
};
|
|
187
189
|
|
|
188
190
|
if (toPathname === fromPathname) {
|
|
@@ -237,5 +239,7 @@ const monitor = new ReactRouteMonitor({
|
|
|
237
239
|
},
|
|
238
240
|
});
|
|
239
241
|
|
|
242
|
+
|
|
243
|
+
|
|
240
244
|
monitor.start();
|
|
241
245
|
monitor.triggerRoutes();
|