@lomray/vite-ssr-boost 1.0.0-beta.8 → 1.0.0

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.
Files changed (71) hide show
  1. package/README.md +72 -12
  2. package/cli/build.d.ts +7 -5
  3. package/cli/build.js +1 -1
  4. package/cli/build.js.map +1 -1
  5. package/cli/helpers/keyboard-input.js +2 -0
  6. package/cli/helpers/keyboard-input.js.map +1 -0
  7. package/cli/helpers/vite-reset-cache.js.map +1 -0
  8. package/cli/run-docker-build.js +1 -1
  9. package/cli/run-docker-build.js.map +1 -1
  10. package/cli/run-prod.d.ts +2 -1
  11. package/cli/run-prod.js +1 -1
  12. package/cli/run-prod.js.map +1 -1
  13. package/cli.js +1 -1
  14. package/cli.js.map +1 -1
  15. package/components/scroll-to-top.d.ts +10 -0
  16. package/components/scroll-to-top.js +2 -0
  17. package/components/scroll-to-top.js.map +1 -0
  18. package/helpers/get-server-state.d.ts +5 -0
  19. package/helpers/get-server-state.js +2 -0
  20. package/helpers/get-server-state.js.map +1 -0
  21. package/helpers/import-route.d.ts +1 -1
  22. package/helpers/import-route.js +1 -1
  23. package/helpers/import-route.js.map +1 -1
  24. package/helpers/is-route-file.d.ts +5 -0
  25. package/helpers/is-route-file.js +2 -0
  26. package/helpers/is-route-file.js.map +1 -0
  27. package/helpers/process-stop.d.ts +1 -1
  28. package/helpers/process-stop.js +1 -1
  29. package/helpers/process-stop.js.map +1 -1
  30. package/helpers/vite-aliases.js +1 -1
  31. package/helpers/vite-aliases.js.map +1 -1
  32. package/interfaces/fc-route.d.ts +9 -0
  33. package/interfaces/fc-route.js.map +1 -1
  34. package/interfaces/route-object.d.ts +1 -1
  35. package/node/entry.d.ts +6 -1
  36. package/node/entry.js +1 -1
  37. package/node/entry.js.map +1 -1
  38. package/node/render.d.ts +3 -2
  39. package/node/render.js +1 -1
  40. package/node/render.js.map +1 -1
  41. package/node/server.js +1 -1
  42. package/node/server.js.map +1 -1
  43. package/package.json +3 -3
  44. package/plugin.d.ts +1 -2
  45. package/plugin.js +1 -1
  46. package/plugin.js.map +1 -1
  47. package/plugins/normalize-route.d.ts +9 -3
  48. package/plugins/normalize-route.js +1 -1
  49. package/plugins/normalize-route.js.map +1 -1
  50. package/services/build.d.ts +94 -0
  51. package/services/build.js +2 -0
  52. package/services/build.js.map +1 -0
  53. package/services/prepare-server.d.ts +4 -3
  54. package/services/prepare-server.js +1 -1
  55. package/services/prepare-server.js.map +1 -1
  56. package/services/server-config.d.ts +6 -10
  57. package/services/server-config.js +1 -1
  58. package/services/server-config.js.map +1 -1
  59. package/services/ssr-manifest.d.ts +207 -0
  60. package/services/ssr-manifest.js +2 -0
  61. package/services/ssr-manifest.js.map +1 -0
  62. package/workflow/Dockerfile +0 -1
  63. package/cli/keyboard-input.js +0 -2
  64. package/cli/keyboard-input.js.map +0 -1
  65. package/cli/vite-reset-cache.js.map +0 -1
  66. package/helpers/unlock-robots.d.ts +0 -5
  67. package/helpers/unlock-robots.js +0 -2
  68. package/helpers/unlock-robots.js.map +0 -1
  69. /package/cli/{keyboard-input.d.ts → helpers/keyboard-input.d.ts} +0 -0
  70. /package/cli/{vite-reset-cache.d.ts → helpers/vite-reset-cache.d.ts} +0 -0
  71. /package/cli/{vite-reset-cache.js → helpers/vite-reset-cache.js} +0 -0
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  <h1 align='center'>Vite SSR BOOST</h1>
2
2
 
3
+ <p align="center">
4
+ <img src="./logo.png" alt="Bootstrap logo" width="250" height="250">
5
+ </p>
6
+
7
+ ### Key features:
8
+
3
9
  - Develop ⚡charged⚡ server side applications with React streaming 💨 support.
4
10
  - Unlocks Suspense for server side applications.
5
11
  - Switch between SPA and SSR in 1 second.
