@lomray/vite-ssr-boost 1.0.0-beta.3 → 1.0.0-beta.30

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 (85) hide show
  1. package/README.md +213 -0
  2. package/browser/entry.d.ts +2 -2
  3. package/browser/entry.js.map +1 -1
  4. package/cli/build.d.ts +5 -1
  5. package/cli/build.js +1 -1
  6. package/cli/build.js.map +1 -1
  7. package/cli/run-dev.d.ts +2 -1
  8. package/cli/run-dev.js +1 -1
  9. package/cli/run-dev.js.map +1 -1
  10. package/cli/run-docker-build.d.ts +12 -0
  11. package/cli/run-docker-build.js +2 -0
  12. package/cli/run-docker-build.js.map +1 -0
  13. package/cli/run-prod.d.ts +1 -0
  14. package/cli/run-prod.js +1 -1
  15. package/cli/run-prod.js.map +1 -1
  16. package/cli.js +1 -1
  17. package/cli.js.map +1 -1
  18. package/components/scroll-to-top.d.ts +7 -0
  19. package/components/scroll-to-top.js +2 -0
  20. package/components/scroll-to-top.js.map +1 -0
  21. package/components/with-suspense.d.ts +7 -0
  22. package/components/with-suspense.js +2 -0
  23. package/components/with-suspense.js.map +1 -0
  24. package/constants/cli-actions.d.ts +1 -0
  25. package/constants/cli-actions.js +1 -1
  26. package/constants/cli-actions.js.map +1 -1
  27. package/helpers/dev-marker.d.ts +9 -0
  28. package/helpers/dev-marker.js +2 -0
  29. package/helpers/dev-marker.js.map +1 -0
  30. package/helpers/get-server-state.d.ts +5 -0
  31. package/helpers/get-server-state.js +2 -0
  32. package/helpers/get-server-state.js.map +1 -0
  33. package/helpers/import-route.d.ts +252 -0
  34. package/helpers/import-route.js +2 -0
  35. package/helpers/import-route.js.map +1 -0
  36. package/helpers/is-route-file.d.ts +5 -0
  37. package/helpers/is-route-file.js +2 -0
  38. package/helpers/is-route-file.js.map +1 -0
  39. package/helpers/print-server-info.js +1 -1
  40. package/helpers/print-server-info.js.map +1 -1
  41. package/helpers/print-server-urls.js +1 -1
  42. package/helpers/print-server-urls.js.map +1 -1
  43. package/helpers/vite-aliases.d.ts +6 -0
  44. package/helpers/vite-aliases.js +2 -0
  45. package/helpers/vite-aliases.js.map +1 -0
  46. package/interfaces/fc-route.d.ts +19 -0
  47. package/interfaces/fc-route.js +2 -0
  48. package/interfaces/fc-route.js.map +1 -0
  49. package/interfaces/fc.d.ts +4 -0
  50. package/interfaces/fc.js +2 -0
  51. package/interfaces/fc.js.map +1 -0
  52. package/interfaces/route-object.d.ts +8 -0
  53. package/interfaces/route-object.js +2 -0
  54. package/interfaces/route-object.js.map +1 -0
  55. package/node/entry.d.ts +7 -2
  56. package/node/entry.js +1 -1
  57. package/node/entry.js.map +1 -1
  58. package/node/render.d.ts +3 -2
  59. package/node/render.js +1 -1
  60. package/node/render.js.map +1 -1
  61. package/node/server.js +1 -1
  62. package/node/server.js.map +1 -1
  63. package/package.json +9 -5
  64. package/plugin.d.ts +7 -4
  65. package/plugin.js +1 -1
  66. package/plugin.js.map +1 -1
  67. package/plugins/make-aliases.d.ts +11 -0
  68. package/plugins/make-aliases.js +2 -0
  69. package/plugins/make-aliases.js.map +1 -0
  70. package/plugins/normalize-route.d.ts +16 -0
  71. package/plugins/normalize-route.js +2 -0
  72. package/plugins/normalize-route.js.map +1 -0
  73. package/services/build.d.ts +94 -0
  74. package/services/build.js +2 -0
  75. package/services/build.js.map +1 -0
  76. package/services/prepare-server.d.ts +4 -3
  77. package/services/prepare-server.js +1 -1
  78. package/services/prepare-server.js.map +1 -1
  79. package/services/server-config.d.ts +6 -10
  80. package/services/server-config.js +1 -1
  81. package/services/server-config.js.map +1 -1
  82. package/services/ssr-manifest.d.ts +189 -0
  83. package/services/ssr-manifest.js +2 -0
  84. package/services/ssr-manifest.js.map +1 -0
  85. package/workflow/Dockerfile +23 -0
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ <h1 align='center'>Vite SSR BOOST</h1>
2
+
3
+ - Develop ⚡charged⚡ server side applications with React streaming 💨 support.
4
+ - Unlocks Suspense for server side applications.
5
+ - Switch between SPA and SSR in 1 second.
6
+ - Charged CLI out of box.
7
+ - Very easy to migrate, very easy to use.
8
+ - All the power of [vite](https://vitejs.dev/)⚡
9
+ - All the power of [react-router](https://reactrouter.com/)🛣
10
+
11
+ <p align="center">
12
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=reliability_rating" alt="reliability">
13
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=security_rating" alt="Security Rating">
14
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=sqale_rating" alt="Maintainability Rating">
15
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=vulnerabilities" alt="Vulnerabilities">
16
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=bugs" alt="Bugs">
17
+ <img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=ncloc" alt="Lines of Code">
18
+ <img src="https://img.shields.io/bundlephobia/minzip/@lomray/vite-ssr-boost" alt="size">
19
+ <img src="https://img.shields.io/npm/l/@lomray/vite-ssr-boost" alt="size">
20
+ <img src="https://img.shields.io/npm/v/@lomray/vite-ssr-boost?label=semantic%20release&logo=semantic-release" alt="semantic version">
21
+ </p>
22
+
23
+ ## Table of contents
24
+ - [Getting started](#getting-started)
25
+ - [How to use](#how-to-use)
26
+ - [Plugin options](#plugin-options)
27
+ - [CLI](#cli)
28
+ - [Example](#demo)
29
+ - [Bugs and feature requests](#bugs-and-feature-requests)
30
+ - [License](#license)
31
+
32
+ ## Getting started
33
+
34
+ The package is distributed using [npm](https://www.npmjs.com/), the node package manager.
35
+
36
+ ```
37
+ npm i --save @lomray/vite-ssr-boost
38
+ ```
39
+
40
+ ## How to use
41
+
42
+ 1. Add plugin to vite config:
43
+ ```typescript
44
+ /**
45
+ * vite.config.ts
46
+ */
47
+
48
+ import { defineConfig } from 'vite'
49
+ import react from '@vitejs/plugin-react'
50
+ /**
51
+ * Import plugin
52
+ */
53
+ import SsrBoost from '@lomray/vite-ssr-boost/plugin';
54
+
55
+ // https://vitejs.dev/config/
56
+ export default defineConfig({
57
+ /**
58
+ * Change root not necessary, but more understandable
59
+ */
60
+ root: 'src',
61
+ publicDir: '../public',
62
+ build: {
63
+ outDir: '../build',
64
+ },
65
+ /**
66
+ * Put here
67
+ */
68
+ plugins: [SsrBoost(), react()],
69
+ });
70
+
71
+ ```
72
+ 2. Create `client` entrypoint:
73
+
74
+ ```typescript jsx
75
+ /**
76
+ * src/client.tsx
77
+ */
78
+ import entryClient from '@lomray/vite-ssr-boost/browser/entry';
79
+ import App from './App.tsx'
80
+ import routes from './routes';
81
+
82
+ void entryClient(App, routes, {
83
+ /**
84
+ * Client configuration (optional)
85
+ */
86
+ init: () => {}
87
+ });
88
+ ```
89
+
90
+ 3. Create `server` entrypoint:
91
+
92
+ ```typescript jsx
93
+ /**
94
+ * src/server.ts
95
+ */
96
+ import entryServer from '@lomray/vite-ssr-boost/node/entry';
97
+ import App from './App';
98
+ import routes from './routes';
99
+
100
+ export default entryServer(App, routes, {
101
+ /**
102
+ * Request timeout (If your backend is slow, increase this value)
103
+ */
104
+ abortDelay: 15000, // default: 15000 (ms)
105
+ /**
106
+ * Server configuration (optional)
107
+ */
108
+ init: () => ({
109
+ /**
110
+ * (optional). Called once after express server creation.
111
+ * E.g. use for configure express middlewares
112
+ */
113
+ onServerCreated: () => {},
114
+ /**
115
+ * (optional). Called on each incoming request.
116
+ * E.g. configure request state, create state manager etc.
117
+ */
118
+ onRequest: async () => {},
119
+ /**
120
+ * (optional). Called when react router and it's context was created.
121
+ * E.g. here you can switch stream depends on req.headers, for search crawlers you can disable stream.
122
+ */
123
+ onRouterReady: () => {},
124
+ /**
125
+ * (optional). Called when application shell is ready to send on client.
126
+ * E.g. here you can modify header or footer.
127
+ */
128
+ onShellReady: () => {},
129
+ /**
130
+ * (optional). Called when application shell or suspense resolved and sent to the client.
131
+ * E.g. here you can add some payload like custom state (any manager state) to response.
132
+ */
133
+ onResponse: () => {},
134
+ /**
135
+ * (optional). Called when application shell or all html (depends on stream option) is ready to send on client.
136
+ * E.g. here you can send any context or state to client.
137
+ */
138
+ getState: () => {},
139
+ }),
140
+ }, App);
141
+ ```
142
+
143
+ 4. Replace `package.json` scripts:
144
+
145
+ ```json
146
+ {
147
+ ...
148
+ "scripts": {
149
+ "develop": "ssr-boost dev",
150
+ "build": "ssr-boost build",
151
+ "start:ssr": "ssr-boost start",
152
+ "start:spa": "ssr-boost start --only-client",
153
+ "preview": "ssr-boost preview"
154
+ },
155
+ ...
156
+ }
157
+ ```
158
+
159
+ 5. Let's do the magic:
160
+
161
+ ```shell
162
+ npm run develop
163
+ ```
164
+
165
+ ## Plugin options
166
+ ```typescript
167
+ import SsrBoost from '@lomray/vite-ssr-boost/plugin';
168
+ import type { FCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route';
169
+
170
+ /**
171
+ * Configuration
172
+ */
173
+ SsrBoost({
174
+ /**
175
+ * index.html file path
176
+ */
177
+ indexFile: 'index.html', // default: index.html
178
+ /**
179
+ * Server entrypoint file
180
+ */
181
+ serverFile: 'server.ts', // default: server.ts
182
+ /**
183
+ * Client entrypoint file
184
+ */
185
+ clientFile: 'client.ts', // default: client.ts
186
+ /**
187
+ * Add tsconfig aliases to vite config aliases
188
+ */
189
+ tsconfigAliases: true, // default: true
190
+ /**
191
+ * Production: add scripts to head (server-side)
192
+ */
193
+ preloadAssets: false, // default: false
194
+ })
195
+ ```
196
+
197
+ ## CLI
198
+ Explore all commands and options:
199
+ ```shell
200
+ ssr-boost -h
201
+ ```
202
+
203
+ ## Demo
204
+ Explore [demo app](https://github.com/Lomray-Software/vite-template) to more understand.
205
+
206
+ ## Bugs and feature requests
207
+
208
+ Bug or a feature request, [please open a new issue](https://github.com/Lomray-Software/vite-ssr-boost/issues/new).
209
+
210
+ ## License
211
+ Made with 💚
212
+
213
+ Published under [Apache License](./LICENSE).
@@ -2,7 +2,7 @@
2
2
  import { Router as RemixRouter } from '@remix-run/router/dist/router';
3
3
  import { FC, PropsWithChildren } from 'react';
4
4
  import ReactDOM from 'react-dom/client';
5
- import { RouteObject } from 'react-router-dom';
5
+ import { TRouteObject } from "../interfaces/route-object.js";
6
6
  interface IAppClientProps<T = undefined> {
7
7
  client: T;
8
8
  }
@@ -17,5 +17,5 @@ interface IEntryClientOptions<T> {
17
17
  /**
18
18
  * Render client side application
19
19
  */
20
- declare function entry<TAppProps>(App: TApp<TAppProps>, routes: RouteObject[], { init }?: IEntryClientOptions<TAppProps>): Promise<ReactDOM.Root | void>;
20
+ declare function entry<TAppProps>(App: TApp<TAppProps>, routes: TRouteObject[], { init }?: IEntryClientOptions<TAppProps>): Promise<ReactDOM.Root | void>;
21
21
  export { entry as default, IAppClientProps, IInitPropsParams, TApp, IEntryClientOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":["import type { Router as RemixRouter } from '@remix-run/router/dist/router';\nimport type { FC, PropsWithChildren } from 'react';\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport type { RouteObject } from 'react-router-dom';\nimport { createBrowserRouter, matchRoutes, RouterProvider } from 'react-router-dom';\nimport { IS_SSR_MODE } from '@constants/common';\n\nexport interface IAppClientProps<T = undefined> {\n client: T;\n}\n\nexport interface IInitPropsParams {\n isSSRMode: boolean;\n router: RemixRouter;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<IAppClientProps<T>>>;\n\nexport interface IEntryClientOptions<T> {\n init?: (params: IInitPropsParams) => Promise<T>;\n}\n\n/**\n * Render client side application\n */\nasync function entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: RouteObject[],\n { init }: IEntryClientOptions<TAppProps> = {},\n): Promise<ReactDOM.Root | void> {\n const lazyMatches = matchRoutes(routes, window.location)?.filter((m) => m.route.lazy);\n\n // Load the lazy matches and update the routes before creating router,\n // so we can hydrate the SSR-rendered content synchronously\n if (lazyMatches && lazyMatches?.length > 0) {\n await Promise.all(\n lazyMatches.map(async (m) => {\n const routeModule = await m.route.lazy?.();\n\n Object.assign(m.route, {\n ...routeModule,\n lazy: undefined,\n });\n }),\n );\n }\n\n const router = createBrowserRouter(routes);\n const root = document.getElementById('root') as HTMLElement;\n const appProps = (await init?.({ isSSRMode: IS_SSR_MODE, router })) as TAppProps;\n\n const AppComponent: FC = () => (\n <App client={appProps}>\n <RouterProvider router={router} />\n </App>\n );\n\n if (!IS_SSR_MODE) {\n return ReactDOM.createRoot(root).render(<AppComponent />);\n }\n\n return ReactDOM.hydrateRoot(root, <AppComponent />);\n}\n\nexport default entry;\n"],"names":["async","entry","App","routes","init","lazyMatches","matchRoutes","window","location","filter","m","route","lazy","length","Promise","all","map","routeModule","Object","assign","undefined","router","createBrowserRouter","root","document","getElementById","appProps","isSSRMode","IS_SSR_MODE","AppComponent","React","createElement","client","RouterProvider","ReactDOM","hydrateRoot","createRoot","render"],"mappings":"sMA0BAA,eAAeC,EACbC,EACAC,GACAC,KAAEA,GAAyC,CAAA,GAE3C,MAAMC,EAAcC,EAAYH,EAAQI,OAAOC,WAAWC,QAAQC,GAAMA,EAAEC,MAAMC,OAI5EP,GAAeA,GAAaQ,OAAS,SACjCC,QAAQC,IACZV,EAAYW,KAAIhB,MAAOU,IACrB,MAAMO,QAAoBP,EAAEC,MAAMC,UAElCM,OAAOC,OAAOT,EAAEC,MAAO,IAClBM,EACHL,UAAMQ,GACN,KAKR,MAAMC,EAASC,EAAoBnB,GAC7BoB,EAAOC,SAASC,eAAe,QAC/BC,QAAkBtB,IAAO,CAAEuB,UAAWC,EAAaP,YAEnDQ,EAAmB,IACvBC,EAAAC,cAAC7B,EAAG,CAAC8B,OAAQN,GACXI,EAACC,cAAAE,GAAeZ,OAAQA,KAI5B,OAAKO,EAIEM,EAASC,YAAYZ,EAAMO,EAACC,cAAAF,EAAe,OAHzCK,EAASE,WAAWb,GAAMc,OAAOP,EAAAC,cAACF,EAAY,MAIzD"}
1
+ {"version":3,"file":"entry.js","sources":["../../src/browser/entry.tsx"],"sourcesContent":["import type { Router as RemixRouter } from '@remix-run/router/dist/router';\nimport type { FC, PropsWithChildren } from 'react';\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport type { RouteObject } from 'react-router-dom';\nimport { createBrowserRouter, matchRoutes, RouterProvider } from 'react-router-dom';\nimport { IS_SSR_MODE } from '@constants/common';\nimport type { TRouteObject } from '@interfaces/route-object';\n\nexport interface IAppClientProps<T = undefined> {\n client: T;\n}\n\nexport interface IInitPropsParams {\n isSSRMode: boolean;\n router: RemixRouter;\n}\n\nexport type TApp<T> = FC<PropsWithChildren<IAppClientProps<T>>>;\n\nexport interface IEntryClientOptions<T> {\n init?: (params: IInitPropsParams) => Promise<T>;\n}\n\n/**\n * Render client side application\n */\nasync function entry<TAppProps>(\n App: TApp<TAppProps>,\n routes: TRouteObject[],\n { init }: IEntryClientOptions<TAppProps> = {},\n): Promise<ReactDOM.Root | void> {\n const lazyMatches = matchRoutes(routes as RouteObject[], window.location)?.filter(\n (m) => m.route.lazy,\n );\n\n // Load the lazy matches and update the routes before creating router,\n // so we can hydrate the SSR-rendered content synchronously\n if (lazyMatches && lazyMatches?.length > 0) {\n await Promise.all(\n lazyMatches.map(async (m) => {\n const routeModule = await m.route.lazy?.();\n\n Object.assign(m.route, {\n ...routeModule,\n lazy: undefined,\n });\n }),\n );\n }\n\n const router = createBrowserRouter(routes as RouteObject[]);\n const root = document.getElementById('root') as HTMLElement;\n const appProps = (await init?.({ isSSRMode: IS_SSR_MODE, router })) as TAppProps;\n\n const AppComponent: FC = () => (\n <App client={appProps}>\n <RouterProvider router={router} />\n </App>\n );\n\n if (!IS_SSR_MODE) {\n return ReactDOM.createRoot(root).render(<AppComponent />);\n }\n\n return ReactDOM.hydrateRoot(root, <AppComponent />);\n}\n\nexport default entry;\n"],"names":["async","entry","App","routes","init","lazyMatches","matchRoutes","window","location","filter","m","route","lazy","length","Promise","all","map","routeModule","Object","assign","undefined","router","createBrowserRouter","root","document","getElementById","appProps","isSSRMode","IS_SSR_MODE","AppComponent","React","createElement","client","RouterProvider","ReactDOM","hydrateRoot","createRoot","render"],"mappings":"sMA2BAA,eAAeC,EACbC,EACAC,GACAC,KAAEA,GAAyC,CAAA,GAE3C,MAAMC,EAAcC,EAAYH,EAAyBI,OAAOC,WAAWC,QACxEC,GAAMA,EAAEC,MAAMC,OAKbP,GAAeA,GAAaQ,OAAS,SACjCC,QAAQC,IACZV,EAAYW,KAAIhB,MAAOU,IACrB,MAAMO,QAAoBP,EAAEC,MAAMC,UAElCM,OAAOC,OAAOT,EAAEC,MAAO,IAClBM,EACHL,UAAMQ,GACN,KAKR,MAAMC,EAASC,EAAoBnB,GAC7BoB,EAAOC,SAASC,eAAe,QAC/BC,QAAkBtB,IAAO,CAAEuB,UAAWC,EAAaP,YAEnDQ,EAAmB,IACvBC,EAAAC,cAAC7B,EAAG,CAAC8B,OAAQN,GACXI,EAACC,cAAAE,GAAeZ,OAAQA,KAI5B,OAAKO,EAIEM,EAASC,YAAYZ,EAAMO,EAACC,cAAAF,EAAe,OAHzCK,EAASE,WAAWb,GAAMc,OAAOP,EAAAC,cAACF,EAAY,MAIzD"}
package/cli/build.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  interface IBuildParams {
2
2
  isOnlyClient?: boolean;
3
3
  isWatch?: boolean;
4
+ isEject?: boolean;
5
+ isUnlockRobots?: boolean;
4
6
  clientOptions?: string;
5
7
  serverOptions?: string;
8
+ mode?: string;
9
+ onFinish?: () => void;
6
10
  }
7
11
  /**
8
12
  * Build production application
9
13
  */
10
- declare function build({ isOnlyClient, isWatch, clientOptions, serverOptions, }: IBuildParams): Promise<void | [unknown, unknown]>;
14
+ declare function build({ onFinish, isOnlyClient, isWatch, isUnlockRobots, isEject, clientOptions, serverOptions, mode, }: IBuildParams): Promise<void>;
11
15
  export { build as default };
package/cli/build.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"node:child_process";import{performance as o}from"node:perf_hooks";import i from"chalk";import{resolveConfig as r}from"vite";import t from"../constants/cli-name.js";import n from"../helpers/plugin-config.js";const s=e=>new Promise(((o,i)=>{e.on("exit",(e=>{o(e)})),e.on("close",(e=>{o(e)})),e.on("error",(e=>{i(e)}))}));async function l({isOnlyClient:l=!1,isWatch:a=!1,clientOptions:c="",serverOptions:p=""}){const m=o.now(),u=await r({},"build"),d=n(u),{outDir:f}=u.build,h=["client"],S=new AbortController,v=s(e.spawn(`vite build ${c} --emptyOutDir --outDir ${f}/client`,{signal:S.signal,stdio:"inherit",shell:!0,env:{...process.env,SSR_BOOST_IS_SSR:l?"0":"1"}}));let w;if(a||await v,l||(w=s(e.spawn(`vite build ${p} --emptyOutDir --outDir ${f}/server --ssr ${d.serverFile}`,{signal:S.signal,stdio:"inherit",shell:!0,env:{...process.env,SSR_BOOST_IS_SSR:l?"0":"1"}})),a||await w,h.push("server")),a){process.on("exit",(()=>{S.abort()}));const e=Promise.all([v,w]);return e.controller=S,e}const $=i.dim(`${i.yellowBright(h.join(","))} built in ${i.reset(i.bold(Math.ceil(o.now()-m)))} ms`);console.info(`\n ${i.green(`${i.bold(t.toUpperCase())}`)} ${$}\n`)}export{l as default};
1
+ import o from"node:child_process";import{performance as e}from"node:perf_hooks";import t from"chalk";import i from"./vite-reset-cache.js";import s from"../constants/cli-name.js";import{createDevMarker as r}from"../helpers/dev-marker.js";import n from"../services/build.js";async function a({onFinish:a,isOnlyClient:l=!1,isWatch:d=!1,isUnlockRobots:c=!1,isEject:m=!1,clientOptions:p="",serverOptions:u="",mode:O=""}){const f=e.now(),v=new n({mode:O}),S=["client"],$=new AbortController,_=O?`--mode ${O}`:"";await v.makeConfig(),await i(),v.clearBuildFolder();const b=v.promisifyProcess(o.spawn(`vite build ${p} --emptyOutDir --outDir ${v.outDir}/client ${_}`,{signal:$.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:l?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}}));let g;if(d||await b,l||(g=v.promisifyProcess(o.spawn(`vite build ${u} --emptyOutDir --outDir ${v.outDir}/server --ssr ${v.serverFile} ${_}`,{signal:$.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:l?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}})),d||(await g,await v.buildManifest(),m&&v.eject()),S.push("server")),d){process.on("exit",(()=>{$.abort()}));let o=l?1:2;const e=t=>{Buffer.from(t).toString().includes("built in")&&(o-=1,o||(b.command.stdout.removeListener("data",e),g?.command.stdout.removeListener("data",e),r(v.isProd,v.viteConfig),a?.()))};return b.command.stdout.on("data",e),void g?.command.stdout.on("data",e)}c&&v.unlockRobots(),r(v.isProd,v.viteConfig),a?.();const h=Math.ceil(e.now()-f),w=h>1e3?(h/1e3).toFixed(2):h,C=h>1e3?"s":"ms",R=t.dim(`${t.yellowBright(S.join(","))} built in ${t.reset(t.bold(w))} ${C}`);console.info(`\n ${t.green(`${t.bold(s.toUpperCase())}`)} ${R} ${v.isProd?"":t.redBright(`NODE_ENV=${v.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 { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport cliName from '@constants/cli-name';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IBuildParams {\n isOnlyClient?: boolean;\n isWatch?: boolean;\n clientOptions?: string;\n serverOptions?: string;\n}\n\n/**\n * Promisify spawn process\n */\nconst promisify = (command: childProcess.ChildProcess) =>\n 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/**\n * Build production application\n */\nasync function build({\n isOnlyClient = false,\n isWatch = false,\n clientOptions = '',\n serverOptions = '',\n}: IBuildParams): Promise<void | [unknown, unknown]> {\n const perfStart = performance.now();\n const config = await resolveConfig({}, 'build');\n const pluginConfig = getPluginConfig(config);\n const { outDir } = config.build;\n const types = ['client'];\n const controller = new AbortController();\n\n // build client\n const clientProcess = promisify(\n childProcess.spawn(`vite build ${clientOptions} --emptyOutDir --outDir ${outDir}/client`, {\n signal: controller.signal,\n stdio: 'inherit',\n shell: true,\n env: {\n ...process.env,\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n },\n }),\n );\n\n if (!isWatch) {\n await clientProcess;\n }\n\n let serverProcess;\n\n if (!isOnlyClient) {\n // build server\n serverProcess = promisify(\n childProcess.spawn(\n `vite build ${serverOptions} --emptyOutDir --outDir ${outDir}/server --ssr ${pluginConfig.serverFile}`,\n {\n signal: controller.signal,\n stdio: 'inherit',\n shell: true,\n env: {\n ...process.env,\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 if (isWatch) {\n process.on('exit', () => {\n controller.abort();\n });\n\n const buildPromise = Promise.all([clientProcess, serverProcess]);\n\n buildPromise['controller'] = controller;\n\n return buildPromise;\n }\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`,\n );\n}\n\nexport default build;\n"],"names":["promisify","command","Promise","resolve","reject","on","code","message","async","build","isOnlyClient","isWatch","clientOptions","serverOptions","perfStart","performance","now","config","resolveConfig","pluginConfig","getPluginConfig","outDir","types","controller","AbortController","clientProcess","childProcess","spawn","signal","stdio","shell","env","process","SSR_BOOST_IS_SSR","serverProcess","serverFile","push","abort","buildPromise","all","buildDurationString","chalk","dim","yellowBright","join","reset","bold","Math","ceil","console","info","green","cliName","toUpperCase"],"mappings":"6NAiBA,MAAMA,EAAaC,GACjB,IAAIC,SAAQ,CAACC,EAASC,KACpBH,EAAQI,GAAG,QAASC,IAClBH,EAAQG,EAAK,IAGfL,EAAQI,GAAG,SAAUC,IACnBH,EAAQG,EAAK,IAGfL,EAAQI,GAAG,SAAUE,IACnBH,EAAOG,EAAQ,GACf,IAMNC,eAAeC,GAAMC,aACnBA,GAAe,EAAKC,QACpBA,GAAU,EAAKC,cACfA,EAAgB,GAAEC,cAClBA,EAAgB,KAEhB,MAAMC,EAAYC,EAAYC,MACxBC,QAAeC,EAAc,CAAE,EAAE,SACjCC,EAAeC,EAAgBH,IAC/BI,OAAEA,GAAWJ,EAAOR,MACpBa,EAAQ,CAAC,UACTC,EAAa,IAAIC,gBAGjBC,EAAgBzB,EACpB0B,EAAaC,MAAM,cAAcf,4BAAwCS,WAAiB,CACxFO,OAAQL,EAAWK,OACnBC,MAAO,UACPC,OAAO,EACPC,IAAK,IACAC,QAAQD,IACXE,iBAAkBvB,EAAe,IAAM,QAS7C,IAAIwB,EA0BJ,GA9BKvB,SACGc,EAKHf,IAEHwB,EAAgBlC,EACd0B,EAAaC,MACX,cAAcd,4BAAwCQ,kBAAuBF,EAAagB,aAC1F,CACEP,OAAQL,EAAWK,OACnBC,MAAO,UACPC,OAAO,EACPC,IAAK,IACAC,QAAQD,IACXE,iBAAkBvB,EAAe,IAAM,QAM1CC,SACGuB,EAGRZ,EAAMc,KAAK,WAGTzB,EAAS,CACXqB,QAAQ3B,GAAG,QAAQ,KACjBkB,EAAWc,OAAO,IAGpB,MAAMC,EAAepC,QAAQqC,IAAI,CAACd,EAAeS,IAIjD,OAFAI,EAAyB,WAAIf,EAEtBe,CACR,CAED,MAAME,EAAsBC,EAAMC,IAChC,GAAGD,EAAME,aAAarB,EAAMsB,KAAK,kBAAkBH,EAAMI,MACvDJ,EAAMK,KAAKC,KAAKC,KAAKjC,EAAYC,MAAQF,WAI7CmC,QAAQC,KACN,OAAOT,EAAMU,MAAM,GAAGV,EAAMK,KAAKM,EAAQC,sBAAsBb,MAEnE"}
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/vite-reset-cache';\nimport cliName from '@constants/cli-name';\nimport { createDevMarker } from '@helpers/dev-marker';\nimport Build from '@services/build';\n\ninterface IBuildParams {\n isOnlyClient?: boolean;\n isWatch?: boolean;\n isEject?: boolean;\n isUnlockRobots?: boolean;\n clientOptions?: string;\n serverOptions?: string;\n mode?: string;\n onFinish?: () => void;\n}\n\n/**\n * Build production application\n */\nasync function build({\n onFinish,\n isOnlyClient = false,\n isWatch = false,\n isUnlockRobots = false,\n isEject = false,\n clientOptions = '',\n serverOptions = '',\n mode = '',\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', process.stderr],\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 );\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 = 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', process.stderr],\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 );\n\n if (!isWatch) {\n await serverProcess;\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","isOnlyClient","isWatch","isUnlockRobots","isEject","clientOptions","serverOptions","mode","perfStart","performance","now","buildService","Build","types","controller","AbortController","modeOpt","makeConfig","viteResetCache","clearBuildFolder","clientProcess","promisifyProcess","childProcess","spawn","outDir","signal","stdio","process","stdin","stderr","shell","env","FORCE_COLOR","SSR_BOOST_IS_SSR","SSR_BOOST_ACTION","global","viteBoostAction","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":"iRAsBAA,eAAeC,GAAMC,SACnBA,EAAQC,aACRA,GAAe,EAAKC,QACpBA,GAAU,EAAKC,eACfA,GAAiB,EAAKC,QACtBA,GAAU,EAAKC,cACfA,EAAgB,GAAEC,cAClBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAYC,EAAYC,MACxBC,EAAe,IAAIC,EAAM,CAAEL,SAC3BM,EAAQ,CAAC,UACTC,EAAa,IAAIC,gBACjBC,EAAUT,EAAO,UAAUA,IAAS,SAEpCI,EAAaM,mBAGbC,IACNP,EAAaQ,mBAKb,MAAMC,EAAgBT,EAAaU,iBACjCC,EAAaC,MACX,cAAclB,4BAAwCM,EAAaa,iBAAiBR,IACpF,CACES,OAAQX,EAAWW,OACnBC,MAAO,CAACC,QAAQC,MAAO,OAAQD,QAAQE,QACvCC,OAAO,EACPC,IAAK,IACAJ,QAAQI,IACXC,YAAa,IACbC,iBAAkBhC,EAAe,IAAM,IACvCiC,iBAAkBC,OAAOC,oBAUjC,IAAIC,EAsCJ,GA1CKnC,SACGkB,EAQHnB,IACHoC,EAAgB1B,EAAaU,iBAC3BC,EAAaC,MACX,cAAcjB,4BAAwCK,EAAaa,uBAAuBb,EAAa2B,cAActB,IACrH,CACES,OAAQX,EAAWW,OACnBC,MAAO,CAACC,QAAQC,MAAO,OAAQD,QAAQE,QACvCC,OAAO,EACPC,IAAK,IACAJ,QAAQI,IACXC,YAAa,IACbC,iBAAkBhC,EAAe,IAAM,IACvCiC,iBAAkBC,OAAOC,oBAM5BlC,UACGmC,QACA1B,EAAa4B,gBAEfnC,GACFO,EAAa6B,SAIjB3B,EAAM4B,KAAK,WAMTvC,EAAS,CACXyB,QAAQe,GAAG,QAAQ,KACjB5B,EAAW6B,OAAO,IAGpB,IAAIC,EAAa3C,EAAe,EAAI,EACpC,MAAM4C,EAAYC,IACJC,OAAOC,KAAKF,GAAMG,WAEtBC,SAAS,cACfN,GAAc,EAETA,IACHxB,EAAuB,QAAE+B,OAAOC,eAAe,OAAQP,GACvDR,GAAyB,QAAEc,OAAOC,eAAe,OAAQP,GACzDQ,EAAgB1C,EAAa2C,OAAQ3C,EAAa4C,YAClDvD,OAEH,EASH,OAHAoB,EAAuB,QAAE+B,OAAOT,GAAG,OAAQG,QAC3CR,GAAyB,QAAEc,OAAOT,GAAG,OAAQG,EAG9C,CAEG1C,GACFQ,EAAa6C,eAGfH,EAAgB1C,EAAa2C,OAAQ3C,EAAa4C,YAClDvD,MAEA,MAAMyD,EAAaC,KAAKC,KAAKlD,EAAYC,MAAQF,GAC3CoD,EAAWH,EAAa,KAAQA,EAAa,KAAMI,QAAQ,GAAKJ,EAChEK,EAAQL,EAAa,IAAO,IAAM,KAElCM,EAAsBC,EAAMC,IAChC,GAAGD,EAAME,aAAarD,EAAMsD,KAAK,kBAAkBH,EAAMI,MAAMJ,EAAMK,KAAKT,OAAcE,KAG1FQ,QAAQC,KACN,OAAOP,EAAMQ,MAAM,GAAGR,EAAMK,KAAKI,EAAQC,sBAAsBX,KAC7DpD,EAAa2C,OAAS,GAAKU,EAAMW,UAAU,YAAYhE,EAAaiE,eAG1E"}
package/cli/run-dev.d.ts CHANGED
@@ -5,6 +5,7 @@ interface IRunDevParams {
5
5
  version: string;
6
6
  isHost?: boolean;
7
7
  isPrintInfo?: boolean;
8
+ mode?: string;
8
9
  }
9
10
  interface IRunDevOut {
10
11
  server: Server;
@@ -13,5 +14,5 @@ interface IRunDevOut {
13
14
  /**
14
15
  * Run development server
15
16
  */
16
- declare function runDev({ version, isHost, isPrintInfo }: IRunDevParams): Promise<IRunDevOut>;
17
+ declare function runDev({ version, isHost, isPrintInfo, mode }: IRunDevParams): Promise<IRunDevOut>;
17
18
  export { runDev as default };
package/cli/run-dev.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 s({version:s,isHost:e,isPrintInfo:n}){global.viteBoostStartTime=o.now();const t=i.init({isHost:e}),{run:f}=await r(t);return{server:f({version:s,isPrintInfo:n}),config:t}}export{s as default};
1
+ import{performance as o}from"node:perf_hooks";import r from"../node/server.js";import e from"../services/server-config.js";async function i({version:i,isHost:s,isPrintInfo:n,mode:t}){global.viteBoostStartTime=o.now();const f=e.init({isHost:s,mode:t}),{run:m}=await r(f);return{server:m({version:i,isPrintInfo:n}),config:f}}export{i as default};
2
2
  //# sourceMappingURL=run-dev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-dev.js","sources":["../../src/cli/run-dev.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 IRunDevParams {\n version: string;\n isHost?: boolean;\n isPrintInfo?: boolean;\n}\n\ninterface IRunDevOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run development server\n */\nasync function runDev({ version, isHost, isPrintInfo }: IRunDevParams): Promise<IRunDevOut> {\n global.viteBoostStartTime = performance.now();\n\n const config = ServerConfig.init({ isHost });\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runDev;\n"],"names":["async","runDev","version","isHost","isPrintInfo","global","viteBoostStartTime","performance","now","config","ServerConfig","init","run","createServer","server"],"mappings":"2HAmBAA,eAAeC,GAAOC,QAAEA,EAAOC,OAAEA,EAAMC,YAAEA,IACvCC,OAAOC,mBAAqBC,EAAYC,MAExC,MAAMC,EAASC,EAAaC,KAAK,CAAER,YAC7BS,IAAEA,SAAcC,EAAaJ,GAEnC,MAAO,CACLK,OAAQF,EAAI,CAAEV,UAASE,gBACvBK,SAEJ"}
1
+ {"version":3,"file":"run-dev.js","sources":["../../src/cli/run-dev.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 IRunDevParams {\n version: string;\n isHost?: boolean;\n isPrintInfo?: boolean;\n mode?: string;\n}\n\ninterface IRunDevOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run development server\n */\nasync function runDev({ version, isHost, isPrintInfo, mode }: IRunDevParams): Promise<IRunDevOut> {\n global.viteBoostStartTime = performance.now();\n\n const config = ServerConfig.init({ isHost, mode });\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runDev;\n"],"names":["async","runDev","version","isHost","isPrintInfo","mode","global","viteBoostStartTime","performance","now","config","ServerConfig","init","run","createServer","server"],"mappings":"2HAoBAA,eAAeC,GAAOC,QAAEA,EAAOC,OAAEA,EAAMC,YAAEA,EAAWC,KAAEA,IACpDC,OAAOC,mBAAqBC,EAAYC,MAExC,MAAMC,EAASC,EAAaC,KAAK,CAAET,SAAQE,UACrCQ,IAAEA,SAAcC,EAAaJ,GAEnC,MAAO,CACLK,OAAQF,EAAI,CAAEX,UAASE,gBACvBM,SAEJ"}
@@ -0,0 +1,12 @@
1
+ interface IRunDockerBuildParams {
2
+ imageName: string;
3
+ dockerOptions?: string;
4
+ dockerFile?: string;
5
+ isOnlyClient?: boolean;
6
+ mode?: string;
7
+ }
8
+ /**
9
+ * Build docker image
10
+ */
11
+ declare function runDockerBuild({ imageName, dockerFile, isOnlyClient, dockerOptions, mode, }: IRunDockerBuildParams): Promise<void>;
12
+ export { runDockerBuild as default };
@@ -0,0 +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 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
+ //# sourceMappingURL=run-docker-build.js.map
@@ -0,0 +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 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
@@ -7,6 +7,7 @@ interface IRunProdParams {
7
7
  isHost?: boolean;
8
8
  isPrintInfo?: boolean;
9
9
  onlyClient?: boolean;
10
+ mode?: string;
10
11
  }
11
12
  interface IRunProdOut {
12
13
  server: Server;
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 n({version:n,isHost:s,isPrintInfo:t,port:e,onlyClient:f=!1}){global.viteBoostStartTime=o.now();const a=i.init({isHost:s,isProd:!0,isOnlyClient:f},{port:e}),{run:l}=await r(a);return{server:l({version:n,isPrintInfo:t}),config:a}}export{n 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 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};
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}\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 global.viteBoostStartTime = performance.now();\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":"2HAqBAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,WACJA,GAAa,IAEbC,OAAOC,mBAAqBC,EAAYC,MAExC,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}\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"}
package/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import{readFileSync as o}from"fs";import t from"chalk";import{Command as n,Option as e}from"commander";import i from"./cli/build.js";import s from"./cli/keyboard-input.js";import r from"./cli/run-dev.js";import c from"./cli/run-prod.js";import a from"./cli/vite-reset-cache.js";import p from"./constants/cli-actions.js";import d from"./constants/cli-context.js";import l from"./constants/cli-name.js";const{description:m,version:f}=JSON.parse(o(new URL("./package.json",import.meta.url),"utf8")),v=()=>{process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.on("data",s).setEncoding("utf8").resume())},u=new n;u.name(l).description(m).version(f).hook("preAction",((o,t)=>{global.viteBoostAction=t.name()}));const O=new e("--host","Ability to access the local instance on other devices under the same network.").default(!1),w=new e("--only-client","Build/run only client side part.").default(!1),y=new e("--port [port]","Server port.").default(3e3);u.command(p.dev).description("Run development server.").addOption(O).addOption(new e("--reset-cache","Clear vite cache before run.").default(!1)).action((async({host:o,resetCache:t})=>{t&&await a();const n=async t=>{const{server:n,config:e}=await r({version:f,isHost:o,isPrintInfo:t});d.server=n,d.config=e};return d.reboot=n,v(),n()})),u.command(p.build).description("Create production build.").addOption(w).addOption(new e("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new e("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).action((async({onlyClient:o,clientOptions:t,serverOptions:n})=>{await i({isOnlyClient:o,clientOptions:t,serverOptions:n})})),u.command(p.start).description("Run production server.").addOption(O).addOption(y).addOption(w).action((({host:o,port:t,onlyClient:n})=>{const e=async e=>{const{server:i,config:s}=await c({version:f,isHost:o,isPrintInfo:e,port:t,onlyClient:n});d.server=i,d.config=s};return d.reboot=e,v(),e()})),u.command(p.preview).description("Build and preview production.").addOption(w).addOption(O).addOption(y).action((async({host:o,port:n,onlyClient:e})=>{const s=async i=>{const{server:s,config:r}=await c({version:f,isHost:o,isPrintInfo:i,port:n,onlyClient:e});s.on("listening",(()=>{setTimeout((()=>{r.getLogger().info(t.yellow("\n Running preview mode... \n"))}),0)})),d.server=s,d.config=r};d.reboot=s,v();const r=i({isWatch:!0,isOnlyClient:e,clientOptions:"-w",serverOptions:"-w"});await Promise.all([s(),r])})),u.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/keyboard-input.js";import s from"./cli/run-dev.js";import d from"./cli/run-docker-build.js";import a 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:u,version:f}=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(u).version(f).hook("preAction",((o,e)=>{global.viteBoostAction=e.name()}));const w=new t("--host","Ability to access the local instance on other devices under the same network.").default(!1),k=new t("--only-client","Build/run only client side part.").default(!1),g=new t("--port [port]","Server port.").default(3e3),y=new t("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production");O.command(l.dev).description("Run development server.").addOption(w).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 c();const i=async n=>{console.info(e.cyan("Starting the development server..."));const{server:i,config:r}=await s({version:f,isHost:o,isPrintInfo:n,mode:t});p.server=i,p.config=r};return p.reboot=i,v(),i()})),O.command(l.build).description("Create production build.").addOption(k).addOption(y).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)).action((async({onlyClient:o,clientOptions:e,serverOptions:n,mode:t,unlockRobots:r,eject:s})=>{await i({isOnlyClient:o,isUnlockRobots:r,isEject:s,clientOptions:e,serverOptions:n,mode:t})})),O.command(l.start).description("Run production server.").addOption(w).addOption(g).addOption(k).action((({host:o,port:e,onlyClient:n})=>{const t=async t=>{const{server:i,config:r}=await a({version:f,isHost:o,isPrintInfo:t,port:e,onlyClient:n});p.server=i,p.config=r};return p.reboot=t,v(),t()})),O.command(l.preview).description("Build and preview production.").addOption(k).addOption(w).addOption(g).addOption(y).action((async({host:o,port:n,onlyClient:t,mode:r})=>{global.viteBoostStartTime=performance.now();const s=async i=>{const{server:r,config:s}=await a({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,v();await i({mode:r,isWatch:!0,isOnlyClient:t,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 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(k).addOption(y).action((async({imageName:o,dockerOptions:e,dockerFile:n,onlyClient:t,mode:i})=>{await d({imageName:o,dockerOptions:e,dockerFile:n,isOnlyClient:t,mode:i})})),O.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 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);\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 .action(async ({ host, resetCache }) => {\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 });\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(\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 .action(async ({ onlyClient, clientOptions, serverOptions }) => {\n await runBuild({ isOnlyClient: onlyClient, clientOptions, serverOptions });\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 .action(async ({ 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 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 const build = runBuild({\n isWatch: true,\n isOnlyClient: onlyClient,\n clientOptions: buildOptions,\n serverOptions: buildOptions,\n });\n\n await Promise.all([command(), build]);\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","command","CliActions","dev","addOption","action","async","host","resetCache","viteResetCache","isPrintInfo","server","config","runDev","isHost","cliContext","reboot","build","env","onlyClient","clientOptions","serverOptions","runBuild","isOnlyClient","start","port","runProd","preview","setTimeout","getLogger","info","chalk","yellow","isWatch","Promise","all"],"mappings":";iZAiBA,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,OAAQC,GAAYC,YAAY,QAAQC,SAC1D,EAGGC,EAAU,IAAIC,EAEpBD,EACGE,KAAKC,GACLnB,YAAYA,GACZC,QAAQA,GACRmB,KAAK,aAAa,CAACC,EAAGC,KAErBC,OAAOC,gBAAkBF,EAAcJ,MAAM,IAMjD,MAAMO,EAAa,IAAIC,EACrB,SACA,iFACAC,SAAQ,GACJC,EAAmB,IAAIF,EAAO,gBAAiB,oCAAoCC,SACvF,GAEIE,EAAa,IAAIH,EAAO,gBAAiB,gBAAgBC,QAAQ,KAMvEX,EACGc,QAAQC,EAAWC,KACnBhC,YAAY,2BACZiC,UAAUR,GACVQ,UAAU,IAAIP,EAAO,gBAAiB,gCAAgCC,SAAQ,IAC9EO,QAAOC,OAASC,OAAMC,iBACjBA,SACIC,IAGR,MAAMR,EAAUK,MAAOI,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBC,EAAO,CAAEzC,UAAS0C,OAAQP,EAAMG,gBAEjEK,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAASf,EAEpBvB,IAEOuB,GAAS,IAGpBd,EACGc,QAAQC,EAAWe,OACnB9C,YAAY,4BACZiC,UAAUL,GACVK,UACC,IAAIP,EACF,oCACA,iFAECqB,IAAI,6BACJpB,QAAQ,KAEZM,UACC,IAAIP,EAAO,oCAAqC,uCAC7CqB,IAAI,6BACJpB,QAAQ,KAEZO,QAAOC,OAASa,aAAYC,gBAAeC,0BACpCC,EAAS,CAAEC,aAAcJ,EAAYC,gBAAeC,iBAAgB,IAG9ElC,EACGc,QAAQC,EAAWsB,OACnBrD,YAAY,0BACZiC,UAAUR,GACVQ,UAAUJ,GACVI,UAAUL,GACVM,QAAO,EAAGE,OAAMkB,OAAMN,iBACrB,MAAMlB,EAAUK,MAAOI,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBc,EAAQ,CACvCtD,UACA0C,OAAQP,EACRG,cACAe,OACAN,eAGFJ,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAASf,EAEpBvB,IAEOuB,GAAS,IAGpBd,EACGc,QAAQC,EAAWyB,SACnBxD,YAAY,iCACZiC,UAAUL,GACVK,UAAUR,GACVQ,UAAUJ,GACVK,QAAOC,OAASC,OAAMkB,OAAMN,iBAC3B,MAAMlB,EAAUK,MAAOI,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBc,EAAQ,CACvCtD,UACA0C,OAAQP,EACRG,cACAe,OACAN,eAGFR,EAAO5B,GAAG,aAAa,KACrB6C,YAAW,KACThB,EAAOiB,YAAYC,KAAKC,EAAMC,OAAO,kCAAkC,GACtE,EAAE,IAGPjB,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAG5BG,EAAWC,OAASf,EAEpBvB,IAEA,MACMuC,EAAQK,EAAS,CACrBW,SAAS,EACTV,aAAcJ,EACdC,cAJmB,KAKnBC,cALmB,aAQfa,QAAQC,IAAI,CAAClC,IAAWgB,GAAO,IAGzC9B,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/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(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 .action(async ({ onlyClient, clientOptions, serverOptions, mode, unlockRobots, eject }) => {\n await runBuild({\n isOnlyClient: onlyClient,\n isUnlockRobots: unlockRobots,\n isEject: eject,\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","console","info","chalk","cyan","server","config","runDev","isHost","cliContext","reboot","build","onlyClient","clientOptions","serverOptions","unlockRobots","eject","runBuild","isOnlyClient","isUnlockRobots","isEject","start","port","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","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,OAAQC,GAAYC,YAAY,QAAQC,SAC1D,EAGGC,EAAU,IAAIC,EAEpBD,EACGE,KAAKC,GACLnB,YAAYA,GACZC,QAAQA,GACRmB,KAAK,aAAa,CAACC,EAAGC,KAErBC,OAAOC,gBAAkBF,EAAcJ,MAAM,IAMjD,MAAMO,EAAa,IAAIC,EACrB,SACA,iFACAC,SAAQ,GACJC,EAAmB,IAAIF,EAAO,gBAAiB,oCAAoCC,SACvF,GAEIE,EAAa,IAAIH,EAAO,gBAAiB,gBAAgBC,QAAQ,KACjEG,EAAgB,IAAIJ,EAAO,gBAAiB,aAC/CK,IAAI,iBACJJ,QAAQ,cAMXX,EACGgB,QAAQC,EAAWC,KACnBlC,YAAY,2BACZmC,UAAUV,GACVU,UAAU,IAAIT,EAAO,gBAAiB,gCAAgCC,SAAQ,IAC9EQ,UAAU,IAAIT,EAAO,gBAAiB,aAAaK,IAAI,iBAAiBJ,QAAQ,gBAChFS,QAAOC,OAASC,OAAMC,aAAYC,WAC7BD,SACIE,IAGR,MAAMT,EAAUK,MAAOK,IACrBC,QAAQC,KAAKC,EAAMC,KAAK,uCAExB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBC,EAAO,CAAEhD,UAASiD,OAAQZ,EAAMI,cAAaF,SAE9EW,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAASpB,EAEpBzB,IAEOyB,GAAS,IAGpBhB,EACGgB,QAAQC,EAAWoB,OACnBrD,YAAY,4BACZmC,UAAUP,GACVO,UAAUL,GACVK,UACC,IAAIT,EACF,oCACA,iFAECK,IAAI,6BACJJ,QAAQ,KAEZQ,UACC,IAAIT,EAAO,oCAAqC,uCAC7CK,IAAI,6BACJJ,QAAQ,KAEZQ,UACC,IAAIT,EACF,kBACA,4DACAC,SAAQ,IAEXQ,UACC,IAAIT,EAAO,UAAW,mDAAmDC,SAAQ,IAElFS,QAAOC,OAASiB,aAAYC,gBAAeC,gBAAehB,OAAMiB,eAAcC,kBACvEC,EAAS,CACbC,aAAcN,EACdO,eAAgBJ,EAChBK,QAASJ,EACTH,gBACAC,gBACAhB,QACA,IAGNxB,EACGgB,QAAQC,EAAW8B,OACnB/D,YAAY,0BACZmC,UAAUV,GACVU,UAAUN,GACVM,UAAUP,GACVQ,QAAO,EAAGE,OAAM0B,OAAMV,iBACrB,MAAMtB,EAAUK,MAAOK,IACrB,MAAMK,OAAEA,EAAMC,OAAEA,SAAiBiB,EAAQ,CACvChE,UACAiD,OAAQZ,EACRI,cACAsB,OACAV,eAGFH,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAASpB,EAEpBzB,IAEOyB,GAAS,IAGpBhB,EACGgB,QAAQC,EAAWiC,SACnBlE,YAAY,iCACZmC,UAAUP,GACVO,UAAUV,GACVU,UAAUN,GACVM,UAAUL,GACVM,QAAOC,OAASC,OAAM0B,OAAMV,aAAYd,WACvCjB,OAAO4C,mBAAqBC,YAAYC,MAExC,MAAMrC,EAAUK,MAAOK,IACrB,MAAMK,OAAEA,EAAMC,OAAEA,SAAiBiB,EAAQ,CACvChE,UACAiD,OAAQZ,EACRI,cACAsB,OACAV,eAGFP,EAAOnC,GAAG,aAAa,KACrB0D,YAAW,KACTtB,EAAOuB,YAAY3B,KAAKC,EAAM2B,OAAO,kCAAkC,GACtE,EAAE,IAGPrB,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAG5BG,EAAWC,OAASpB,EAEpBzB,UAIMoD,EAAS,CACbnB,OACAiC,SAAS,EACTb,aAAcN,EACdC,cANmB,KAOnBC,cAPmB,KAQnBkB,SAAU,KACH1C,GAAS,GAEhB,IAGNhB,EACGgB,QAAQC,EAAW0C,aACnB3E,YAAY,8CACZ4E,eAAe,4BAA6B,sBAC5CzC,UACC,IAAIT,EACF,oCACA,6DAGHS,UACC,IAAIT,EACF,8BACA,yEAGHS,UAAUP,GACVO,UAAUL,GACVM,QAAOC,OAASwC,YAAWC,gBAAeC,aAAYzB,aAAYd,iBAC3DwC,EAAe,CACnBH,YACAC,gBACAC,aACAnB,aAAcN,EACdd,QACA,IAGNxB,EAAQb"}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ /**
3
+ * Scroll page to top on every pathname (url) change
4
+ * @constructor
5
+ */
6
+ declare const ScrollToTop: FC;
7
+ export { ScrollToTop as default };
@@ -0,0 +1,2 @@
1
+ import{useEffect as o}from"react";import{useLocation as r}from"react-router-dom";const t=()=>{const{pathname:t}=r();return o((()=>{window.scrollTo(0,0)}),[t]),null};export{t 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 } from 'react';\nimport { useLocation } from 'react-router-dom';\n\n/**\n * Scroll page to top on every pathname (url) change\n * @constructor\n */\nconst ScrollToTop: FC = () => {\n const { pathname } = useLocation();\n\n useEffect(() => {\n window.scrollTo(0, 0);\n }, [pathname]);\n\n return null;\n};\n\nexport default ScrollToTop;\n"],"names":["ScrollToTop","pathname","useLocation","useEffect","window","scrollTo"],"mappings":"iFAQM,MAAAA,EAAkB,KACtB,MAAMC,SAAEA,GAAaC,IAMrB,OAJAC,GAAU,KACRC,OAAOC,SAAS,EAAG,EAAE,GACpB,CAACJ,IAEG,IAAI"}
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { FCAny, FCC } from "../interfaces/fc.js";
3
+ /**
4
+ * Wrap component in suspense
5
+ */
6
+ declare const withSuspense: <T extends Record<string, any>>(Component: FCAny<T>, Suspense: FCC<Record<string, any>>) => FC<T>;
7
+ export { withSuspense as default };
@@ -0,0 +1,2 @@
1
+ import t from"hoist-non-react-statics";import e from"react";const r=(r,o)=>{const n=t=>e.createElement(o,null,e.createElement(r,{...t}));return t(n,r),n};export{r as default};
2
+ //# sourceMappingURL=with-suspense.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-suspense.js","sources":["../../src/components/with-suspense.tsx"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport type { FC } from 'react';\nimport React from 'react';\nimport type { FCAny, FCC } from '@interfaces/fc';\n\n/**\n * Wrap component in suspense\n */\nconst withSuspense = <T extends Record<string, any>>(\n Component: FCAny<T>,\n Suspense: FCC<Record<string, any>>,\n): FC<T> => {\n const Element: FC<T> = (props) => (\n <Suspense>\n <Component {...props} />\n </Suspense>\n );\n\n hoistNonReactStatics(Element, Component);\n\n return Element;\n};\n\nexport default withSuspense;\n"],"names":["withSuspense","Component","Suspense","Element","props","React","createElement","hoistNonReactStatics"],"mappings":"4DAQA,MAAMA,EAAe,CACnBC,EACAC,KAEA,MAAMC,EAAkBC,GACtBC,EAAAC,cAACJ,EAAQ,KACPG,EAAAC,cAACL,EAAc,IAAAG,KAMnB,OAFAG,EAAqBJ,EAASF,GAEvBE,CAAO"}
@@ -1,6 +1,7 @@
1
1
  declare enum CliActions {
2
2
  dev = "dev",
3
3
  build = "build",
4
+ buildDocker = "build-docker",
4
5
  start = "start",
5
6
  preview = "preview"
6
7
  }
@@ -1,2 +1,2 @@
1
- var e;!function(e){e.dev="dev",e.build="build",e.start="start",e.preview="preview"}(e||(e={}));var r=e;export{r as default};
1
+ var e;!function(e){e.dev="dev",e.build="build",e.buildDocker="build-docker",e.start="start",e.preview="preview"}(e||(e={}));var r=e;export{r as default};
2
2
  //# sourceMappingURL=cli-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-actions.js","sources":["../../src/constants/cli-actions.ts"],"sourcesContent":["enum CliActions {\n dev = 'dev',\n build = 'build',\n start = 'start',\n preview = 'preview',\n}\n\nexport default CliActions;\n"],"names":["CliActions","CliActions$1"],"mappings":"AAAA,IAAKA,GAAL,SAAKA,GACHA,EAAA,IAAA,MACAA,EAAA,MAAA,QACAA,EAAA,MAAA,QACAA,EAAA,QAAA,SACD,CALD,CAAKA,IAAAA,EAKJ,CAAA,IAED,IAAAC,EAAeD"}
1
+ {"version":3,"file":"cli-actions.js","sources":["../../src/constants/cli-actions.ts"],"sourcesContent":["enum CliActions {\n dev = 'dev',\n build = 'build',\n buildDocker = 'build-docker',\n start = 'start',\n preview = 'preview',\n}\n\nexport default CliActions;\n"],"names":["CliActions","CliActions$1"],"mappings":"AAAA,IAAKA,GAAL,SAAKA,GACHA,EAAA,IAAA,MACAA,EAAA,MAAA,QACAA,EAAA,YAAA,eACAA,EAAA,MAAA,QACAA,EAAA,QAAA,SACD,CAND,CAAKA,IAAAA,EAMJ,CAAA,IAED,IAAAC,EAAeD"}
@@ -0,0 +1,9 @@
1
+ import { ResolvedConfig } from 'vite';
2
+ declare const markerFileName = "server/.dev";
3
+ /**
4
+ * Create dev marker
5
+ *
6
+ * @see printServerInfo
7
+ */
8
+ declare const createDevMarker: (isProd: boolean, { root, build: buildConf }: ResolvedConfig) => void;
9
+ export { createDevMarker, markerFileName };
@@ -0,0 +1,2 @@
1
+ import r from"node:fs";import e from"node:path";const o="server/.dev",t=(t,{root:i,build:s})=>{const n=e.resolve(i,s.outDir),c=`${n}/${o}`;t?r.existsSync(c)&&r.rmSync(c):(r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),r.writeFileSync(c,""))};export{t as createDevMarker,o as markerFileName};
2
+ //# sourceMappingURL=dev-marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-marker.js","sources":["../../src/helpers/dev-marker.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type { ResolvedConfig } from 'vite';\n\nconst markerFileName = 'server/.dev';\n\n/**\n * Create dev marker\n *\n * @see printServerInfo\n */\nconst createDevMarker = (isProd: boolean, { root, build: buildConf }: ResolvedConfig): void => {\n const devMarkerPath = path.resolve(root, buildConf.outDir);\n const devMarker = `${devMarkerPath}/${markerFileName}`;\n\n if (!isProd) {\n if (!fs.existsSync(devMarkerPath)) {\n fs.mkdirSync(devMarkerPath, { recursive: true });\n }\n\n fs.writeFileSync(devMarker, '');\n } else if (fs.existsSync(devMarker)) {\n fs.rmSync(devMarker);\n }\n};\n\nexport { createDevMarker, markerFileName };\n"],"names":["markerFileName","createDevMarker","isProd","root","build","buildConf","devMarkerPath","path","resolve","outDir","devMarker","fs","existsSync","rmSync","mkdirSync","recursive","writeFileSync"],"mappings":"gDAIM,MAAAA,EAAiB,cAOjBC,EAAkB,CAACC,GAAmBC,OAAMC,MAAOC,MACvD,MAAMC,EAAgBC,EAAKC,QAAQL,EAAME,EAAUI,QAC7CC,EAAY,GAAGJ,KAAiBN,IAEjCE,EAMMS,EAAGC,WAAWF,IACvBC,EAAGE,OAAOH,IANLC,EAAGC,WAAWN,IACjBK,EAAGG,UAAUR,EAAe,CAAES,WAAW,IAG3CJ,EAAGK,cAAcN,EAAW,IAG7B"}
@@ -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"}