@shaper.org/vite-react-plugin 1.0.16 → 1.0.17
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.d.mts +3 -19
- package/dist/index.mjs +35 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,25 +3,6 @@ import { UserConfig } from "vite";
|
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
declare const reactPlugin: (config: UserConfig) => ({
|
|
6
|
-
name: string;
|
|
7
|
-
enforce: string;
|
|
8
|
-
resolveId(id: string): "virtual:hmr-events-plugin" | undefined;
|
|
9
|
-
load(id: string): string | undefined;
|
|
10
|
-
transformIndexHtml(html: string): {
|
|
11
|
-
html: string;
|
|
12
|
-
tags: {
|
|
13
|
-
tag: string;
|
|
14
|
-
injectTo: string;
|
|
15
|
-
type: string;
|
|
16
|
-
attrs: {
|
|
17
|
-
src: string;
|
|
18
|
-
type: string;
|
|
19
|
-
};
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
22
|
-
configureServer(server: vite0.ViteDevServer): void;
|
|
23
|
-
handleHotUpdate(ctx: vite0.HmrContext): vite0.ModuleNode[];
|
|
24
|
-
} | {
|
|
25
6
|
name: string;
|
|
26
7
|
enforce: string;
|
|
27
8
|
transform(code: any, id: any): Promise<{
|
|
@@ -34,6 +15,9 @@ declare const reactPlugin: (config: UserConfig) => ({
|
|
|
34
15
|
apply: string;
|
|
35
16
|
configResolved(resolvedConfig: vite0.ResolvedConfig): void;
|
|
36
17
|
transform(code: string, id: string, options: Record<string, any>): Promise<string | undefined>;
|
|
18
|
+
} | {
|
|
19
|
+
name: string;
|
|
20
|
+
configureServer(server: any): void;
|
|
37
21
|
})[];
|
|
38
22
|
//#endregion
|
|
39
23
|
export { reactPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1861,13 +1861,47 @@ function jsxSourcePlugin(options = {}) {
|
|
|
1861
1861
|
};
|
|
1862
1862
|
}
|
|
1863
1863
|
|
|
1864
|
+
//#endregion
|
|
1865
|
+
//#region src/analyze-deps-plugin.ts
|
|
1866
|
+
function analyzeDepsPlugin() {
|
|
1867
|
+
return {
|
|
1868
|
+
name: "analyze-deps",
|
|
1869
|
+
configureServer(server) {
|
|
1870
|
+
server.middlewares.use("/__analyze", async (req, res) => {
|
|
1871
|
+
console.log(req.url);
|
|
1872
|
+
try {
|
|
1873
|
+
const entry = new URL(req.url, "http://localhost").searchParams.get("entry");
|
|
1874
|
+
await server.transformRequest(entry);
|
|
1875
|
+
const mod = await server.moduleGraph.getModuleByUrl(entry);
|
|
1876
|
+
const result = [];
|
|
1877
|
+
for (const nodeModule of mod._clientModule.importedModules) result.push({
|
|
1878
|
+
id: nodeModule.id,
|
|
1879
|
+
file: nodeModule.file
|
|
1880
|
+
});
|
|
1881
|
+
res.setHeader("Content-Type", "application/json");
|
|
1882
|
+
res.statusCode = 200;
|
|
1883
|
+
res.end(JSON.stringify({
|
|
1884
|
+
modules: result,
|
|
1885
|
+
file: mod._clientModule.file
|
|
1886
|
+
}));
|
|
1887
|
+
} catch (err) {
|
|
1888
|
+
res.setHeader("Content-Type", "application/json");
|
|
1889
|
+
res.statusCode = 500;
|
|
1890
|
+
res.end(JSON.stringify({ msg: err.message ?? "Unexpected error." }));
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1864
1897
|
//#endregion
|
|
1865
1898
|
//#region src/index.ts
|
|
1866
1899
|
const reactPlugin = (config) => {
|
|
1867
1900
|
return [
|
|
1868
1901
|
HMREventsPlugin(),
|
|
1869
1902
|
jsxSourcePlugin(config),
|
|
1870
|
-
reactRoutesPlugin()
|
|
1903
|
+
reactRoutesPlugin(),
|
|
1904
|
+
analyzeDepsPlugin()
|
|
1871
1905
|
];
|
|
1872
1906
|
};
|
|
1873
1907
|
|