@webjourney/vite-plugins 1.1.0 → 1.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,iBA4BvD"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,iBA4BvD"}
package/dist/build.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { execSync } from 'node:child_process';
2
+ import { createRequire } from 'node:module';
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
4
5
  import { JSDOM } from 'jsdom';
@@ -81,7 +82,9 @@ async function prerender(projectRoot) {
81
82
  const entryServerPath = toAbsolute('dist-ssr/entry-server.js');
82
83
  const { render } = await import(entryServerPath);
83
84
  // Dynamically import renderToString from the project's react-dom
84
- const reactDomServerPath = path.resolve(projectRoot, 'node_modules/react-dom/server');
85
+ // Use createRequire to properly resolve in hoisted workspaces
86
+ const require = createRequire(path.join(projectRoot, 'package.json'));
87
+ const reactDomServerPath = require.resolve('react-dom/server');
85
88
  const { renderToString } = await import(reactDomServerPath);
86
89
  // Extract routes from App.tsx
87
90
  const routes = await extractRoutes(projectRoot);
@@ -0,0 +1,8 @@
1
+ import { ComponentType } from 'react';
2
+ /**
3
+ * Creates a render function for server-side rendering
4
+ * @param App - The root App component to render
5
+ * @returns A render function that wraps the App in StrictMode and StaticRouter
6
+ */
7
+ export declare function createServerRenderer(App: ComponentType): (url: string) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=entry-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-server.d.ts","sourceRoot":"","sources":["../src/entry-server.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,OAAO,CAAC;AAGlD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,IAC9B,KAAK,MAAM,6CASnC"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { StrictMode } from 'react';
3
+ import { StaticRouter } from 'react-router';
4
+ /**
5
+ * Creates a render function for server-side rendering
6
+ * @param App - The root App component to render
7
+ * @returns A render function that wraps the App in StrictMode and StaticRouter
8
+ */
9
+ export function createServerRenderer(App) {
10
+ return function render(url) {
11
+ return (_jsx(StrictMode, { children: _jsx(StaticRouter, { location: url, children: _jsx(App, {}) }) }));
12
+ };
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webjourney/vite-plugins",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Vite plugins for Webjourney WYSIWYG editing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -13,6 +13,10 @@
13
13
  "./build": {
14
14
  "import": "./dist/build.js",
15
15
  "types": "./dist/build.d.ts"
16
+ },
17
+ "./entry-server": {
18
+ "import": "./dist/entry-server.js",
19
+ "types": "./dist/entry-server.d.ts"
16
20
  }
17
21
  },
18
22
  "files": [
@@ -37,10 +41,14 @@
37
41
  "@types/node": "^20.0.0",
38
42
  "@types/react": "^18.0.0",
39
43
  "@types/react-dom": "^18.0.0",
44
+ "react": "^18.0.0",
45
+ "react-router": "^7.0.0",
40
46
  "typescript": "^5.8.3",
41
47
  "vite": "^5.0.0"
42
48
  },
43
49
  "peerDependencies": {
50
+ "react": "^18.0.0 || ^19.0.0",
51
+ "react-router": "^6.0.0 || ^7.0.0",
44
52
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
45
53
  }
46
54
  }