@@ -24,6 +30,7 @@
24
30
  - [Getting started](#getting-started)
25
31
  - [How to use](#how-to-use)
26
32
  - [Plugin options](#plugin-options)
33
+ - [Useful imports](#useful-imports)
27
34
  - [CLI](#cli)
28
35
  - [Example](#demo)
29
36
  - [Bugs and feature requests](#bugs-and-feature-requests)
@@ -98,6 +105,10 @@ import App from './App';
98
105
  import routes from './routes';
99
106
 
100
107
  export default entryServer(App, routes, {
108
+ /**
109
+ * Request timeout (If your backend is slow, increase this value)
110
+ */
111
+ abortDelay: 15000, // default: 15000 (ms)
101
112
  /**
102
113
  * Server configuration (optional)
103
114
  */
@@ -168,19 +179,17 @@ import type { FCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route';
168
179
  */
169
180
  SsrBoost({
170
181
  /**
171
- * With this option you can export route components like FCRoute or FCCRoute
172
- * @example
173
- * const Page: FCRoute = () => <div>Hi</div>;
174
- *
175
- * Page.ErrorBoudary = () => <div>Error</div>;
176
- *
177
- * export default Page;
178
- *
179
- * Routes:
180
- * const routes = [{ path: '/', lazyNR: () => import('./pages/home') }]
182
+ * index.html file path
181
183
  */
182
- hasLazyRoutePlugin: true, // default: true
183
-
184
+ indexFile: 'index.html', // default: index.html
185
+ /**
186
+ * Server entrypoint file
187
+ */
188
+ serverFile: 'server.ts', // default: server.ts
189
+ /**
190
+ * Client entrypoint file
191
+ */
192
+ clientFile: 'client.ts', // default: client.ts
184
193
  /**
185
194
  * Add tsconfig aliases to vite config aliases
186
195
  */
@@ -188,12 +197,63 @@ SsrBoost({
188
197
  })
189
198
  ```
190
199
 
200
+ ## Useful imports
201
+ ```typescript
202
+ /**
203
+ * Components
204
+ */
205
+ // Navigate component based on react-router-dom with server-side support
206
+ import Navigate from '@lomray/vite-ssr-boost/components/navigate';
207
+ // Change server response status
208
+ import ResponseStatus from '@lomray/vite-ssr-boost/components/response-status';
209
+ // Scroll page to top after navigate
210
+ import ScrollToTop from '@lomray/vite-ssr-boost/components/scroll-to-top';
211
+ // HOC for wrap component in Suspense
212
+ import withSuspense from '@lomray/vite-ssr-boost/components/with-suspense';
213
+
214
+ /**
215
+ * Helpers
216
+ */
217
+ // Get server state (e.g. state manager) on client side
218
+ import getServerState from '@lomray/vite-ssr-boost/helpers/get-server-state';
219
+
220
+ /**
221
+ * Interfaces
222
+ */
223
+ // interfaces for route components
224
+ import type { FCRoute, FCCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route';
225
+ // interface for define routes
226
+ import type { TRouteObject } from '@lomray/vite-ssr-boost/interfaces/route-object';
227
+ ```
228
+
191
229
  ## CLI
192
230
  Explore all commands and options:
193
231
  ```shell
194
232
  ssr-boost -h
195
233
  ```
196
234
 
235
+ ## WARNING
236
+ Route imports of the following types are supported:
237
+ ```typescript jsx
238
+ import { RouteObject } from 'react-router-dom';
239
+ import HomePage from './pages/home';
240
+
241
+ const importPath = './pages/home';
242
+
243
+ const routes: RouteObject[] = [
244
+ {
245
+ path: '/home',
246
+ Component: HomePage, // support
247
+ element: <AppLayout />, // support
248
+ lazy: () => import('./pages/home'), // support
249
+ lazy: () => import(importPath), // not support
250
+ lazy: () => { // not support
251
+ return import('./pages/home');
252
+ }
253
+ }
254
+ ];
255
+ ```
256
+
197
257
  ## Demo
198
258
  Explore [demo app](https://github.com/Lomray-Software/vite-template) to more understand.
199
259
 
package/cli/build.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  interface IBuildParams {
2
+ onFinish?: () => void;
3
+ mode?: string;
4
+ clientOptions?: string;
5
+ serverOptions?: string;
2
6
  isOnlyClient?: boolean;
3
7
  isWatch?: boolean;
4
8
  isUnlockRobots?: boolean;
5
- clientOptions?: string;
6
- serverOptions?: string;
7
- mode?: string;
8
- onFinish?: () => void;
9
+ isEject?: boolean;
10
+ isNoWarnings?: boolean;
9
11
  }
10
12
  /**
11
13
  * Build production application
12
14
  */
13
- declare function build({ onFinish, isOnlyClient, isWatch, isUnlockRobots, clientOptions, serverOptions, mode, }: IBuildParams): Promise<void>;
15
+ declare function build({ onFinish, mode, clientOptions, serverOptions, isOnlyClient, isWatch, isUnlockRobots, isEject, isNoWarnings, }: IBuildParams): Promise<void>;
14
16
  export { build as default };
package/cli/build.js CHANGED
@@ -1,2 +1,2 @@
1
- import o from"node:child_process";import e from"node:fs";import t from"node:path";import{performance as r}from"node:perf_hooks";import s from"chalk";import{resolveConfig as i}from"vite";import n from"./vite-reset-cache.js";import p from"../constants/cli-name.js";import{createDevMarker as c}from"../helpers/dev-marker.js";import d from"../helpers/plugin-config.js";import m from"../helpers/unlock-robots.js";const l=o=>{const e=new Promise(((e,t)=>{o.on("exit",(o=>{e(o)})),o.on("close",(o=>{e(o)})),o.on("error",(o=>{t(o)}))}));return o.stdout?.pipe(process.stdout),o.stderr?.pipe(process.stderr),e.command=o,e};async function a({onFinish:a,isOnlyClient:u=!1,isWatch:f=!1,isUnlockRobots:v=!1,clientOptions:O="",serverOptions:h="",mode:S=""}){const $=r.now(),b=await i({},"build",S,"production"===S?"production":"development"),_=d(b),{outDir:w}=b.build,g=["client"],R=new AbortController,y=S?`--mode ${S}`:"",C=process.env.NODE_ENV||"development",D="production"===C,j=t.resolve(b.root,w);await n(),e.existsSync(j)&&e.rmSync(j,{recursive:!0});const E=l(o.spawn(`vite build ${O} --emptyOutDir --outDir ${w}/client ${y}`,{signal:R.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:u?"0":"1"}}));let k;if(f||await E,u||(k=l(o.spawn(`vite build ${h} --emptyOutDir --outDir ${w}/server --ssr ${_.serverFile} ${y}`,{signal:R.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:u?"0":"1"}})),f||await k,g.push("server")),f){process.on("exit",(()=>{R.abort()}));let o=u?1:2;const e=t=>{Buffer.from(t).toString().includes("built in")&&(o-=1,o||(E.command.stdout.removeListener("data",e),k?.command.stdout.removeListener("data",e),c(D,b),a?.()))};return E.command.stdout.on("data",e),void k?.command.stdout.on("data",e)}v&&m(b.root,w),c(D,b),a?.();const B=s.dim(`${s.yellowBright(g.join(","))} built in ${s.reset(s.bold(Math.ceil(r.now()-$)))} ms`);console.info(`\n ${s.green(`${s.bold(p.toUpperCase())}`)} ${B} ${D?"":s.redBright(`NODE_ENV=${C}`)}\n`)}export{a as default};
1
+ import o from"node:child_process";import{performance as e}from"node:perf_hooks";import i from"chalk";import t from"./helpers/vite-reset-cache.js";import s from"../constants/cli-name.js";import{createDevMarker as r}from"../helpers/dev-marker.js";import n from"../helpers/process-stop.js";import l from"../services/build.js";async function a({onFinish:a,mode:c="",clientOptions:d="",serverOptions:p="",isOnlyClient:m=!1,isWatch:f=!1,isUnlockRobots:u=!1,isEject:O=!1,isNoWarnings:v=!1}){const S=e.now(),$=new l({mode:c}),h=["client"],_=new AbortController,b=c?`--mode ${c}`:"";await $.makeConfig(),await t(),$.clearBuildFolder();const g=$.promisifyProcess(o.spawn(`vite build ${d} --emptyOutDir --outDir ${$.outDir}/client ${b}`,{signal:_.signal,stdio:[process.stdin,"pipe","pipe"],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:m?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}}),v);if(!f){const o=await g;n(o,!0)}let w;if(!m){if(w=$.promisifyProcess(o.spawn(`vite build ${p} --emptyOutDir --outDir ${$.outDir}/server --ssr ${$.serverFile} ${b}`,{signal:_.signal,stdio:[process.stdin,"pipe","pipe"],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:m?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}}),v),!f){const o=await w;n(o,!0),await $.buildManifest(),O&&$.eject()}h.push("server")}if(f){process.on("exit",(()=>{_.abort()}));let o=m?1:2;const e=i=>{Buffer.from(i).toString().includes("built in")&&(o-=1,o||(g.command.stdout.removeListener("data",e),w?.command.stdout.removeListener("data",e),r($.isProd,$.viteConfig),a?.()))};return g.command.stdout.on("data",e),void w?.command.stdout.on("data",e)}u&&$.unlockRobots(),r($.isProd,$.viteConfig),a?.();const C=Math.ceil(e.now()-S),R=C>1e3?(C/1e3).toFixed(2):C,B=C>1e3?"s":"ms",j=i.dim(`${i.yellowBright(h.join(","))} built in ${i.reset(i.bold(R))} ${B}`);console.info(`\n ${i.green(`${i.bold(s.toUpperCase())}`)} ${j} ${$.isProd?"":i.redBright(`NODE_ENV=${$.nodeEnv}`)}\n`)}export{a as default};
2
2
  //# sourceMappingURL=build.js.map
package/cli/build.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sources":["../../src/cli/build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport viteResetCache from '@cli/vite-reset-cache';\nimport cliName from '@constants/cli-name';\nimport { createDevMarker } from '@helpers/dev-marker';\nimport getPluginConfig from '@helpers/plugin-config';\nimport unlockRobots from '@helpers/unlock-robots';\n\ninterface IBuildParams {\n isOnlyClient?: boolean;\n isWatch?: boolean;\n isUnlockRobots?: boolean;\n clientOptions?: string;\n serverOptions?: string;\n mode?: string;\n onFinish?: () => void;\n}\n\n/**\n * Promisify spawn process\n */\nconst promisify = (command: childProcess.ChildProcess) => {\n const promise = new Promise((resolve, reject) => {\n command.on('exit', (code) => {\n resolve(code);\n });\n\n command.on('close', (code) => {\n resolve(code);\n });\n\n command.on('error', (message) => {\n reject(message);\n });\n });\n\n command.stdout?.pipe(process.stdout);\n command.stderr?.pipe(process.stderr);\n\n promise['command'] = command;\n\n return promise;\n};\n\n/**\n * Build production application\n */\nasync function build({\n onFinish,\n isOnlyClient = false,\n isWatch = false,\n isUnlockRobots = false,\n clientOptions = '',\n serverOptions = '',\n mode = '',\n}: IBuildParams): Promise<void> {\n const perfStart = performance.now();\n const config = await resolveConfig(\n {},\n 'build',\n mode,\n mode === 'production' ? 'production' : 'development',\n );\n const pluginConfig = getPluginConfig(config);\n const { outDir } = config.build;\n const types = ['client'];\n const controller = new AbortController();\n const modeOpt = mode ? `--mode ${mode}` : '';\n const nodeEnv = process.env.NODE_ENV || 'development';\n const isProd = nodeEnv === 'production';\n const buildDir = path.resolve(config.root, outDir);\n\n // this is required step - build with different env may cause problems\n await viteResetCache();\n\n // clear build folder\n if (fs.existsSync(buildDir)) {\n fs.rmSync(buildDir, { recursive: true });\n }\n\n /**\n * Build client\n */\n const clientProcess = promisify(\n childProcess.spawn(\n `vite build ${clientOptions} --emptyOutDir --outDir ${outDir}/client ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', process.stderr],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n },\n },\n ),\n );\n\n if (!isWatch) {\n await clientProcess;\n }\n\n let serverProcess: Promise<unknown> | undefined;\n\n /**\n * Build server\n */\n if (!isOnlyClient) {\n serverProcess = promisify(\n childProcess.spawn(\n `vite build ${serverOptions} --emptyOutDir --outDir ${outDir}/server --ssr ${pluginConfig.serverFile} ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', process.stderr],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n },\n },\n ),\n );\n\n if (!isWatch) {\n await serverProcess;\n }\n\n types.push('server');\n }\n\n /**\n * Preview mode\n */\n if (isWatch) {\n process.on('exit', () => {\n controller.abort();\n });\n\n let buildCount = isOnlyClient ? 1 : 2;\n const listener = (buff: Uint8Array): void => {\n const msg = Buffer.from(buff).toString();\n\n if (msg.includes('built in')) {\n buildCount -= 1;\n\n if (!buildCount) {\n clientProcess['command'].stdout.removeListener('data', listener);\n serverProcess?.['command'].stdout.removeListener('data', listener);\n createDevMarker(isProd, config);\n onFinish?.();\n }\n }\n };\n\n /**\n * Listen output for call onFinish\n */\n clientProcess['command'].stdout.on('data', listener);\n serverProcess?.['command'].stdout.on('data', listener);\n\n return;\n }\n\n if (isUnlockRobots) {\n unlockRobots(config.root, outDir);\n }\n\n createDevMarker(isProd, config);\n onFinish?.();\n\n const buildDurationString = chalk.dim(\n `${chalk.yellowBright(types.join(','))} built in ${chalk.reset(\n chalk.bold(Math.ceil(performance.now() - perfStart)),\n )} ms`,\n );\n\n console.info(\n `\\n ${chalk.green(`${chalk.bold(cliName.toUpperCase())}`)} ${buildDurationString} ${\n isProd ? '' : chalk.redBright(`NODE_ENV=${nodeEnv}`)\n }\\n`,\n );\n}\n\nexport default build;\n"],"names":["promisify","command","promise","Promise","resolve","reject","on","code","message","stdout","pipe","process","stderr","async","build","onFinish","isOnlyClient","isWatch","isUnlockRobots","clientOptions","serverOptions","mode","perfStart","performance","now","config","resolveConfig","pluginConfig","getPluginConfig","outDir","types","controller","AbortController","modeOpt","nodeEnv","env","NODE_ENV","isProd","buildDir","path","root","viteResetCache","fs","existsSync","rmSync","recursive","clientProcess","childProcess","spawn","signal","stdio","stdin","shell","FORCE_COLOR","SSR_BOOST_IS_SSR","serverProcess","serverFile","push","abort","buildCount","listener","buff","Buffer","from","toString","includes","removeListener","createDevMarker","unlockRobots","buildDurationString","chalk","dim","yellowBright","join","reset","bold","Math","ceil","console","info","green","cliName","toUpperCase","redBright"],"mappings":"wZAyBA,MAAMA,EAAaC,IACjB,MAAMC,EAAU,IAAIC,SAAQ,CAACC,EAASC,KACpCJ,EAAQK,GAAG,QAASC,IAClBH,EAAQG,EAAK,IAGfN,EAAQK,GAAG,SAAUC,IACnBH,EAAQG,EAAK,IAGfN,EAAQK,GAAG,SAAUE,IACnBH,EAAOG,EAAQ,GACf,IAQJ,OALAP,EAAQQ,QAAQC,KAAKC,QAAQF,QAC7BR,EAAQW,QAAQF,KAAKC,QAAQC,QAE7BV,EAAiB,QAAID,EAEdC,CAAO,EAMhBW,eAAeC,GAAMC,SACnBA,EAAQC,aACRA,GAAe,EAAKC,QACpBA,GAAU,EAAKC,eACfA,GAAiB,EAAKC,cACtBA,EAAgB,GAAEC,cAClBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAYC,EAAYC,MACxBC,QAAeC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,OAHA+B,EAAuB,QAAErC,OAAOH,GAAG,OAAQsD,QAC3CL,GAAyB,QAAE9C,OAAOH,GAAG,OAAQsD,EAG9C,CAEG1C,GACFkD,EAAa3C,EAAOe,KAAMX,GAG5BsC,EAAgB9B,EAAQZ,GACxBV,MAEA,MAAMsD,EAAsBC,EAAMC,IAChC,GAAGD,EAAME,aAAa1C,EAAM2C,KAAK,kBAAkBH,EAAMI,MACvDJ,EAAMK,KAAKC,KAAKC,KAAKtD,EAAYC,MAAQF,WAI7CwD,QAAQC,KACN,OAAOT,EAAMU,MAAM,GAAGV,EAAMK,KAAKM,EAAQC,sBAAsBb,KAC7DhC,EAAS,GAAKiC,EAAMa,UAAU,YAAYjD,SAGhD"}
1
+ {"version":3,"file":"build.js","sources":["../../src/cli/build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport viteResetCache from '@cli/helpers/vite-reset-cache';\nimport cliName from '@constants/cli-name';\nimport { createDevMarker } from '@helpers/dev-marker';\nimport processStop from '@helpers/process-stop';\nimport Build from '@services/build';\n\ninterface IBuildParams {\n onFinish?: () => void;\n mode?: string;\n clientOptions?: string;\n serverOptions?: string;\n isOnlyClient?: boolean;\n isWatch?: boolean;\n isUnlockRobots?: boolean;\n isEject?: boolean;\n isNoWarnings?: boolean;\n}\n\n/**\n * Build production application\n */\nasync function build({\n onFinish,\n mode = '',\n clientOptions = '',\n serverOptions = '',\n isOnlyClient = false,\n isWatch = false,\n isUnlockRobots = false,\n isEject = false,\n isNoWarnings = false,\n}: IBuildParams): Promise<void> {\n const perfStart = performance.now();\n const buildService = new Build({ mode });\n const types = ['client'];\n const controller = new AbortController();\n const modeOpt = mode ? `--mode ${mode}` : '';\n\n await buildService.makeConfig();\n\n // this is required step - build with different env may cause problems\n await viteResetCache();\n buildService.clearBuildFolder();\n\n /**\n * Build client\n */\n const clientProcess = buildService.promisifyProcess(\n childProcess.spawn(\n `vite build ${clientOptions} --emptyOutDir --outDir ${buildService.outDir}/client ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', 'pipe'],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n SSR_BOOST_ACTION: global.viteBoostAction,\n },\n },\n ),\n isNoWarnings,\n );\n\n if (!isWatch) {\n const exitCode = (await clientProcess) as number;\n\n processStop(exitCode, true);\n }\n\n let serverProcess: Promise<unknown> | undefined;\n\n /**\n * Build server\n */\n if (!isOnlyClient) {\n serverProcess = buildService.promisifyProcess(\n childProcess.spawn(\n `vite build ${serverOptions} --emptyOutDir --outDir ${buildService.outDir}/server --ssr ${buildService.serverFile} ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', 'pipe'],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n SSR_BOOST_ACTION: global.viteBoostAction,\n },\n },\n ),\n isNoWarnings,\n );\n\n if (!isWatch) {\n const exitCode = (await serverProcess) as number;\n\n processStop(exitCode, true);\n await buildService.buildManifest();\n\n if (isEject) {\n buildService.eject();\n }\n }\n\n types.push('server');\n }\n\n /**\n * Preview mode\n */\n if (isWatch) {\n process.on('exit', () => {\n controller.abort();\n });\n\n let buildCount = isOnlyClient ? 1 : 2;\n const listener = (buff: Uint8Array): void => {\n const msg = Buffer.from(buff).toString();\n\n if (msg.includes('built in')) {\n buildCount -= 1;\n\n if (!buildCount) {\n clientProcess['command'].stdout.removeListener('data', listener);\n serverProcess?.['command'].stdout.removeListener('data', listener);\n createDevMarker(buildService.isProd, buildService.viteConfig);\n onFinish?.();\n }\n }\n };\n\n /**\n * Listen output for call onFinish\n */\n clientProcess['command'].stdout.on('data', listener);\n serverProcess?.['command'].stdout.on('data', listener);\n\n return;\n }\n\n if (isUnlockRobots) {\n buildService.unlockRobots();\n }\n\n createDevMarker(buildService.isProd, buildService.viteConfig);\n onFinish?.();\n\n const durationMs = Math.ceil(performance.now() - perfStart);\n const duration = durationMs > 1000 ? (durationMs / 1000).toFixed(2) : durationMs;\n const units = durationMs > 1000 ? 's' : 'ms';\n\n const buildDurationString = chalk.dim(\n `${chalk.yellowBright(types.join(','))} built in ${chalk.reset(chalk.bold(duration))} ${units}`,\n );\n\n console.info(\n `\\n ${chalk.green(`${chalk.bold(cliName.toUpperCase())}`)} ${buildDurationString} ${\n buildService.isProd ? '' : chalk.redBright(`NODE_ENV=${buildService.nodeEnv}`)\n }\\n`,\n );\n}\n\nexport default build;\n"],"names":["async","build","onFinish","mode","clientOptions","serverOptions","isOnlyClient","isWatch","isUnlockRobots","isEject","isNoWarnings","perfStart","performance","now","buildService","Build","types","controller","AbortController","modeOpt","makeConfig","viteResetCache","clearBuildFolder","clientProcess","promisifyProcess","childProcess","spawn","outDir","signal","stdio","process","stdin","shell","env","FORCE_COLOR","SSR_BOOST_IS_SSR","SSR_BOOST_ACTION","global","viteBoostAction","exitCode","processStop","serverProcess","serverFile","buildManifest","eject","push","on","abort","buildCount","listener","buff","Buffer","from","toString","includes","stdout","removeListener","createDevMarker","isProd","viteConfig","unlockRobots","durationMs","Math","ceil","duration","toFixed","units","buildDurationString","chalk","dim","yellowBright","join","reset","bold","console","info","green","cliName","toUpperCase","redBright","nodeEnv"],"mappings":"mUAwBAA,eAAeC,GAAMC,SACnBA,EAAQC,KACRA,EAAO,GAAEC,cACTA,EAAgB,GAAEC,cAClBA,EAAgB,GAAEC,aAClBA,GAAe,EAAKC,QACpBA,GAAU,EAAKC,eACfA,GAAiB,EAAKC,QACtBA,GAAU,EAAKC,aACfA,GAAe,IAEf,MAAMC,EAAYC,EAAYC,MACxBC,EAAe,IAAIC,EAAM,CAAEZ,SAC3Ba,EAAQ,CAAC,UACTC,EAAa,IAAIC,gBACjBC,EAAUhB,EAAO,UAAUA,IAAS,SAEpCW,EAAaM,mBAGbC,IACNP,EAAaQ,mBAKb,MAAM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,eAGfH,EAAgB3C,EAAa4C,OAAQ5C,EAAa6C,YAClDzD,MAEA,MAAM2D,EAAaC,KAAKC,KAAKnD,EAAYC,MAAQF,GAC3CqD,EAAWH,EAAa,KAAQA,EAAa,KAAMI,QAAQ,GAAKJ,EAChEK,EAAQL,EAAa,IAAO,IAAM,KAElCM,EAAsBC,EAAMC,IAChC,GAAGD,EAAME,aAAatD,EAAMuD,KAAK,kBAAkBH,EAAMI,MAAMJ,EAAMK,KAAKT,OAAcE,KAG1FQ,QAAQC,KACN,OAAOP,EAAMQ,MAAM,GAAGR,EAAMK,KAAKI,EAAQC,sBAAsBX,KAC7DrD,EAAa4C,OAAS,GAAKU,EAAMW,UAAU,YAAYjE,EAAakE,eAG1E"}
@@ -0,0 +1,2 @@
1
+ import o from"chalk";import t from"../../constants/cli-context.js";import i from"../../constants/cli-shortcuts.js";import r from"../../helpers/plugin-config.js";import e from"../../helpers/process-stop.js";let n=!1;function s(s){!async function(s){if(""===s||""===s)return void(t.server?.close((o=>e(o?1:0)))||e());if(n)return;const{config:c}=t,f=c?.getLogger(),{customShortcuts:l=[]}="object"==typeof c?.getVite()?.config?r(c.getVite().config):{},p=l.filter(Boolean).concat(i).filter((({isOnlyDev:o=!1})=>!o||o&&!c?.isProd));if("\r"===s)return f?.info("\r");"h"===s&&f?.info(["",o.bold(" Shortcuts"),...p.map((t=>o.dim(" press ")+o.bold(t.key)+o.dim(` to ${t.description}`)))].join("\n"));const m=p.find((({key:o})=>o===s));if(!m)return;n=!0,await m.action(t),n=!1}(s)}export{s as default};
2
+ //# sourceMappingURL=keyboard-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboard-input.js","sources":["../../../src/cli/helpers/keyboard-input.ts"],"sourcesContent":["import chalk from 'chalk';\nimport cliContext from '@constants/cli-context';\nimport defaultShortcuts from '@constants/cli-shortcuts';\nimport getPluginConfig from '@helpers/plugin-config';\nimport processStop from '@helpers/process-stop';\n\nlet isActionRunning = false;\n\n/**\n * Handle keyboard press buttons\n */\nfunction onKeyPress(input: string): void {\n void runAction(input);\n}\n\n/**\n * Run shortcut\n */\nasync function runAction(input: string): Promise<void> {\n // ctrl+c or ctrl+d\n if (input === '\\x03' || input === '\\x04') {\n if (!cliContext.server?.close((e) => processStop(e ? 1 : 0))) {\n processStop();\n }\n\n return;\n }\n\n if (isActionRunning) {\n return;\n }\n\n const { config } = cliContext;\n const Logger = config?.getLogger();\n const { customShortcuts = [] } =\n typeof config?.getVite()?.config === 'object' ? getPluginConfig(config.getVite()!.config) : {};\n\n const shortcuts = customShortcuts\n .filter(Boolean)\n .concat(defaultShortcuts)\n .filter(({ isOnlyDev = false }) => !isOnlyDev || (isOnlyDev && !config?.isProd));\n\n // print empty line\n if (input === '\\r') {\n return Logger?.info('\\r');\n }\n\n // print help\n if (input === 'h') {\n Logger?.info(\n [\n '',\n chalk.bold(' Shortcuts'),\n ...shortcuts.map(\n (shortcut) =>\n chalk.dim(' press ') +\n chalk.bold(shortcut.key) +\n chalk.dim(` to ${shortcut.description}`),\n ),\n ].join('\\n'),\n );\n }\n\n // execute shortcut command\n const shortcut = shortcuts.find(({ key }) => key === input);\n\n if (!shortcut) {\n return;\n }\n\n isActionRunning = true;\n await shortcut.action(cliContext);\n isActionRunning = false;\n}\n\nexport default onKeyPress;\n"],"names":["isActionRunning","onKeyPress","input","async","cliContext","server","close","e","processStop","config","Logger","getLogger","customShortcuts","getVite","getPluginConfig","shortcuts","filter","Boolean","concat","defaultShortcuts","isOnlyDev","isProd","info","chalk","bold","map","shortcut","dim","key","description","join","find","action","runAction"],"mappings":"8MAMA,IAAIA,GAAkB,EAKtB,SAASC,EAAWC,IAOpBC,eAAyBD,GAEvB,GAAc,MAAVA,GAA8B,MAAVA,EAKtB,YAJKE,EAAWC,QAAQC,OAAOC,GAAMC,EAAYD,EAAI,EAAI,MACvDC,KAMJ,GAAIR,EACF,OAGF,MAAMS,OAAEA,GAAWL,EACbM,EAASD,GAAQE,aACjBC,gBAAEA,EAAkB,IACa,iBAA9BH,GAAQI,WAAWJ,OAAsBK,EAAgBL,EAAOI,UAAWJ,QAAU,CAAA,EAExFM,EAAYH,EACfI,OAAOC,SACPC,OAAOC,GACPH,QAAO,EAAGI,aAAY,MAAaA,GAAcA,IAAcX,GAAQY,SAG1E,GAAc,OAAVnB,EACF,OAAOQ,GAAQY,KAAK,MAIR,MAAVpB,GACFQ,GAAQY,KACN,CACE,GACAC,EAAMC,KAAK,kBACRT,EAAUU,KACVC,GACCH,EAAMI,IAAI,YACVJ,EAAMC,KAAKE,EAASE,KACpBL,EAAMI,IAAI,OAAOD,EAASG,kBAE9BC,KAAK,OAKX,MAAMJ,EAAWX,EAAUgB,MAAK,EAAGH,SAAUA,IAAQ1B,IAErD,IAAKwB,EACH,OAGF1B,GAAkB,QACZ0B,EAASM,OAAO5B,GACtBJ,GAAkB,CACpB,CA7DOiC,CAAU/B,EACjB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-reset-cache.js","sources":["../../../src/cli/helpers/vite-reset-cache.ts"],"sourcesContent":["import fs from 'node:fs';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\n\n/**\n * Reset vite cache\n */\nasync function viteResetCache(): Promise<void> {\n const config = await resolveConfig({}, 'build');\n const { cacheDir } = config;\n\n if (fs.existsSync(cacheDir)) {\n fs.rmSync(cacheDir, { recursive: true, force: true });\n }\n\n console.info(chalk.dim(chalk.yellowBright('vite cache cleared.')));\n}\n\nexport default viteResetCache;\n"],"names":["async","viteResetCache","config","resolveConfig","cacheDir","fs","existsSync","rmSync","recursive","force","console","info","chalk","dim","yellowBright"],"mappings":"iFAOAA,eAAeC,IACb,MAAMC,QAAeC,EAAc,CAAE,EAAE,UACjCC,SAAEA,GAAaF,EAEjBG,EAAGC,WAAWF,IAChBC,EAAGE,OAAOH,EAAU,CAAEI,WAAW,EAAMC,OAAO,IAGhDC,QAAQC,KAAKC,EAAMC,IAAID,EAAME,aAAa,wBAC5C"}
@@ -1,2 +1,2 @@
1
- import o from"node:child_process";import e from"node:path";import{cwd as r}from"node:process";import{resolveConfig as i}from"vite";import t from"../helpers/plugin-config.js";async function d({imageName:d,dockerFile:l,isOnlyClient:n=!1,dockerOptions:p="",mode:s=""}){const c="production"===s?"production":"development",a=await i({},"build",s),m=t(a),{root:u,build:{outDir:f}}=a,$=r(),g=`.${e.resolve(u,f).replace($,"")}`,b=n?"spa":"ssr",h=l||`${m.pluginPath}/workflow/Dockerfile`;o.execSync(`docker build -f ${h} --build-arg ROOT_PATH=${$} --build-arg BUILD_PATH=${g} --build-arg RUN_TYPE=${b} --build-arg ENV_MODE=${c}${p} -t ${d} ${$}`,{stdio:"inherit",env:{...process.env}})}export{d as default};
1
+ import o from"node:child_process";import e from"node:path";import{cwd as r}from"node:process";import{resolveConfig as i}from"vite";import t from"../helpers/plugin-config.js";async function n({imageName:n,dockerFile:d,isOnlyClient:l=!1,dockerOptions:p="",mode:s=""}){const c="production"===s?"production":"development",a=await i({},"build",s),m=t(a),{root:u,build:{outDir:f}}=a,$=r(),g=`.${e.resolve(u,f).replace($,"")}`,b=l?"spa":"ssr",h=d||`${m.pluginPath}/workflow/Dockerfile`;o.execSync(`docker build -f ${h} --build-arg BUILD_PATH=${g} --build-arg RUN_TYPE=${b} --build-arg ENV_MODE=${c}${p} -t ${n} ${$}`,{stdio:"inherit",env:{...process.env}})}export{n as default};
2
2
  //# sourceMappingURL=run-docker-build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n isOnlyClient?: boolean;\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n isOnlyClient = false,\n dockerOptions = '',\n mode = '',\n}: IRunDockerBuildParams): Promise<void> {\n const nodeEnv = mode === 'production' ? 'production' : 'development';\n const config = await resolveConfig({}, 'build', mode);\n const pluginConfig = getPluginConfig(config);\n const {\n root,\n build: { outDir },\n } = config;\n const projectRoot = cwd();\n const buildDir = `.${path.resolve(root, outDir).replace(projectRoot, '')}`; // relative path\n const runType = isOnlyClient ? 'spa' : 'ssr';\n const docFile = dockerFile || `${pluginConfig.pluginPath}/workflow/Dockerfile`;\n\n childProcess.execSync(\n `docker build -f ${docFile}` +\n ` --build-arg ROOT_PATH=${projectRoot} --build-arg BUILD_PATH=${buildDir}` +\n ` --build-arg RUN_TYPE=${runType} --build-arg ENV_MODE=${nodeEnv}` +\n `${dockerOptions} -t ${imageName} ${projectRoot}`,\n {\n stdio: 'inherit',\n env: {\n ...process.env,\n },\n },\n );\n}\n\nexport default runDockerBuild;\n"],"names":["async","runDockerBuild","imageName","dockerFile","isOnlyClient","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"8KAiBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,aACVA,GAAe,EAAKC,cACpBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAmB,eAATD,EAAwB,aAAe,cACjDE,QAAeC,EAAc,CAAE,EAAE,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUjB,EAAe,MAAQ,MACjCkB,EAAUnB,GAAc,GAAGO,EAAaa,iCAE9CC,EAAaC,SACX,mBAAmBH,2BACSP,4BAAsCE,0BACvCI,0BAAgCd,IACtDF,QAAoBH,KAAaa,IACtC,CACEW,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
1
+ {"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n isOnlyClient?: boolean;\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n isOnlyClient = false,\n dockerOptions = '',\n mode = '',\n}: IRunDockerBuildParams): Promise<void> {\n const nodeEnv = mode === 'production' ? 'production' : 'development';\n const config = await resolveConfig({}, 'build', mode);\n const pluginConfig = getPluginConfig(config);\n const {\n root,\n build: { outDir },\n } = config;\n const projectRoot = cwd();\n const buildDir = `.${path.resolve(root, outDir).replace(projectRoot, '')}`; // relative path\n const runType = isOnlyClient ? 'spa' : 'ssr';\n const docFile = dockerFile || `${pluginConfig.pluginPath}/workflow/Dockerfile`;\n\n childProcess.execSync(\n `docker build -f ${docFile}` +\n ` --build-arg BUILD_PATH=${buildDir}` +\n ` --build-arg RUN_TYPE=${runType} --build-arg ENV_MODE=${nodeEnv}` +\n `${dockerOptions} -t ${imageName} ${projectRoot}`,\n {\n stdio: 'inherit',\n env: {\n ...process.env,\n },\n },\n );\n}\n\nexport default runDockerBuild;\n"],"names":["async","runDockerBuild","imageName","dockerFile","isOnlyClient","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"8KAiBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,aACVA,GAAe,EAAKC,cACpBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAmB,eAATD,EAAwB,aAAe,cACjDE,QAAeC,EAAc,CAAE,EAAE,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUjB,EAAe,MAAQ,MACjCkB,EAAUnB,GAAc,GAAGO,EAAaa,iCAE9CC,EAAaC,SACX,mBAAmBH,4BACUL,0BACFI,0BAAgCd,IACtDF,QAAoBH,KAAaa,IACtC,CACEW,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
package/cli/run-prod.d.ts CHANGED
@@ -8,6 +8,7 @@ interface IRunProdParams {
8
8
  isPrintInfo?: boolean;
9
9
  onlyClient?: boolean;
10
10
  mode?: string;
11
+ modulePreload?: boolean;
11
12
  }
12
13
  interface IRunProdOut {
13
14
  server: Server;
@@ -16,5 +17,5 @@ interface IRunProdOut {
16
17
  /**
17
18
  * Run production server
18
19
  */
19
- declare function runProd({ version, isHost, isPrintInfo, port, onlyClient, }: IRunProdParams): Promise<IRunProdOut>;
20
+ declare function runProd({ version, isHost, isPrintInfo, port, onlyClient, modulePreload, }: IRunProdParams): Promise<IRunProdOut>;
20
21
  export { runProd as default };
package/cli/run-prod.js CHANGED
@@ -1,2 +1,2 @@
1
- import{performance as o}from"node:perf_hooks";import r from"../node/server.js";import i from"../services/server-config.js";async function t({version:t,isHost:s,isPrintInfo:e,port:n,onlyClient:f=!1}){global.viteBoostStartTime||(global.viteBoostStartTime=o.now());const a=i.init({isHost:s,isProd:!0,isOnlyClient:f},{port:n}),{run:l}=await r(a);return{server:l({version:t,isPrintInfo:e}),config:a}}export{t as default};
1
+ import{performance as o}from"node:perf_hooks";import r from"../node/server.js";import i from"../services/server-config.js";async function e({version:e,isHost:t,isPrintInfo:s,port:n,onlyClient:l=!1,modulePreload:a=!1}){global.viteBoostStartTime||(global.viteBoostStartTime=o.now());const f=i.init({isHost:t,isProd:!0,isOnlyClient:l,isModulePreload:a},{port:n}),{run:m}=await r(f);return{server:m({version:e,isPrintInfo:s}),config:f}}export{e as default};
2
2
  //# sourceMappingURL=run-prod.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":["import type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport createServer from '@node/server';\nimport ServerConfig from '@services/server-config';\n\ninterface IRunProdParams {\n version: string;\n port?: number;\n isHost?: boolean;\n isPrintInfo?: boolean;\n onlyClient?: boolean; // SPA mode\n mode?: string;\n}\n\ninterface IRunProdOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run production server\n */\nasync function runProd({\n version,\n isHost,\n isPrintInfo,\n port,\n onlyClient = false,\n}: IRunProdParams): Promise<IRunProdOut> {\n if (!global.viteBoostStartTime) {\n global.viteBoostStartTime = performance.now();\n }\n\n const config = ServerConfig.init({ isHost, isProd: true, isOnlyClient: onlyClient }, { port });\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runProd;\n"],"names":["async","runProd","version","isHost","isPrintInfo","port","onlyClient","global","viteBoostStartTime","performance","now","config","ServerConfig","init","isProd","isOnlyClient","run","createServer","server"],"mappings":"2HAsBAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,WACJA,GAAa,IAERC,OAAOC,qBACVD,OAAOC,mBAAqBC,EAAYC,OAG1C,MAAMC,EAASC,EAAaC,KAAK,CAAEV,SAAQW,QAAQ,EAAMC,aAAcT,GAAc,CAAED,UACjFW,IAAEA,SAAcC,EAAaN,GAEnC,MAAO,CACLO,OAAQF,EAAI,CAAEd,UAASE,gBACvBO,SAEJ"}
1
+ {"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":["import type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport createServer from '@node/server';\nimport ServerConfig from '@services/server-config';\n\ninterface IRunProdParams {\n version: string;\n port?: number;\n isHost?: boolean;\n isPrintInfo?: boolean;\n onlyClient?: boolean; // SPA mode\n mode?: string;\n modulePreload?: boolean;\n}\n\ninterface IRunProdOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run production server\n */\nasync function runProd({\n version,\n isHost,\n isPrintInfo,\n port,\n onlyClient = false,\n modulePreload = false,\n}: IRunProdParams): Promise<IRunProdOut> {\n if (!global.viteBoostStartTime) {\n global.viteBoostStartTime = performance.now();\n }\n\n const config = ServerConfig.init(\n { isHost, isProd: true, isOnlyClient: onlyClient, isModulePreload: modulePreload },\n { port },\n );\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runProd;\n"],"names":["async","runProd","version","isHost","isPrintInfo","port","onlyClient","modulePreload","global","viteBoostStartTime","performance","now","config","ServerConfig","init","isProd","isOnlyClient","isModulePreload","run","createServer","server"],"mappings":"2HAuBAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,WACJA,GAAa,EAAKC,cAClBA,GAAgB,IAEXC,OAAOC,qBACVD,OAAOC,mBAAqBC,EAAYC,OAG1C,MAAMC,EAASC,EAAaC,KAC1B,CAAEX,SAAQY,QAAQ,EAAMC,aAAcV,EAAYW,gBAAiBV,GACnE,CAAEF,UAEEa,IAAEA,SAAcC,EAAaP,GAEnC,MAAO,CACLQ,OAAQF,EAAI,CAAEhB,UAASE,gBACvBQ,SAEJ"}
package/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as o}from"fs";import e from"chalk";import{Command as n,Option as i}from"commander";import t from"./cli/build.js";import r from"./cli/keyboard-input.js";import s from"./cli/run-dev.js";import a from"./cli/run-docker-build.js";import d from"./cli/run-prod.js";import c from"./cli/vite-reset-cache.js";import l from"./constants/cli-actions.js";import p from"./constants/cli-context.js";import m from"./constants/cli-name.js";const{description:f,version:u}=JSON.parse(o(new URL("./package.json",import.meta.url),"utf8")),v=()=>{process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.on("data",r).setEncoding("utf8").resume())},O=new n;O.name(m).description(f).version(u).hook("preAction",((o,e)=>{global.viteBoostAction=e.name()}));const w=new i("--host","Ability to access the local instance on other devices under the same network.").default(!1),k=new i("--only-client","Build/run only client side part.").default(!1),g=new i("--port [port]","Server port.").default(3e3),b=new i("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production");O.command(l.dev).description("Run development server.").addOption(w).addOption(new i("--reset-cache","Clear vite cache before run.").default(!1)).addOption(b).action((async({host:o,resetCache:e,mode:n})=>{e&&await c();const i=async e=>{const{server:i,config:t}=await s({version:u,isHost:o,isPrintInfo:e,mode:n});p.server=i,p.config=t};return p.reboot=i,v(),i()})),O.command(l.build).description("Create production build.").addOption(k).addOption(b).addOption(new i("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new i("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).addOption(new i("--unlock-robots","Change general directive Disallow to Allow in robots.txt").default(!1)).action((async({onlyClient:o,clientOptions:e,serverOptions:n,mode:i,unlockRobots:r})=>{await t({isOnlyClient:o,isUnlockRobots:r,clientOptions:e,serverOptions:n,mode:i})})),O.command(l.start).description("Run production server.").addOption(w).addOption(g).addOption(k).action((({host:o,port:e,onlyClient:n})=>{const i=async i=>{const{server:t,config:r}=await d({version:u,isHost:o,isPrintInfo:i,port:e,onlyClient:n});p.server=t,p.config=r};return p.reboot=i,v(),i()})),O.command(l.preview).description("Build and preview production.").addOption(k).addOption(w).addOption(g).addOption(b).action((async({host:o,port:n,onlyClient:i,mode:r})=>{global.viteBoostStartTime=performance.now();const s=async t=>{const{server:r,config:s}=await d({version:u,isHost:o,isPrintInfo:t,port:n,onlyClient:i});r.on("listening",(()=>{setTimeout((()=>{s.getLogger().info(e.yellow("\n Running preview mode... \n"))}),0)})),p.server=r,p.config=s};p.reboot=s,v();await t({mode:r,isWatch:!0,isOnlyClient:i,clientOptions:"-w",serverOptions:"-w",onFinish:()=>{s()}})})),O.command(l.buildDocker).description("Create docker image with production build.").requiredOption("--image-name <image-name>","Docker image name.").addOption(new i("--docker-options [docker-options]","Extra docker options which pass to docker build command.")).addOption(new i("--docker-file [docker-file]","Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).")).addOption(k).addOption(b).action((async({imageName:o,dockerOptions:e,dockerFile:n,onlyClient:i,mode:t})=>{await a({imageName:o,dockerOptions:e,dockerFile:n,isOnlyClient:i,mode:t})})),O.parse();
2
+ import{readFileSync as o}from"fs";import e from"chalk";import{Command as n,Option as t}from"commander";import i from"./cli/build.js";import r from"./cli/helpers/keyboard-input.js";import s from"./cli/helpers/vite-reset-cache.js";import d from"./cli/run-dev.js";import a from"./cli/run-docker-build.js";import c from"./cli/run-prod.js";import l from"./constants/cli-actions.js";import p from"./constants/cli-context.js";import m from"./constants/cli-name.js";const{description:u,version:f}=JSON.parse(o(new URL("./package.json",import.meta.url),"utf8")),w=()=>{process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.on("data",r).setEncoding("utf8").resume())},v=new n;v.name(m).description(u).version(f).hook("preAction",((o,e)=>{global.viteBoostAction=e.name()}));const O=new t("--host","Ability to access the local instance on other devices under the same network.").default(!1),h=new t("--only-client","Build/run only client side part.").default(!1),g=new t("--port [port]","Server port.").default(3e3),k=new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production");v.command(l.dev).description("Run development server.").addOption(O).addOption(new t("--reset-cache","Clear vite cache before run.").default(!1)).addOption(new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("development")).action((async({host:o,resetCache:n,mode:t})=>{n&&await s();const i=async n=>{console.info(e.cyan("Starting the development server..."));const{server:i,config:r}=await d({version:f,isHost:o,isPrintInfo:n,mode:t});p.server=i,p.config=r};return p.reboot=i,w(),i()})),v.command(l.build).description("Create production build.").addOption(h).addOption(k).addOption(new t("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new t("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).addOption(new t("--unlock-robots","Change general directive Disallow to Allow in robots.txt").default(!1)).addOption(new t("--eject","Produces entrypoint file to run app without cli").default(!1)).addOption(new t("--throw-warnings","The build will abort with an error if warnings occur in the process.").default(!1)).action((async({onlyClient:o,clientOptions:e,serverOptions:n,mode:t,unlockRobots:r,eject:s,throwWarnings:d})=>{await i({isOnlyClient:o,isUnlockRobots:r,isNoWarnings:d,isEject:s,clientOptions:e,serverOptions:n,mode:t})})),v.command(l.start).description("Run production server.").addOption(O).addOption(g).addOption(h).addOption(new t("--module-preload","Add module preload scripts to server output.").default(!1)).action((({host:o,port:e,onlyClient:n,modulePreload:t})=>{const i=async i=>{const{server:r,config:s}=await c({version:f,isHost:o,isPrintInfo:i,port:e,onlyClient:n,modulePreload:t});p.server=r,p.config=s};return p.reboot=i,w(),i()})),v.command(l.preview).description("Build and preview production.").addOption(h).addOption(O).addOption(g).addOption(k).action((async({host:o,port:n,onlyClient:t,mode:r})=>{global.viteBoostStartTime=performance.now();const s=async i=>{const{server:r,config:s}=await c({version:f,isHost:o,isPrintInfo:i,port:n,onlyClient:t});r.on("listening",(()=>{setTimeout((()=>{s.getLogger().info(e.yellow("\n Running preview mode... \n"))}),0)})),p.server=r,p.config=s};p.reboot=s,w();await i({mode:r,isWatch:!0,isOnlyClient:t,clientOptions:"-w",serverOptions:"-w",onFinish:()=>{s()}})})),v.command(l.buildDocker).description("Create docker image with production build.").requiredOption("--image-name <image-name>","Docker image name.").addOption(new t("--docker-options [docker-options]","Extra docker options which pass to docker build command.")).addOption(new t("--docker-file [docker-file]","Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).")).addOption(h).addOption(k).action((async({imageName:o,dockerOptions:e,dockerFile:n,onlyClient:t,mode:i})=>{await a({imageName:o,dockerOptions:e,dockerFile:n,isOnlyClient:t,mode:i})})),v.parse();
3
3
  //# sourceMappingURL=cli.js.map
package/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport chalk from 'chalk';\nimport { Command, Option } from 'commander';\nimport runBuild from '@cli/build';\nimport onKeyPress from '@cli/keyboard-input';\nimport runDev from '@cli/run-dev';\nimport runDockerBuild from '@cli/run-docker-build';\nimport runProd from '@cli/run-prod';\nimport viteResetCache from '@cli/vite-reset-cache';\nimport CliActions from '@constants/cli-actions';\nimport cliContext from '@constants/cli-context';\nimport cliName from '@constants/cli-name';\n\n/**\n * Parse package meta\n */\nconst { description, version } = JSON.parse(\n readFileSync(new URL('./package.json', import.meta.url), 'utf8'),\n) as { name: string; description: string; version: string };\n\n/**\n * Enable shortcuts\n * listen keyboard command\n */\nconst enableShortcuts = (): void => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n process.stdin.on('data', onKeyPress).setEncoding('utf8').resume();\n }\n};\n\nconst program = new Command();\n\nprogram\n .name(cliName)\n .description(description)\n .version(version)\n .hook('preAction', (_, actionCommand) => {\n // pass cli action to plugin config\n global.viteBoostAction = actionCommand.name();\n });\n\n/**\n * Common options\n */\nconst hostOption = new Option(\n '--host',\n 'Ability to access the local instance on other devices under the same network.',\n).default(false);\nconst onlyClientOption = new Option('--only-client', 'Build/run only client side part.').default(\n false,\n);\nconst portOption = new Option('--port [port]', 'Server port.').default(3000);\nconst envModeOption = new Option('--mode [mode]', 'Env mode.')\n .env('VITE_ENV_MODE')\n .default('production');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(new Option('--reset-cache', 'Clear vite cache before run.').default(false))\n .addOption(envModeOption)\n .action(async ({ host, resetCache, mode }) => {\n if (resetCache) {\n await viteResetCache();\n }\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runDev({ version, isHost: host, isPrintInfo, mode });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.build)\n .description('Create production build.')\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option(\n '--unlock-robots',\n 'Change general directive Disallow to Allow in robots.txt',\n ).default(false),\n )\n .action(async ({ onlyClient, clientOptions, serverOptions, mode, unlockRobots }) => {\n await runBuild({\n isOnlyClient: onlyClient,\n isUnlockRobots: unlockRobots,\n clientOptions,\n serverOptions,\n mode,\n });\n });\n\nprogram\n .command(CliActions.start)\n .description('Run production server.')\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(onlyClientOption)\n .action(({ host, port, onlyClient }) => {\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.preview)\n .description('Build and preview production.')\n .addOption(onlyClientOption)\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(envModeOption)\n .action(async ({ host, port, onlyClient, mode }) => {\n global.viteBoostStartTime = performance.now();\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n });\n\n server.on('listening', () => {\n setTimeout(() => {\n config.getLogger().info(chalk.yellow('\\n Running preview mode... \\n'));\n }, 0);\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n const buildOptions = '-w';\n\n await runBuild({\n mode,\n isWatch: true,\n isOnlyClient: onlyClient,\n clientOptions: buildOptions,\n serverOptions: buildOptions,\n onFinish: () => {\n void command();\n },\n });\n });\n\nprogram\n .command(CliActions.buildDocker)\n .description('Create docker image with production build.')\n .requiredOption('--image-name <image-name>', 'Docker image name.')\n .addOption(\n new Option(\n '--docker-options [docker-options]',\n 'Extra docker options which pass to docker build command.',\n ),\n )\n .addOption(\n new Option(\n '--docker-file [docker-file]',\n 'Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).',\n ),\n )\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .action(async ({ imageName, dockerOptions, dockerFile, onlyClient, mode }) => {\n await runDockerBuild({\n imageName,\n dockerOptions,\n dockerFile,\n isOnlyClient: onlyClient,\n mode,\n });\n });\n\nprogram.parse();\n"],"names":["description","version","JSON","parse","readFileSync","URL","url","enableShortcuts","process","stdin","isTTY","setRawMode","on","onKeyPress","setEncoding","resume","program","Command","name","cliName","hook","_","actionCommand","global","viteBoostAction","hostOption","Option","default","onlyClientOption","portOption","envModeOption","env","command","CliActions","dev","addOption","action","async","host","resetCache","mode","viteResetCache","isPrintInfo","server","config","runDev","isHost","cliContext","reboot","build","onlyClient","clientOptions","serverOptions","unlockRobots","runBuild","isOnlyClient","isUnlockRobots","start","port","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","info","chalk","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild"],"mappings":";0bAkBA,MAAMA,YAAEA,EAAWC,QAAEA,GAAYC,KAAKC,MACpCC,EAAa,IAAIC,IAAI,6BAA8BC,KAAM,SAOrDC,EAAkB,KAClBC,QAAQC,MAAMC,QAChBF,QAAQC,MAAME,YAAW,GACzBH,QAAQC,MAAMG,GAAG,OAAQ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M,UAAUP,GACVQ,QAAO,EAAGE,OAAMoB,OAAMR,iBACrB,MAAMlB,EAAUK,MAAOK,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBe,EAAQ,CACvC1D,UACA6C,OAAQR,EACRI,cACAgB,OACAR,eAGFH,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAAShB,EAEpBzB,IAEOyB,GAAS,IAGpBhB,EACGgB,QAAQC,EAAW2B,SACnB5D,YAAY,iCACZmC,UAAUP,GACVO,UAAUV,GACVU,UAAUN,GACVM,UAAUL,GACVM,QAAOC,OAASC,OAAMoB,OAAMR,aAAYV,WACvCjB,OAAOsC,mBAAqBC,YAAYC,MAExC,MAAM/B,EAAUK,MAAOK,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBe,EAAQ,CACvC1D,UACA6C,OAAQR,EACRI,cACAgB,OACAR,eAGFP,EAAO/B,GAAG,aAAa,KACrBoD,YAAW,KACTpB,EAAOqB,YAAYC,KAAKC,EAAMC,OAAO,kCAAkC,GACtE,EAAE,IAGPrB,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAG5BG,EAAWC,OAAShB,EAEpBzB,UAIM+C,EAAS,CACbd,OACA6B,SAAS,EACTd,aAAcL,EACdC,cANmB,KAOnBC,cAPmB,KAQnBkB,SAAU,KACHtC,GAAS,GAEhB,IAGNhB,EACGgB,QAAQC,EAAWsC,aACnBvE,YAAY,8CACZwE,eAAe,4BAA6B,sBAC5CrC,UACC,IAAIT,EACF,oCACA,6DAGHS,UACC,IAAIT,EACF,8BACA,yEAGHS,UAAUP,GACVO,UAAUL,GACVM,QAAOC,OAASoC,YAAWC,gBAAeC,aAAYzB,aAAYV,iBAC3DoC,EAAe,CACnBH,YACAC,gBACAC,aACApB,aAAcL,EACdV,QACA,IAGNxB,EAAQb"}
1
+ {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport chalk from 'chalk';\nimport { Command, Option } from 'commander';\nimport runBuild from '@cli/build';\nimport onKeyPress from '@cli/helpers/keyboard-input';\nimport viteResetCache from '@cli/helpers/vite-reset-cache';\nimport runDev from '@cli/run-dev';\nimport runDockerBuild from '@cli/run-docker-build';\nimport runProd from '@cli/run-prod';\nimport CliActions from '@constants/cli-actions';\nimport cliContext from '@constants/cli-context';\nimport cliName from '@constants/cli-name';\n\n/**\n * Parse package meta\n */\nconst { description, version } = JSON.parse(\n readFileSync(new URL('./package.json', import.meta.url), 'utf8'),\n) as { name: string; description: string; version: string };\n\n/**\n * Enable shortcuts\n * listen keyboard command\n */\nconst enableShortcuts = (): void => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n process.stdin.on('data', onKeyPress).setEncoding('utf8').resume();\n }\n};\n\nconst program = new Command();\n\nprogram\n .name(cliName)\n .description(description)\n .version(version)\n .hook('preAction', (_, actionCommand) => {\n // pass cli action to plugin config\n global.viteBoostAction = actionCommand.name();\n });\n\n/**\n * Common options\n */\nconst hostOption = new Option(\n '--host',\n 'Ability to access the local instance on other devices under the same network.',\n).default(false);\nconst onlyClientOption = new Option('--only-client', 'Build/run only client side part.').default(\n false,\n);\nconst portOption = new Option('--port [port]', 'Server port.').default(3000);\nconst envModeOption = new Option('--mode [mode]', 'Env mode.')\n .env('VITE_ENV_MODE')\n .default('production');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(new Option('--reset-cache', 'Clear vite cache before run.').default(false))\n .addOption(new Option('--mode [mode]', 'Env mode.').env('VITE_ENV_MODE').default('development'))\n .action(async ({ host, resetCache, mode }) => {\n if (resetCache) {\n await viteResetCache();\n }\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n console.info(chalk.cyan('Starting the development server...'));\n\n const { server, config } = await runDev({ version, isHost: host, isPrintInfo, mode });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.build)\n .description('Create production build.')\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option(\n '--unlock-robots',\n 'Change general directive Disallow to Allow in robots.txt',\n ).default(false),\n )\n .addOption(\n new Option('--eject', 'Produces entrypoint file to run app without cli').default(false),\n )\n .addOption(\n new Option(\n '--throw-warnings',\n 'The build will abort with an error if warnings occur in the process.',\n ).default(false),\n )\n .action(\n async ({\n onlyClient,\n clientOptions,\n serverOptions,\n mode,\n unlockRobots,\n eject,\n throwWarnings,\n }) => {\n await runBuild({\n isOnlyClient: onlyClient,\n isUnlockRobots: unlockRobots,\n isNoWarnings: throwWarnings,\n isEject: eject,\n clientOptions,\n serverOptions,\n mode,\n });\n },\n );\n\nprogram\n .command(CliActions.start)\n .description('Run production server.')\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(onlyClientOption)\n .addOption(\n new Option('--module-preload', 'Add module preload scripts to server output.').default(false),\n )\n .action(({ host, port, onlyClient, modulePreload }) => {\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n modulePreload,\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.preview)\n .description('Build and preview production.')\n .addOption(onlyClientOption)\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(envModeOption)\n .action(async ({ host, port, onlyClient, mode }) => {\n global.viteBoostStartTime = performance.now();\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n });\n\n server.on('listening', () => {\n setTimeout(() => {\n config.getLogger().info(chalk.yellow('\\n Running preview mode... \\n'));\n }, 0);\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n const buildOptions = '-w';\n\n await runBuild({\n mode,\n isWatch: true,\n isOnlyClient: onlyClient,\n clientOptions: buildOptions,\n serverOptions: buildOptions,\n onFinish: () => {\n void command();\n },\n });\n });\n\nprogram\n .command(CliActions.buildDocker)\n .description('Create docker image with production build.')\n .requiredOption('--image-name <image-name>', 'Docker image name.')\n .addOption(\n new Option(\n '--docker-options [docker-options]',\n 'Extra docker options which pass to docker build command.',\n ),\n )\n .addOption(\n new Option(\n '--docker-file [docker-file]',\n 'Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).',\n ),\n )\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .action(async ({ imageName, dockerOptions, dockerFile, onlyClient, mode }) => {\n await runDockerBuild({\n imageName,\n dockerOptions,\n dockerFile,\n isOnlyClient: onlyClient,\n mode,\n });\n });\n\nprogram.parse();\n"],"names":["description","version","JSON","parse","readFileSync","URL","url","enableShortcuts","process","stdin","isTTY","setRawMode","on","onKeyPress","setEncoding","resume","program","Command","name","cliName","hook","_","actionCommand","global","viteBoostAction","hostOption","Option","default","onlyClientOption","portOption","envModeOption","env","command","CliActions","dev","addOption","action","async","host","resetCache","mode","viteResetCache","isPrintInfo","console","info","chalk","cyan","server","config","runDev","isHost","cliContext","reboot","build","onlyClient","clientOptions","serverOptions","unlockRobots","eject","throwWarnings","runBuild","isOnlyClient","isUnlockRobots","isNoWarnings","isEject","start","port","modulePreload","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild"],"mappings":";0cAkBA,MAAMA,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IMqD,EAAS,CACbpB,OACAoC,SAAS,EACTf,aAAcP,EACdC,cANmB,KAOnBC,cAPmB,KAQnBqB,SAAU,KACH7C,GAAS,GAEhB,IAGNhB,EACGgB,QAAQC,EAAW6C,aACnB9E,YAAY,8CACZ+E,eAAe,4BAA6B,sBAC5C5C,UACC,IAAIT,EACF,oCACA,6DAGHS,UACC,IAAIT,EACF,8BACA,yEAGHS,UAAUP,GACVO,UAAUL,GACVM,QAAOC,OAAS2C,YAAWC,gBAAeC,aAAY5B,aAAYd,iBAC3D2C,EAAe,CACnBH,YACAC,gBACAC,aACArB,aAAcP,EACdd,QACA,IAGNxB,EAAQb"}
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ interface IScrollToTop {
3
+ shouldReloadReset?: boolean;
4
+ }
5
+ /**
6
+ * Scroll page to top on every pathname (url) change
7
+ * @constructor
8
+ */
9
+ declare const ScrollToTop: FC<IScrollToTop>;
10
+ export { ScrollToTop as default };
@@ -0,0 +1,2 @@
1
+ import{useRef as r,useEffect as o}from"react";import{useLocation as t}from"react-router-dom";const e=({shouldReloadReset:e=!1})=>{const{pathname:n}=t(),a=r(n);return o((()=>{(e||a.current!==n)&&(a.current=n,window.scrollTo(0,0))}),[n]),null};export{e as default};
2
+ //# sourceMappingURL=scroll-to-top.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-to-top.js","sources":["../../src/components/scroll-to-top.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect, useRef } from 'react';\nimport { useLocation } from 'react-router-dom';\n\ninterface IScrollToTop {\n shouldReloadReset?: boolean;\n}\n\n/**\n * Scroll page to top on every pathname (url) change\n * @constructor\n */\nconst ScrollToTop: FC<IScrollToTop> = ({ shouldReloadReset = false }) => {\n const { pathname } = useLocation();\n const prev = useRef(pathname);\n\n useEffect(() => {\n if (!shouldReloadReset && prev.current === pathname) {\n return;\n }\n\n prev.current = pathname;\n window.scrollTo(0, 0);\n }, [pathname]);\n\n return null;\n};\n\nexport default ScrollToTop;\n"],"names":["ScrollToTop","shouldReloadReset","pathname","useLocation","prev","useRef","useEffect","current","window","scrollTo"],"mappings":"6FAYM,MAAAA,EAAgC,EAAGC,qBAAoB,MAC3D,MAAMC,SAAEA,GAAaC,IACfC,EAAOC,EAAOH,GAWpB,OATAI,GAAU,MACHL,GAAqBG,EAAKG,UAAYL,KAI3CE,EAAKG,QAAUL,EACfM,OAAOC,SAAS,EAAG,GAAE,GACpB,CAACP,IAEG,IAAI"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get server state on the client side
3
+ */
4
+ declare const getServerState: (name: string, shouldRemove?: boolean) => Record<string, any>;
5
+ export { getServerState as default };
@@ -0,0 +1,2 @@
1
+ const e=(e,t=!0)=>{const n=window[e];return t&&n&&delete window[e],n??{}};export{e as default};
2
+ //# sourceMappingURL=get-server-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-server-state.js","sources":["../../src/helpers/get-server-state.ts"],"sourcesContent":["/**\n * Get server state on the client side\n */\nconst getServerState = (name: string, shouldRemove = true): Record<string, any> => {\n const data = window[name] as Record<string, any>;\n\n if (shouldRemove && data) {\n delete window[name];\n }\n\n return data ?? {};\n};\n\nexport default getServerState;\n"],"names":["getServerState","name","shouldRemove","data","window"],"mappings":"AAGM,MAAAA,EAAiB,CAACC,EAAcC,GAAe,KACnD,MAAMC,EAAOC,OAAOH,GAMpB,OAJIC,GAAgBC,UACXC,OAAOH,GAGTE,GAAQ,CAAA,CAAE"}
@@ -248,5 +248,5 @@ type IAsyncRoute = Omit<IndexRouteObject, ImmutableRouteKey> | Omit<NonIndexRout
248
248
  /**
249
249
  * Import dynamic route
250
250
  */
251
- declare const importRoute: (route: IDynamicRoute) => Promise<IAsyncRoute>;
251
+ declare const importRoute: (route: IDynamicRoute, id?: string) => Promise<IAsyncRoute>;
252
252
  export { importRoute as default, IDynamicRoute, IAsyncRoute };
@@ -1,2 +1,2 @@
1
- import e from"../components/with-suspense.js";import{keys as o}from"../interfaces/fc-route.js";const s=async s=>{const t=(await s()).default,n={Component:t};return o.forEach((e=>{t[e]&&(n[e]=t[e])})),t.Suspense&&(n.Component=e(t,t.Suspense)),n};export{s as default};
1
+ import t from"../components/with-suspense.js";import{keys as e}from"../interfaces/fc-route.js";const n=async(n,o)=>{const s=await n();if(s.Component)return{...s,pathId:o};const p=s.default,r={Component:p,pathId:o};return e.forEach((t=>{p[t]&&(r[t]=p[t])})),p.Suspense&&(r.Component=t(p,p.Suspense)),r};export{n as default};
2
2
  //# sourceMappingURL=import-route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-route.js","sources":["../../src/helpers/import-route.ts"],"sourcesContent":["import type { ImmutableRouteKey } from '@remix-run/router/utils';\nimport type { IndexRouteObject, NonIndexRouteObject } from 'react-router-dom';\nimport withSuspense from '@components/with-suspense';\nimport type { FCCRoute, FCRoute } from '@interfaces/fc-route';\nimport { keys } from '@interfaces/fc-route';\n\nexport type IDynamicRoute = () => Promise<{ default: FCRoute | FCCRoute<any> }>;\n\nexport type IAsyncRoute =\n | Omit<IndexRouteObject, ImmutableRouteKey>\n | Omit<NonIndexRouteObject, ImmutableRouteKey>;\n\n/**\n * Import dynamic route\n */\nconst importRoute = async (route: IDynamicRoute): Promise<IAsyncRoute> => {\n const Component = (await route()).default;\n const result = { Component };\n\n keys.forEach((key) => {\n if (Component[key]) {\n result[key] = Component[key];\n }\n });\n\n if (Component.Suspense) {\n result.Component = withSuspense(Component, Component.Suspense);\n }\n\n return result;\n};\n\nexport default importRoute;\n"],"names":["importRoute","async","route","Component","default","result","keys","forEach","key","Suspense","withSuspense"],"mappings":"+FAeA,MAAMA,EAAcC,MAAOC,IACzB,MAAMC,SAAmBD,KAASE,QAC5BC,EAAS,CAAEF,aAYjB,OAVAG,EAAKC,SAASC,IACRL,EAAUK,KACZH,EAAOG,GAAOL,EAAUK,GACzB,IAGCL,EAAUM,WACZJ,EAAOF,UAAYO,EAAaP,EAAWA,EAAUM,WAGhDJ,CAAM"}
1
+ {"version":3,"file":"import-route.js","sources":["../../src/helpers/import-route.ts"],"sourcesContent":["import type { ImmutableRouteKey } from '@remix-run/router/utils';\nimport type { IndexRouteObject, NonIndexRouteObject } from 'react-router-dom';\nimport withSuspense from '@components/with-suspense';\nimport type { FCCRoute, FCRoute } from '@interfaces/fc-route';\nimport { keys } from '@interfaces/fc-route';\n\nexport type IDynamicRoute = () => Promise<{ default: FCRoute | FCCRoute<any> }>;\n\nexport type IAsyncRoute =\n | Omit<IndexRouteObject, ImmutableRouteKey>\n | Omit<NonIndexRouteObject, ImmutableRouteKey>;\n\n/**\n * Import dynamic route\n */\nconst importRoute = async (route: IDynamicRoute, id?: string): Promise<IAsyncRoute> => {\n const resolved = await route();\n\n // fallback to react router export style\n if (resolved['Component']) {\n return { ...resolved, pathId: id } as IAsyncRoute;\n }\n\n const Component = resolved.default;\n const result = { Component, pathId: id };\n\n keys.forEach((key) => {\n if (Component[key]) {\n result[key] = Component[key];\n }\n });\n\n if (Component.Suspense) {\n result.Component = withSuspense(Component, Component.Suspense);\n }\n\n return result;\n};\n\nexport default importRoute;\n"],"names":["importRoute","async","route","id","resolved","pathId","Component","default","result","keys","forEach","key","Suspense","withSuspense"],"mappings":"+FAeM,MAAAA,EAAcC,MAAOC,EAAsBC,KAC/C,MAAMC,QAAiBF,IAGvB,GAAIE,EAAoB,UACtB,MAAO,IAAKA,EAAUC,OAAQF,GAGhC,MAAMG,EAAYF,EAASG,QACrBC,EAAS,CAAEF,YAAWD,OAAQF,GAYpC,OAVAM,EAAKC,SAASC,IACRL,EAAUK,KACZH,EAAOG,GAAOL,EAAUK,GACzB,IAGCL,EAAUM,WACZJ,EAAOF,UAAYO,EAAaP,EAAWA,EAAUM,WAGhDJ,CAAM"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detect route file
3
+ */
4
+ declare const isRoutesFile: (code: string) => boolean;
5
+ export { isRoutesFile as default };
@@ -0,0 +1,2 @@
1
+ const t=t=>/\[.*{.*path:.*lazy:.+import/s.test(t);export{t as default};
2
+ //# sourceMappingURL=is-route-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-route-file.js","sources":["../../src/helpers/is-route-file.ts"],"sourcesContent":["/**\n * Detect route file\n */\nconst isRoutesFile = (code: string): boolean => /\\[.*{.*path:.*lazy:.+import/s.test(code);\n\nexport default isRoutesFile;\n"],"names":["isRoutesFile","code","test"],"mappings":"AAGA,MAAMA,EAAgBC,GAA0B,+BAA+BC,KAAKD"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Stop node process
3
3
  */
4
- declare const processStop: (code?: number) => never;
4
+ declare const processStop: (code?: number, isOnlyError?: boolean) => void;
5
5
  export { processStop as default };
@@ -1,2 +1,2 @@
1
- import o from"node:process";const e=(e=0)=>o.exit(e);export{e as default};
1
+ import o from"node:process";const e=(e=0,t=!1)=>{t&&0===e||o.exit(e)};export{e as default};
2
2
  //# sourceMappingURL=process-stop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process-stop.js","sources":["../../src/helpers/process-stop.ts"],"sourcesContent":["import process from 'node:process';\n\n/**\n * Stop node process\n */\nconst processStop = (code = 0) => process.exit(code);\n\nexport default processStop;\n"],"names":["processStop","code","process","exit"],"mappings":"4BAKA,MAAMA,EAAc,CAACC,EAAO,IAAMC,EAAQC,KAAKF"}
1
+ {"version":3,"file":"process-stop.js","sources":["../../src/helpers/process-stop.ts"],"sourcesContent":["import process from 'node:process';\n\n/**\n * Stop node process\n */\nconst processStop = (code = 0, isOnlyError = false) => {\n if (isOnlyError && code === 0) {\n return;\n }\n\n process.exit(code);\n};\n\nexport default processStop;\n"],"names":["processStop","code","isOnlyError","process","exit"],"mappings":"4BAKM,MAAAA,EAAc,CAACC,EAAO,EAAGC,GAAc,KACvCA,GAAwB,IAATD,GAInBE,EAAQC,KAAKH,EAAK"}
@@ -1,2 +1,2 @@
1
- import{fileURLToPath as e,URL as r}from"node:url";const a=e=>e.replace("./","/").replace(/([^:]\/)\/+/g,"$1"),p=(p,t="")=>p.map((([p,l])=>({find:p,replacement:e(new r(`${t}${a(l)}`,import.meta.url))})));export{p as default};
1
+ import{fileURLToPath as e,URL as r,pathToFileURL as t}from"node:url";const a=e=>e.replace("./","/").replace(/([^:]\/)\/+/g,"$1"),o=(o,p="")=>o.map((([o,l])=>({find:o,replacement:e(new r(t(`${p}${a(l)}`).toString(),import.meta.url))})));export{o as default};
2
2
  //# sourceMappingURL=vite-aliases.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-aliases.js","sources":["../../src/helpers/vite-aliases.ts"],"sourcesContent":["import { fileURLToPath, URL } from 'node:url';\nimport type { Alias } from 'vite';\n\nconst cleanupPath = (path: string) => path.replace('./', '/').replace(/([^:]\\/)\\/+/g, '$1');\n\n/**\n * Set vite aliases\n */\nconst viteAliases = (aliases: [string, string][], root = ''): Alias[] =>\n aliases.map(([find, path]) => ({\n find,\n replacement: fileURLToPath(new URL(`${root}${cleanupPath(path)}`, import.meta.url)),\n }));\n\nexport default viteAliases;\n"],"names":["cleanupPath","path","replace","viteAliases","aliases","root","map","find","replacement","fileURLToPath","URL","url"],"mappings":"kDAGA,MAAMA,EAAeC,GAAiBA,EAAKC,QAAQ,KAAM,KAAKA,QAAQ,eAAgB,MAKhFC,EAAc,CAACC,EAA6BC,EAAO,KACvDD,EAAQE,KAAI,EAAEC,EAAMN,MAAW,CAC7BM,OACAC,YAAaC,EAAc,IAAIC,EAAI,GAAGL,IAAOL,EAAYC,iBAAqBU"}
1
+ {"version":3,"file":"vite-aliases.js","sources":["../../src/helpers/vite-aliases.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL, URL } from 'node:url';\nimport type { Alias } from 'vite';\n\nconst cleanupPath = (path: string) => path.replace('./', '/').replace(/([^:]\\/)\\/+/g, '$1');\n\n/**\n * Set vite aliases\n */\nconst viteAliases = (aliases: [string, string][], root = ''): Alias[] =>\n aliases.map(([find, path]) => ({\n find,\n replacement: fileURLToPath(\n new URL(pathToFileURL(`${root}${cleanupPath(path)}`).toString(), import.meta.url),\n ),\n }));\n\nexport default viteAliases;\n"],"names":["cleanupPath","path","replace","viteAliases","aliases","root","map","find","replacement","fileURLToPath","URL","pathToFileURL","toString","url"],"mappings":"qEAGA,MAAMA,EAAeC,GAAiBA,EAAKC,QAAQ,KAAM,KAAKA,QAAQ,eAAgB,MAKhFC,EAAc,CAACC,EAA6BC,EAAO,KACvDD,EAAQE,KAAI,EAAEC,EAAMN,MAAW,CAC7BM,OACAC,YAAaC,EACX,IAAIC,EAAIC,EAAc,GAAGN,IAAOL,EAAYC,MAASW,uBAAwBC"}
@@ -1,5 +1,14 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { RouteObject } from 'react-router/dist/lib/context';
3
+ import { IRequestContext } from "../node/render.js";
4
+ declare module '@remix-run/router' {
5
+ interface LoaderFunctionArgs {
6
+ context?: IRequestContext;
7
+ }
8
+ interface ActionFunctionArgs {
9
+ context?: IRequestContext;
10
+ }
11
+ }
3
12
  declare const keys: readonly ["loader", "action", "ErrorBoundary", "errorElement"];
4
13
  type IRouteParams = Pick<RouteObject, (typeof keys)[number]> & {
5
14
  Suspense?: FC;
@@ -1 +1 @@
1
- {"version":3,"file":"fc-route.js","sources":["../../src/interfaces/fc-route.ts"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport type { RouteObject } from 'react-router/dist/lib/context';\n\nconst keys = ['loader', 'action', 'ErrorBoundary', 'errorElement'] as const;\n\ntype IRouteParams = Pick<RouteObject, (typeof keys)[number]> & { Suspense?: FC };\n\ntype FCRoute<TProps = Record<string, any>> = FC<TProps> & IRouteParams;\ntype FCCRoute<TProps = Record<string, any>> = FC<PropsWithChildren<TProps>> & IRouteParams;\n\nexport type { FCRoute, FCCRoute, IRouteParams };\n\nexport { keys };\n"],"names":["keys"],"mappings":"AAGM,MAAAA,EAAO,CAAC,SAAU,SAAU,gBAAiB"}
1
+ {"version":3,"file":"fc-route.js","sources":["../../src/interfaces/fc-route.ts"],"sourcesContent":["import type { FC, PropsWithChildren } from 'react';\nimport type { RouteObject } from 'react-router/dist/lib/context';\nimport type { IRequestContext } from '@node/render';\n\ndeclare module '@remix-run/router' {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n export interface LoaderFunctionArgs {\n context?: IRequestContext;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n export interface ActionFunctionArgs {\n context?: IRequestContext;\n }\n}\n\nconst keys = ['loader', 'action', 'ErrorBoundary', 'errorElement'] as const;\n\ntype IRouteParams = Pick<RouteObject, (typeof keys)[number]> & { Suspense?: FC };\n\ntype FCRoute<TProps = Record<string, any>> = FC<TProps> & IRouteParams;\ntype FCCRoute<TProps = Record<string, any>> = FC<PropsWithChildren<TProps>> & IRouteParams;\n\nexport type { FCRoute, FCCRoute, IRouteParams };\n\nexport { keys };\n"],"names":["keys"],"mappings":"AAgBM,MAAAA,EAAO,CAAC,SAAU,SAAU,gBAAiB"}
@@ -1,7 +1,7 @@
1
1
  import { RouteObject } from 'react-router-dom';
2
2
  import { IDynamicRoute } from "../helpers/import-route.js";
3
3
  type TRouteObjectNR = Omit<RouteObject, 'lazy' | 'children'> & {
4
- lazyNR?: IDynamicRoute;
4
+ lazy?: IDynamicRoute | RouteObject['lazy'];
5
5
  children?: TRouteObject[];
6
6
  };
7
7
  type TRouteObject = RouteObject | TRouteObjectNR;
package/node/entry.d.ts CHANGED
@@ -6,6 +6,7 @@ import { IRenderOptions, TRender } from "./render.js";
6
6
  import ServerConfig from "../services/server-config.js";
7
7
  interface IInitServerRequestOut<T = Record<string, any>> {
8
8
  appProps?: T;
9
+ hasEarlyHints?: boolean;
9
10
  }
10
11
  interface IEntrypointOptions<TAppProps = Record<string, any>> {
11
12
  onServerCreated?: (app: Express) => Promise<void> | void;
@@ -20,12 +21,16 @@ interface IEntrypointOptions<TAppProps = Record<string, any>> {
20
21
  interface IPrepareRenderOut<TAppProps = Record<string, any>> {
21
22
  render: TRender;
22
23
  init: IEntryServerOptions<TAppProps>['init'];
24
+ routes: TRouteObject[];
25
+ abortDelay?: number;
23
26
  }
24
27
  interface IAppServerProps<T = Record<string, any>> {
25
28
  server: T;
26
29
  }
27
30
  type TApp<T> = FC<PropsWithChildren<Record<string, any> & IAppServerProps<T>>>;
28
31
  interface IEntryServerOptions<TAppProps = Record<string, any>> {
32
+ abortDelay?: number;
33
+ hasEarlyHints?: boolean;
29
34
  init?: (params: {
30
35
  config: ServerConfig;
31
36
  }) => IEntrypointOptions<TAppProps> | Promise<IEntrypointOptions<TAppProps>>;
@@ -33,5 +38,5 @@ interface IEntryServerOptions<TAppProps = Record<string, any>> {
33
38
  /**
34
39
  * Render server side application
35
40
  */
36
- declare function entry<TAppProps>(App: TApp<TAppProps>, routes: TRouteObject[], { init }?: IEntryServerOptions<TAppProps>): IPrepareRenderOut<TAppProps>;
41
+ declare function entry<TAppProps>(App: TApp<TAppProps>, routes: TRouteObject[], { init, abortDelay }?: IEntryServerOptions<TAppProps>): IPrepareRenderOut<TAppProps>;
37
42
  export { entry as default, IInitServerRequestOut, IEntrypointOptions, IPrepareRenderOut, IAppServerProps, TApp, IEntryServerOptions };
package/node/entry.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createStaticHandler as r}from"react-router-dom/server.mjs";import e from"./render.js";function n(n,t,{init:o}={}){const i=r(t);return{render:e.bind(null,{handler:i,App:n}),init:o}}export{n as default};
1
+ import{createStaticHandler as r}from"react-router-dom/server.mjs";import e from"./render.js";function t(t,o,{init:n,abortDelay:a}={}){const i=r(o);return{render:e.bind(null,{handler:i,App:t}),init:n,routes:o,abortDelay:a}}export{t as default};
2
2
  //# sourceMappingURL=entry.js.map
package/node/entry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","sources":["../../src/node/entry.tsx"],"sourcesContent":["import type { Express, Request, Response as ExpressResponse } from 'express';\nimport type { FC, PropsWithChildren } from 'react';\nimport type { RouteObject } from 'react-router-dom';\nimport { createStaticHandler } from 'react-router-dom/server.mjs';\nimport type { TRouteObject } from '@interfaces/route-object';\nimport type { IRenderOptions, IRenderParams, TRender } from '@node/render';\nimport render from '@node/render';\nimport type ServerConfig from '@services/server-config';\n\nexport interface IInitServerRequestOut<T = Record<string, any>> {\n appProps?: T;\n}\n\nexport interface IEntrypointOptions<TAppProps = Record<string, any>> {\n onServerCreated?: (app: Express) => Promise<void> | void;\n onRequest?: (\n req: Request,\n res: ExpressResponse,\n ) => Promise<IInitServerRequestOut<TAppProps>> | IInitServerRequestOut<TAppProps>;\n onRouterReady?: IRenderOptions<TAppProps>['onRouterReady'];\n onShellReady?: IRenderOptions<TAppProps>['onShellReady'];\n onShellError?: IRenderOptions<TAppProps>['onShellError'];\n onResponse?: IRenderOptions<TAppProps>['onResponse'];\n onError?: IRenderOptions<TAppProps>['onError'];\n getState?: IRenderOptions<TAppProps>['getState'];\n}\n\nexport interface IPrepareRenderOut<TAppProps = Record<string, any>> {\n render: TRender;\n init: IEntryServerOptions<TAppProps>['init'];\n}\n\nexport interface IAppServerProps<T = Record<string, any>> {\n server: T;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<Record<string, any> & IAppServerProps<T>>>;\n\nexport interface IEntryServerOptions<TAppProps = Record<string, any>> {\n init?: (params: {\n config: ServerConfig;\n }) => IEntrypointOptions<TAppProps> | Promise<IEntrypointOptions<TAppProps>>;\n}\n\n/**\n * Render server side application\n */\nfunction entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: TRouteObject[],\n { init }: IEntryServerOptions<TAppProps> = {},\n): IPrepareRenderOut<TAppProps> {\n const handler = createStaticHandler(routes as RouteObject[]);\n\n return {\n render: render.bind(null, { handler, App } as IRenderParams<TAppProps>) as TRender,\n init,\n };\n}\n\nexport default entry;\n"],"names":["entry","App","routes","init","handler","createStaticHandler","render","bind"],"mappings":"6FA+CA,SAASA,EACPC,EACAC,GACAC,KAAEA,GAAyC,CAAA,GAE3C,MAAMC,EAAUC,EAAoBH,GAEpC,MAAO,CACLI,OAAQA,EAAOC,KAAK,KAAM,CAAEH,UAASH,QACrCE,OAEJ"}
1
+ {"version":3,"file":"entry.js","sources":["../../src/node/entry.tsx"],"sourcesContent":["import type { Express, Request, Response as ExpressResponse } from 'express';\nimport type { FC, PropsWithChildren } from 'react';\nimport type { RouteObject } from 'react-router-dom';\nimport { createStaticHandler } from 'react-router-dom/server.mjs';\nimport type { TRouteObject } from '@interfaces/route-object';\nimport type { IRenderOptions, IRenderParams, TRender } from '@node/render';\nimport render from '@node/render';\nimport type ServerConfig from '@services/server-config';\n\nexport interface IInitServerRequestOut<T = Record<string, any>> {\n appProps?: T;\n hasEarlyHints?: boolean;\n}\n\nexport interface IEntrypointOptions<TAppProps = Record<string, any>> {\n onServerCreated?: (app: Express) => Promise<void> | void;\n onRequest?: (\n req: Request,\n res: ExpressResponse,\n ) => Promise<IInitServerRequestOut<TAppProps>> | IInitServerRequestOut<TAppProps>;\n onRouterReady?: IRenderOptions<TAppProps>['onRouterReady'];\n onShellReady?: IRenderOptions<TAppProps>['onShellReady'];\n onShellError?: IRenderOptions<TAppProps>['onShellError'];\n onResponse?: IRenderOptions<TAppProps>['onResponse'];\n onError?: IRenderOptions<TAppProps>['onError'];\n getState?: IRenderOptions<TAppProps>['getState'];\n}\n\nexport interface IPrepareRenderOut<TAppProps = Record<string, any>> {\n render: TRender;\n init: IEntryServerOptions<TAppProps>['init'];\n routes: TRouteObject[];\n abortDelay?: number;\n}\n\nexport interface IAppServerProps<T = Record<string, any>> {\n server: T;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<Record<string, any> & IAppServerProps<T>>>;\n\nexport interface IEntryServerOptions<TAppProps = Record<string, any>> {\n abortDelay?: number;\n hasEarlyHints?: boolean;\n init?: (params: {\n config: ServerConfig;\n }) => IEntrypointOptions<TAppProps> | Promise<IEntrypointOptions<TAppProps>>;\n}\n\n/**\n * Render server side application\n */\nfunction entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: TRouteObject[],\n { init, abortDelay }: IEntryServerOptions<TAppProps> = {},\n): IPrepareRenderOut<TAppProps> {\n const handler = createStaticHandler(routes as RouteObject[]);\n\n return {\n render: render.bind(null, { handler, App } as IRenderParams<TAppProps>) as TRender,\n init,\n routes,\n abortDelay,\n };\n}\n\nexport default entry;\n"],"names":["entry","App","routes","init","abortDelay","handler","createStaticHandler","render","bind"],"mappings":"6FAoDA,SAASA,EACPC,EACAC,GACAC,KAAEA,EAAIC,WAAEA,GAA+C,IAEvD,MAAMC,EAAUC,EAAoBJ,GAEpC,MAAO,CACLK,OAAQA,EAAOC,KAAK,KAAM,CAAEH,UAASJ,QACrCE,OACAD,SACAE,aAEJ"}