@lomray/vite-ssr-boost 7.1.0 → 8.0.0-beta.2

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 (248) hide show
  1. package/README.md +18 -1
  2. package/adapters/body.d.ts +5 -0
  3. package/adapters/body.js +2 -0
  4. package/adapters/body.js.map +1 -0
  5. package/adapters/compression.d.ts +11 -0
  6. package/adapters/compression.js +2 -0
  7. package/adapters/compression.js.map +1 -0
  8. package/adapters/edge.d.ts +11 -0
  9. package/adapters/edge.js +2 -0
  10. package/adapters/edge.js.map +1 -0
  11. package/adapters/express/create-request.d.ts +11 -0
  12. package/adapters/express/create-request.js +2 -0
  13. package/adapters/express/create-request.js.map +1 -0
  14. package/adapters/express/entry.d.ts +55 -0
  15. package/adapters/express/entry.js.map +1 -0
  16. package/{services → adapters/express}/prepare-server.d.ts +15 -40
  17. package/adapters/express/prepare-server.js +2 -0
  18. package/adapters/express/prepare-server.js.map +1 -0
  19. package/adapters/express/render.d.ts +63 -0
  20. package/adapters/express/render.js +2 -0
  21. package/adapters/express/render.js.map +1 -0
  22. package/adapters/express/server.d.ts +15 -0
  23. package/adapters/express/server.js +2 -0
  24. package/adapters/express/server.js.map +1 -0
  25. package/adapters/express.d.ts +11 -0
  26. package/adapters/express.js +2 -0
  27. package/adapters/express.js.map +1 -0
  28. package/adapters/fastify.d.ts +23 -0
  29. package/adapters/fastify.js +2 -0
  30. package/adapters/fastify.js.map +1 -0
  31. package/adapters/hono.d.ts +13 -0
  32. package/adapters/hono.js +2 -0
  33. package/adapters/hono.js.map +1 -0
  34. package/adapters/node.d.ts +19 -0
  35. package/adapters/node.js +2 -0
  36. package/adapters/node.js.map +1 -0
  37. package/browser/entry.d.ts +9 -9
  38. package/browser/entry.js +1 -1
  39. package/browser/entry.js.map +1 -1
  40. package/cli/build.d.ts +2 -2
  41. package/cli/build.js.map +1 -1
  42. package/cli/helpers/keyboard-input.d.ts +1 -1
  43. package/cli/helpers/keyboard-input.js +1 -1
  44. package/cli/helpers/keyboard-input.js.map +1 -1
  45. package/cli/helpers/vite-reset-cache.d.ts +1 -1
  46. package/cli/helpers/vite-reset-cache.js.map +1 -1
  47. package/cli/interfaces/actions.d.ts +8 -9
  48. package/cli/run-amplify-build.d.ts +1 -1
  49. package/cli/run-amplify-build.js.map +1 -1
  50. package/cli/run-dev.d.ts +3 -4
  51. package/cli/run-dev.js +1 -1
  52. package/cli/run-dev.js.map +1 -1
  53. package/cli/run-docker-build.d.ts +2 -2
  54. package/cli/run-docker-build.js.map +1 -1
  55. package/cli/run-prod.d.ts +5 -6
  56. package/cli/run-prod.js +1 -1
  57. package/cli/run-prod.js.map +1 -1
  58. package/cli/run-serverless.d.ts +3 -3
  59. package/cli/run-serverless.js +1 -1
  60. package/cli/run-serverless.js.map +1 -1
  61. package/cli/run-vercel-build.d.ts +1 -1
  62. package/cli/run-vercel-build.js.map +1 -1
  63. package/cli.js +1 -1
  64. package/cli.js.map +1 -1
  65. package/components/navigate.d.ts +3 -3
  66. package/components/navigate.js.map +1 -1
  67. package/components/only-client.d.ts +2 -2
  68. package/components/only-client.js +1 -1
  69. package/components/only-client.js.map +1 -1
  70. package/components/render-client.d.ts +4 -4
  71. package/components/render-client.js +1 -1
  72. package/components/render-client.js.map +1 -1
  73. package/components/response-status.d.ts +2 -2
  74. package/components/response-status.js +1 -1
  75. package/components/response-status.js.map +1 -1
  76. package/components/scroll-to-top.d.ts +2 -2
  77. package/components/scroll-to-top.js +1 -1
  78. package/components/scroll-to-top.js.map +1 -1
  79. package/components/with-suspense.d.ts +3 -3
  80. package/components/with-suspense.js.map +1 -1
  81. package/constants/cli-actions.d.ts +1 -1
  82. package/constants/cli-actions.js.map +1 -1
  83. package/constants/cli-context.d.ts +4 -5
  84. package/constants/cli-context.js.map +1 -1
  85. package/constants/cli-name.d.ts +1 -1
  86. package/constants/cli-name.js.map +1 -1
  87. package/constants/cli-shortcuts.d.ts +2 -2
  88. package/constants/cli-shortcuts.js +1 -1
  89. package/constants/cli-shortcuts.js.map +1 -1
  90. package/constants/common.js.map +1 -1
  91. package/constants/plugin-name.d.ts +1 -1
  92. package/constants/plugin-name.js.map +1 -1
  93. package/constants/stream-error.d.ts +1 -1
  94. package/constants/stream-error.js.map +1 -1
  95. package/context/server.d.ts +3 -4
  96. package/context/server.js.map +1 -1
  97. package/core/compose-html.d.ts +5 -0
  98. package/core/compose-html.js +2 -0
  99. package/core/compose-html.js.map +1 -0
  100. package/core/early-hints.d.ts +6 -0
  101. package/core/early-hints.js +2 -0
  102. package/core/early-hints.js.map +1 -0
  103. package/core/handler.d.ts +30 -0
  104. package/core/handler.js +2 -0
  105. package/core/handler.js.map +1 -0
  106. package/core/head-response.d.ts +5 -0
  107. package/core/head-response.js +2 -0
  108. package/core/head-response.js.map +1 -0
  109. package/core/headers.d.ts +12 -0
  110. package/core/headers.js +2 -0
  111. package/core/headers.js.map +1 -0
  112. package/core/render.d.ts +101 -0
  113. package/core/render.js +2 -0
  114. package/core/render.js.map +1 -0
  115. package/core/transform-html.d.ts +7 -0
  116. package/core/transform-html.js +2 -0
  117. package/core/transform-html.js.map +1 -0
  118. package/core/types.d.ts +7 -0
  119. package/core/types.js +2 -0
  120. package/core/types.js.map +1 -0
  121. package/edge/render-to-stream.d.ts +6 -0
  122. package/edge/render-to-stream.js +2 -0
  123. package/edge/render-to-stream.js.map +1 -0
  124. package/helpers/build-custom-state.d.ts +2 -3
  125. package/helpers/build-custom-state.js +1 -1
  126. package/helpers/build-custom-state.js.map +1 -1
  127. package/helpers/build-router-state.d.ts +2 -2
  128. package/helpers/build-router-state.js.map +1 -1
  129. package/helpers/create-focus-only.d.ts +3 -3
  130. package/helpers/create-focus-only.js.map +1 -1
  131. package/helpers/dev-marker.d.ts +1 -1
  132. package/helpers/dev-marker.js.map +1 -1
  133. package/helpers/get-server-state.d.ts +1 -1
  134. package/helpers/get-server-state.js.map +1 -1
  135. package/helpers/html-escape.d.ts +1 -1
  136. package/helpers/html-escape.js +1 -1
  137. package/helpers/html-escape.js.map +1 -1
  138. package/helpers/import-route.d.ts +7 -7
  139. package/helpers/import-route.js +1 -1
  140. package/helpers/import-route.js.map +1 -1
  141. package/helpers/is-route-file.d.ts +1 -1
  142. package/helpers/is-route-file.js.map +1 -1
  143. package/helpers/obtain-stream-error.d.ts +3 -3
  144. package/helpers/obtain-stream-error.js +1 -1
  145. package/helpers/obtain-stream-error.js.map +1 -1
  146. package/helpers/plugin-config.d.ts +5 -5
  147. package/helpers/plugin-config.js +1 -1
  148. package/helpers/plugin-config.js.map +1 -1
  149. package/helpers/print-server-info.d.ts +3 -4
  150. package/helpers/print-server-info.js +1 -1
  151. package/helpers/print-server-info.js.map +1 -1
  152. package/helpers/print-server-urls.d.ts +2 -2
  153. package/helpers/print-server-urls.js +1 -1
  154. package/helpers/print-server-urls.js.map +1 -1
  155. package/helpers/process-stop.d.ts +1 -1
  156. package/helpers/process-stop.js.map +1 -1
  157. package/helpers/resolve-server-urls.d.ts +3 -4
  158. package/helpers/resolve-server-urls.js +1 -1
  159. package/helpers/resolve-server-urls.js.map +1 -1
  160. package/helpers/serialize-errors.d.ts +2 -2
  161. package/helpers/serialize-errors.js.map +1 -1
  162. package/helpers/vite-aliases.d.ts +2 -2
  163. package/helpers/vite-aliases.js +1 -1
  164. package/helpers/vite-aliases.js.map +1 -1
  165. package/interfaces/fc-route.d.ts +4 -4
  166. package/interfaces/fc-route.js.map +1 -1
  167. package/interfaces/fc.d.ts +3 -4
  168. package/interfaces/route-object.d.ts +6 -6
  169. package/node/compress-response.d.ts +6 -0
  170. package/node/compress-response.js +2 -0
  171. package/node/compress-response.js.map +1 -0
  172. package/node/create-headers.d.ts +6 -0
  173. package/node/create-headers.js +2 -0
  174. package/node/create-headers.js.map +1 -0
  175. package/node/create-request.d.ts +13 -0
  176. package/node/create-request.js +2 -0
  177. package/node/create-request.js.map +1 -0
  178. package/node/http.d.ts +4 -0
  179. package/node/http.js +2 -0
  180. package/node/http.js.map +1 -0
  181. package/node/render-to-stream.d.ts +6 -0
  182. package/node/render-to-stream.js +2 -0
  183. package/node/render-to-stream.js.map +1 -0
  184. package/node/request-signal.d.ts +10 -0
  185. package/node/request-signal.js +2 -0
  186. package/node/request-signal.js.map +1 -0
  187. package/node/split-link-header.d.ts +5 -0
  188. package/node/split-link-header.js +2 -0
  189. package/node/split-link-header.js.map +1 -0
  190. package/node/write-early-hints.d.ts +6 -0
  191. package/node/write-early-hints.js +2 -0
  192. package/node/write-early-hints.js.map +1 -0
  193. package/node/write-fetch-response.d.ts +11 -0
  194. package/node/write-fetch-response.js +2 -0
  195. package/node/write-fetch-response.js.map +1 -0
  196. package/package.json +89 -27
  197. package/plugin.d.ts +7 -7
  198. package/plugin.js.map +1 -1
  199. package/plugins/create-spa-index.d.ts +3 -3
  200. package/plugins/create-spa-index.js.map +1 -1
  201. package/plugins/handle-custom-entrypoint.d.ts +4 -4
  202. package/plugins/handle-custom-entrypoint.js +1 -1
  203. package/plugins/handle-custom-entrypoint.js.map +1 -1
  204. package/plugins/make-aliases.d.ts +3 -3
  205. package/plugins/make-aliases.js +1 -1
  206. package/plugins/make-aliases.js.map +1 -1
  207. package/plugins/normalize-route.d.ts +3 -3
  208. package/plugins/normalize-route.js.map +1 -1
  209. package/services/build.d.ts +5 -51
  210. package/services/build.js +1 -1
  211. package/services/build.js.map +1 -1
  212. package/services/logger.d.ts +2 -30
  213. package/services/logger.js.map +1 -1
  214. package/services/parse-routes.d.ts +5 -42
  215. package/services/parse-routes.js +1 -1
  216. package/services/parse-routes.js.map +1 -1
  217. package/services/path-normalize.d.ts +3 -18
  218. package/services/path-normalize.js +1 -1
  219. package/services/path-normalize.js.map +1 -1
  220. package/services/server-api.d.ts +1 -7
  221. package/services/server-api.js.map +1 -1
  222. package/services/server-config.d.ts +7 -52
  223. package/services/server-config.js +1 -1
  224. package/services/server-config.js.map +1 -1
  225. package/services/ssr-manifest.d.ts +20 -60
  226. package/services/ssr-manifest.js +1 -1
  227. package/services/ssr-manifest.js.map +1 -1
  228. package/workflow/Dockerfile +1 -1
  229. package/helpers/handle-response.d.ts +0 -7
  230. package/helpers/handle-response.js +0 -2
  231. package/helpers/handle-response.js.map +0 -1
  232. package/node/create-fetch-request.d.ts +0 -7
  233. package/node/create-fetch-request.js +0 -2
  234. package/node/create-fetch-request.js.map +0 -1
  235. package/node/entry.d.ts +0 -63
  236. package/node/entry.js.map +0 -1
  237. package/node/render.d.ts +0 -64
  238. package/node/render.js +0 -2
  239. package/node/render.js.map +0 -1
  240. package/node/server.d.ts +0 -16
  241. package/node/server.js +0 -2
  242. package/node/server.js.map +0 -1
  243. package/node/write-response.d.ts +0 -14
  244. package/node/write-response.js +0 -2
  245. package/node/write-response.js.map +0 -1
  246. package/services/prepare-server.js +0 -2
  247. package/services/prepare-server.js.map +0 -1
  248. /package/{node → adapters/express}/entry.js +0 -0
package/package.json CHANGED
@@ -1,8 +1,24 @@
1
1
  {
2
2
  "name": "@lomray/vite-ssr-boost",
3
- "version": "7.1.0",
3
+ "version": "8.0.0-beta.2",
4
4
  "description": "Vite plugin for create awesome SSR or SPA applications on React.",
5
5
  "type": "module",
6
+ "exports": {
7
+ "./*.js": {
8
+ "types": "./*.d.ts",
9
+ "default": "./*.js"
10
+ },
11
+ "./*.d.ts": "./*.d.ts",
12
+ "./*.map": "./*.map",
13
+ "./*.json": "./*.json",
14
+ "./*.md": "./*.md",
15
+ "./LICENSE": "./LICENSE",
16
+ "./workflow/*": "./workflow/*",
17
+ "./*": {
18
+ "types": "./*.d.ts",
19
+ "default": "./*.js"
20
+ }
21
+ },
6
22
  "keywords": [
7
23
  "js",
8
24
  "vite",
@@ -34,66 +50,112 @@
34
50
  "lint:format": "eslint . --fix",
35
51
  "ts:check": "tsc --project ./tsconfig.json --skipLibCheck --noemit",
36
52
  "test": "vitest run",
53
+ "test:core:no-optional": "node scripts/test-core-no-optional.mjs",
54
+ "test:edge:packed": "node scripts/test-packed-edge.mjs",
55
+ "test:bun": "bun scripts/test-bun.mjs",
56
+ "test:template": "npm run build && node scripts/test-template.mjs",
37
57
  "test:coverage": "vitest run --coverage"
38
58
  },
39
59
  "dependencies": {
40
- "chalk": "^5.6.2",
41
- "commander": "^14.0.3",
42
- "compression": "^1.8.1",
43
- "express": "^5.2.1",
60
+ "chalk": "^6.0.0",
61
+ "commander": "^15.0.0",
44
62
  "hoist-non-react-statics": "^3.3.2",
45
63
  "json5": "^2.2.3"
46
64
  },
65
+ "optionalDependencies": {
66
+ "compression": "^1.8.1",
67
+ "express": "^5.2.1"
68
+ },
47
69
  "devDependencies": {
48
- "@commitlint/cli": "^20.5.0",
49
- "@commitlint/config-conventional": "^20.5.0",
50
- "@lomray/eslint-config-react": "^6.0.3",
51
- "@lomray/prettier-config": "^2.1.0",
70
+ "@babel/generator": "^8.0.0",
71
+ "@babel/parser": "^8.0.4",
72
+ "@babel/traverse": "^8.0.4",
73
+ "@babel/types": "^8.0.4",
74
+ "@commitlint/cli": "^21.2.2",
75
+ "@commitlint/config-conventional": "^21.2.2",
76
+ "@lomray/eslint-config": "^7.0.0",
77
+ "@lomray/eslint-config-react": "^7.0.0",
78
+ "@lomray/prettier-config": "^3.0.0",
52
79
  "@rollup/plugin-terser": "^1.0.0",
53
- "@testing-library/react": "^16.3.2",
80
+ "@rollup/plugin-typescript": "^12.3.0",
81
+ "@testing-library/react": "^16.3.3",
54
82
  "@types/babel__generator": "^7.27.0",
55
83
  "@types/babel__traverse": "^7.28.0",
56
84
  "@types/compression": "^1.8.1",
85
+ "@types/express": "^5.0.6",
57
86
  "@types/hoist-non-react-statics": "^3.3.7",
58
- "@types/react-dom": "^19.2.3",
59
- "@types/sinon": "^21.0.0",
60
- "@vitest/coverage-v8": "^4.1.0",
61
- "@zerollup/ts-transform-paths": "^1.7.18",
62
- "eslint": "^9.39.4",
87
+ "@types/node": "^22.20.1",
88
+ "@types/react": "^19.2.18",
89
+ "@types/react-dom": "^19.2.7",
90
+ "@types/serve-static": "^2.2.0",
91
+ "@types/sinon": "^22.0.0",
92
+ "@vitest/coverage-v8": "^5.0.0",
93
+ "conventional-changelog-conventionalcommits": "^9.3.1",
94
+ "esbuild": "^0.28.2",
95
+ "eslint": "^10.10.0",
96
+ "fastify": "^5.12.3",
97
+ "globals": "^17.12.0",
98
+ "hono": "^4.13.7",
63
99
  "husky": "^9.1.7",
64
- "jsdom": "^29.0.1",
65
- "lint-staged": "^16.4.0",
66
- "prettier": "^3.8.1",
67
- "rollup": "^4.59.1",
100
+ "jsdom": "^30.0.1",
101
+ "lint-staged": "^17.4.1",
102
+ "miniflare": "^4.20260730.0",
103
+ "prettier": "^3.9.6",
104
+ "react": "^19.2.8",
105
+ "react-dom": "^19.2.8",
106
+ "react-router": "^8.3.1",
107
+ "rollup": "^4.63.1",
68
108
  "rollup-plugin-copy": "^3.5.0",
69
109
  "rollup-plugin-folder-input": "^1.0.1",
70
110
  "rollup-plugin-peer-deps-external": "^2.2.4",
71
111
  "rollup-plugin-preserve-shebangs": "^0.2.0",
72
- "rollup-plugin-ts": "^3.4.5",
73
- "semantic-release": "^25.0.3",
74
- "sinon": "^21.0.3",
75
- "typescript": "^5.3.3",
112
+ "semantic-release": "^25.0.9",
113
+ "sinon": "^22.1.0",
114
+ "tsc-alias": "^1.9.4",
115
+ "typescript": "^6.0.3",
116
+ "typescript-eslint": "^8.69.0",
117
+ "vite": "^8.2.2",
76
118
  "vitepress": "^1.6.4",
77
- "vitest": "^4.1.0"
119
+ "vitest": "^5.0.0"
78
120
  },
79
121
  "peerDependencies": {
80
122
  "@babel/generator": ">=7.23.0",
81
123
  "@babel/parser": ">=7.23.0",
82
124
  "@babel/traverse": ">=7.23.0",
125
+ "@babel/types": ">=7.23.0",
126
+ "@types/compression": ">=1.7.5",
83
127
  "@types/express": ">=4.17.21",
128
+ "@types/serve-static": ">=1.15.5",
129
+ "react": ">=18.2.0",
84
130
  "react-dom": ">=18.2.0",
85
131
  "react-router": ">=7.0.1",
86
132
  "vite": ">=5"
87
133
  },
134
+ "peerDependenciesMeta": {
135
+ "@types/compression": {
136
+ "optional": true
137
+ },
138
+ "@types/express": {
139
+ "optional": true
140
+ },
141
+ "@types/serve-static": {
142
+ "optional": true
143
+ }
144
+ },
88
145
  "overrides": {
89
- "rollup-plugin-ts": {
90
- "browserslist-generator": "^3.0.0"
146
+ "miniflare": {
147
+ "undici": "^7.29.0"
148
+ },
149
+ "vitepress": {
150
+ "vite": "^6.4.3",
151
+ "@docsearch/js": "^3.9.0",
152
+ "@docsearch/css": "^3.9.0"
91
153
  }
92
154
  },
93
155
  "bin": {
94
156
  "ssr-boost": "cli.js"
95
157
  },
96
158
  "engines": {
97
- "node": ">=22.0.0"
159
+ "node": ">=22.12.0"
98
160
  }
99
161
  }
package/plugin.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { Plugin } from 'vite';
2
- import { ICliContext } from "./constants/cli-context.js";
3
- import { IPluginOptions as ICreateSPAIndex } from "./plugins/create-spa-index.js";
4
- import { IPluginOptions as IMakeAliasesPluginOptions } from "./plugins/make-aliases.js";
5
- import { IBuildEntrypoint } from "./services/build.js";
6
- interface IPluginOptions {
1
+ import type { Plugin } from 'vite';
2
+ import type { ICliContext } from './constants/cli-context.js';
3
+ import type { IPluginOptions as ICreateSPAIndex } from './plugins/create-spa-index.js';
4
+ import type { IPluginOptions as IMakeAliasesPluginOptions } from './plugins/make-aliases.js';
5
+ import type { IBuildEntrypoint } from './services/build.js';
6
+ export interface IPluginOptions {
7
7
  indexFile?: string;
8
8
  serverFile?: string;
9
9
  clientFile?: string;
@@ -23,4 +23,4 @@ interface IPluginOptions {
23
23
  * @constructor
24
24
  */
25
25
  declare function ViteSsrBoostPlugin(options?: IPluginOptions): Plugin[];
26
- export { ViteSsrBoostPlugin as default, IPluginOptions };
26
+ export default ViteSsrBoostPlugin;
package/plugin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path';\nimport process from 'node:process';\nimport type { Plugin } from 'vite';\nimport CliActions from '@constants/cli-actions';\nimport type { ICliContext } from '@constants/cli-context';\nimport PLUGIN_NAME from '@constants/plugin-name';\nimport ViteCreateSPAIndexPlugin from '@plugins/create-spa-index';\nimport type { IPluginOptions as ICreateSPAIndex } from '@plugins/create-spa-index';\nimport {\n ViteHandleCustomEntrypointPlugin,\n getCurrentEntrypoint,\n} from '@plugins/handle-custom-entrypoint';\nimport type { IPluginOptions as IMakeAliasesPluginOptions } from '@plugins/make-aliases';\nimport ViteMakeAliasesPlugin from '@plugins/make-aliases';\nimport ViteNormalizeRouterPlugin from '@plugins/normalize-route';\nimport type { IBuildEntrypoint } from '@services/build';\n\nexport interface IPluginOptions {\n // default: index.html\n indexFile?: string;\n // default: server.ts\n serverFile?: string;\n // default: client.ts\n clientFile?: string;\n // Path contains routes declaration files (need to detect route files). default: undefined, e.g.: /routes/\n routesPath?: string;\n // Create additional SPA entrypoint: index-spa.html\n // Can be used for service worker: createHandlerBoundToURL(\"index-spa.html\")\n spaIndex?: boolean | ICreateSPAIndex;\n // Read aliases from tsconfig\n tsconfigAliases?: boolean | IMakeAliasesPluginOptions;\n customShortcuts?: {\n key: string;\n description: string;\n action: (cliContext: ICliContext) => Promise<void> | void;\n isOnlyDev?: boolean;\n }[];\n // Additional entry points for build\n entrypoint?: IBuildEntrypoint[];\n}\n\nconst defaultOptions: IPluginOptions = {\n indexFile: 'index.html',\n serverFile: 'server.ts',\n clientFile: 'client.ts',\n tsconfigAliases: true,\n spaIndex: false,\n};\n\n/**\n * Init plugin\n * @constructor\n */\nfunction ViteSsrBoostPlugin(options: IPluginOptions = {}): Plugin[] {\n const dirInfo = new URL(import.meta.url);\n const action = (global.viteBoostAction || process.env.SSR_BOOST_ACTION) as CliActions;\n const mergedOptions: IPluginOptions = { ...defaultOptions, ...options };\n const entrypointConfig = getCurrentEntrypoint(mergedOptions.entrypoint ?? []);\n const isSSR = process.env.SSR_BOOST_IS_SSR === '1' || action === CliActions.dev;\n const isBuild = action === CliActions.build;\n\n const plugins: Plugin[] = [\n {\n name: PLUGIN_NAME,\n enforce: 'pre',\n // @ts-ignore save custom options\n pluginOptions: {\n ...mergedOptions,\n pluginPath: path.dirname(dirInfo.pathname),\n action,\n isDev: action === CliActions.dev,\n },\n\n config(config, { isSsrBuild }) {\n config.define = {\n ...(config.define ?? {}),\n __IS_SSR__: entrypointConfig ? entrypointConfig.type === 'ssr' : isSSR,\n };\n\n config.build = {\n ...(config.build ?? {}),\n };\n\n if (!isSsrBuild) {\n if (isSSR && isBuild) {\n config.build.manifest = true;\n }\n\n return config;\n }\n\n return {\n ...config,\n ...(isBuild ? { appType: 'custom' } : {}),\n publicDir: false,\n };\n },\n },\n ];\n\n const { tsconfigAliases, routesPath, spaIndex } = mergedOptions;\n\n if (tsconfigAliases) {\n plugins.push(\n ViteMakeAliasesPlugin(typeof tsconfigAliases === 'boolean' ? undefined : tsconfigAliases),\n );\n }\n\n if (spaIndex) {\n plugins.push(ViteCreateSPAIndexPlugin(typeof spaIndex === 'boolean' ? undefined : spaIndex));\n }\n\n if (entrypointConfig) {\n plugins.push(ViteHandleCustomEntrypointPlugin({ entrypoint: entrypointConfig }));\n }\n\n plugins.push(ViteNormalizeRouterPlugin({ isSSR, isBuild, routesPath }));\n\n return plugins;\n}\n\nexport default ViteSsrBoostPlugin;\n"],"names":["defaultOptions","indexFile","serverFile","clientFile","tsconfigAliases","spaIndex","ViteSsrBoostPlugin","options","dirInfo","URL","url","action","global","viteBoostAction","process","env","SSR_BOOST_ACTION","mergedOptions","entrypointConfig","getCurrentEntrypoint","entrypoint","isSSR","SSR_BOOST_IS_SSR","CliActions","dev","isBuild","build","plugins","name","PLUGIN_NAME","enforce","pluginOptions","pluginPath","path","dirname","pathname","isDev","config","isSsrBuild","define","__IS_SSR__","type","appType","publicDir","manifest","routesPath","push","ViteMakeAliasesPlugin","undefined","ViteCreateSPAIndexPlugin","ViteHandleCustomEntrypointPlugin","ViteNormalizeRouterPlugin"],"mappings":"8XAyCA,MAAMA,EAAiC,CACrCC,UAAW,aACXC,WAAY,YACZC,WAAY,YACZC,iBAAiB,EACjBC,UAAU,GAOZ,SAASC,EAAmBC,EAA0B,IACpD,MAAMC,EAAU,IAAIC,gBAAgBC,KAC9BC,EAAUC,OAAOC,iBAAmBC,EAAQC,IAAIC,iBAChDC,EAAgC,IAAKjB,KAAmBO,GACxDW,EAAmBC,EAAqBF,EAAcG,YAAc,IACpEC,EAAyC,MAAjCP,EAAQC,IAAIO,kBAA4BX,IAAWY,EAAWC,IACtEC,EAAUd,IAAWY,EAAWG,MAEhCC,EAAoB,CACxB,CACEC,KAAMC,EACNC,QAAS,MAETC,cAAe,IACVd,EACHe,WAAYC,EAAKC,QAAQ1B,EAAQ2B,UACjCxB,SACAyB,MAAOzB,IAAWY,EAAWC,KAG/Ba,OAAM,CAACA,GAAQC,WAAEA,MACfD,EAAOE,OAAS,IACVF,EAAOE,QAAU,GACrBC,WAAYtB,EAA6C,QAA1BA,EAAiBuB,KAAiBpB,GAGnEgB,EAAOX,MAAQ,IACTW,EAAOX,OAAS,IAGjBY,EAQE,IACFD,KACCZ,EAAU,CAAEiB,QAAS,UAAa,CAAA,EACtCC,WAAW,IAVPtB,GAASI,IACXY,EAAOX,MAAMkB,UAAW,GAGnBP,OAYTjC,gBAAEA,EAAeyC,WAAEA,EAAUxC,SAAEA,GAAaY,EAkBlD,OAhBIb,GACFuB,EAAQmB,KACNC,EAAiD,kBAApB3C,OAAgC4C,EAAY5C,IAIzEC,GACFsB,EAAQmB,KAAKG,EAA6C,kBAAb5C,OAAyB2C,EAAY3C,IAGhFa,GACFS,EAAQmB,KAAKI,EAAiC,CAAE9B,WAAYF,KAG9DS,EAAQmB,KAAKK,EAA0B,CAAE9B,QAAOI,UAASoB,gBAElDlB,CACT"}
1
+ {"version":3,"file":"plugin.js","sources":["../src/plugin.ts"],"sourcesContent":[null],"names":["defaultOptions","indexFile","serverFile","clientFile","tsconfigAliases","spaIndex","ViteSsrBoostPlugin","options","dirInfo","URL","url","action","global","viteBoostAction","process","env","SSR_BOOST_ACTION","mergedOptions","entrypointConfig","getCurrentEntrypoint","entrypoint","isSSR","SSR_BOOST_IS_SSR","CliActions","dev","isBuild","build","plugins","name","PLUGIN_NAME","enforce","pluginOptions","pluginPath","path","dirname","pathname","isDev","config","isSsrBuild","define","__IS_SSR__","type","appType","publicDir","manifest","routesPath","push","ViteMakeAliasesPlugin","undefined","ViteCreateSPAIndexPlugin","ViteHandleCustomEntrypointPlugin","ViteNormalizeRouterPlugin"],"mappings":"8XAyCA,MAAMA,EAAiC,CACrCC,UAAW,aACXC,WAAY,YACZC,WAAY,YACZC,iBAAiB,EACjBC,UAAU,GAOZ,SAASC,EAAmBC,EAA0B,IACpD,MAAMC,EAAU,IAAIC,gBAAgBC,KAC9BC,EAAUC,OAAOC,iBAAmBC,EAAQC,IAAIC,iBAChDC,EAAgC,IAAKjB,KAAmBO,GACxDW,EAAmBC,EAAqBF,EAAcG,YAAc,IACpEC,EAAyC,MAAjCP,EAAQC,IAAIO,kBAA4BX,IAAWY,EAAWC,IACtEC,EAAUd,IAAWY,EAAWG,MAEhCC,EAAoB,CACxB,CACEC,KAAMC,EACNC,QAAS,MAETC,cAAe,IACVd,EACHe,WAAYC,EAAKC,QAAQ1B,EAAQ2B,UACjCxB,SACAyB,MAAOzB,IAAWY,EAAWC,KAG/Ba,OAAM,CAACA,GAAQC,WAAEA,MACfD,EAAOE,OAAS,IACVF,EAAOE,QAAU,GACrBC,WAAYtB,EAA6C,QAA1BA,EAAiBuB,KAAiBpB,GAGnEgB,EAAOX,MAAQ,IACTW,EAAOX,OAAS,IAGjBY,EAQE,IACFD,KACCZ,EAAU,CAAEiB,QAAS,UAAa,CAAA,EACtCC,WAAW,IAVPtB,GAASI,IACXY,EAAOX,MAAMkB,UAAW,GAGnBP,OAYTjC,gBAAEA,EAAeyC,WAAEA,EAAUxC,SAAEA,GAAaY,EAkBlD,OAhBIb,GACFuB,EAAQmB,KACNC,EAAiD,kBAApB3C,OAAgC4C,EAAY5C,IAIzEC,GACFsB,EAAQmB,KAAKG,EAA6C,kBAAb5C,OAAyB2C,EAAY3C,IAGhFa,GACFS,EAAQmB,KAAKI,EAAiC,CAAE9B,WAAYF,KAG9DS,EAAQmB,KAAKK,EAA0B,CAAE9B,QAAOI,UAASoB,gBAElDlB,CACT"}
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'vite';
2
- interface IPluginOptions {
1
+ import type { Plugin } from 'vite';
2
+ export interface IPluginOptions {
3
3
  filename?: string;
4
4
  rootId?: string;
5
5
  }
@@ -11,4 +11,4 @@ interface IPluginOptions {
11
11
  * @constructor
12
12
  */
13
13
  declare function ViteCreateSPAIndexPlugin(options?: IPluginOptions): Plugin;
14
- export { ViteCreateSPAIndexPlugin as default, IPluginOptions };
14
+ export default ViteCreateSPAIndexPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"create-spa-index.js","sources":["../../src/plugins/create-spa-index.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport PLUGIN_NAME from '@constants/plugin-name';\nimport { getCurrentEntrypointName } from '@plugins/handle-custom-entrypoint';\n\nexport interface IPluginOptions {\n filename?: string;\n rootId?: string;\n}\n\nconst pluginName = `${PLUGIN_NAME}-create-spa-entrypoint`;\n\n/**\n * Create additional entrypoint for SPA.\n * File: index-spa.html\n *\n * E.g. for service worker entrypoint\n * @constructor\n */\nfunction ViteCreateSPAIndexPlugin(options: IPluginOptions = {}): Plugin {\n const { filename = 'index-spa.html', rootId = 'root' } = options;\n let spaHtml = '';\n\n return {\n name: pluginName,\n enforce: 'post',\n /**\n * Apply only on build but not for SSR\n */\n apply(_, { command, isSsrBuild }): boolean {\n return command === 'build' && !isSsrBuild && !getCurrentEntrypointName();\n },\n transformIndexHtml(html): string {\n spaHtml = html.replace(`id=\"${rootId}\"`, `id=\"${rootId}\" data-force-spa=\"1\"`);\n\n return html;\n },\n generateBundle(): void {\n if (!spaHtml) {\n return;\n }\n\n this.emitFile({\n type: 'asset',\n fileName: filename,\n source: spaHtml,\n });\n },\n };\n}\n\nexport default ViteCreateSPAIndexPlugin;\n"],"names":["pluginName","PLUGIN_NAME","ViteCreateSPAIndexPlugin","options","filename","rootId","spaHtml","name","enforce","apply","_","command","isSsrBuild","getCurrentEntrypointName","transformIndexHtml","html","replace","generateBundle","this","emitFile","type","fileName","source"],"mappings":"oHASA,MAAMA,EAAa,GAAGC,0BAStB,SAASC,EAAyBC,EAA0B,IAC1D,MAAMC,SAAEA,EAAW,iBAAgBC,OAAEA,EAAS,QAAWF,EACzD,IAAIG,EAAU,GAEd,MAAO,CACLC,KAAMP,EACNQ,QAAS,OAITC,MAAK,CAACC,GAAGC,QAAEA,EAAOC,WAAEA,KACC,UAAZD,IAAwBC,IAAeC,IAEhDC,mBAAmBC,IACjBT,EAAUS,EAAKC,QAAQ,OAAOX,KAAW,OAAOA,yBAEzCU,GAETE,iBACOX,GAILY,KAAKC,SAAS,CACZC,KAAM,QACNC,SAAUjB,EACVkB,OAAQhB,GAEZ,EAEJ"}
1
+ {"version":3,"file":"create-spa-index.js","sources":["../../src/plugins/create-spa-index.ts"],"sourcesContent":[null],"names":["pluginName","PLUGIN_NAME","ViteCreateSPAIndexPlugin","options","filename","rootId","spaHtml","name","enforce","apply","_","command","isSsrBuild","getCurrentEntrypointName","transformIndexHtml","html","replace","generateBundle","this","emitFile","type","fileName","source"],"mappings":"oHASA,MAAMA,EAAa,GAAGC,0BAStB,SAASC,EAAyBC,EAA0B,IAC1D,MAAMC,SAAEA,EAAW,iBAAgBC,OAAEA,EAAS,QAAWF,EACzD,IAAIG,EAAU,GAEd,MAAO,CACLC,KAAMP,EACNQ,QAAS,OAITC,MAAK,CAACC,GAAGC,QAAEA,EAAOC,WAAEA,KACC,UAAZD,IAAwBC,IAAeC,IAEhDC,mBAAmBC,IACjBT,EAAUS,EAAKC,QAAQ,OAAOX,KAAW,OAAOA,yBAEzCU,GAET,cAAAE,GACOX,GAILY,KAAKC,SAAS,CACZC,KAAM,QACNC,SAAUjB,EACVkB,OAAQhB,GAEZ,EAEJ"}
@@ -1,6 +1,6 @@
1
- import { Plugin } from 'vite';
2
- import { IBuildEntrypoint } from "../services/build.js";
3
- interface IPluginOptions {
1
+ import type { Plugin } from 'vite';
2
+ import type { IBuildEntrypoint } from '../services/build.js';
3
+ export interface IPluginOptions {
4
4
  entrypoint: IBuildEntrypoint;
5
5
  }
6
6
  /**
@@ -22,4 +22,4 @@ declare const getCurrentEntrypoint: (entrypoint: IBuildEntrypoint[], currentEntr
22
22
  * @constructor
23
23
  */
24
24
  declare function ViteHandleCustomEntrypointPlugin(options: IPluginOptions): Plugin;
25
- export { IPluginOptions, ViteHandleCustomEntrypointPlugin, getCurrentEntrypoint, getCurrentEntrypointName, setCurrentEntrypointName };
25
+ export { ViteHandleCustomEntrypointPlugin, getCurrentEntrypoint, getCurrentEntrypointName, setCurrentEntrypointName, };
@@ -1,2 +1,2 @@
1
- import e from"node:fs";import n from"node:path";import o from"node:process";import r from"../constants/plugin-name.js";const t=`${r}-handle-custom-entrypoint`,i=()=>o.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME,l=e=>{o.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME=e},s=(e,n=i())=>{if(!e.length||!n)return null;for(const o of e)if(o.name===n&&!o.serverFile)return o;return null},c=(e,n,o)=>{const r=n.replace("./","/"),t=o.replace("./","/");return e.replace(r,t)};function m(o){const{entrypoint:i}=o;let l="",s="";return{name:t,enforce:"pre",apply:(e,{isSsrBuild:n})=>!n&&Boolean(i),config(e){const{indexFile:o}=i,r=e.build??{},t=o?n.resolve(e.root??"",o):void 0;return{...e,build:{...r,rollupOptions:{...r.rollupOptions??{},input:t}}}},configResolved(e){const o=e.plugins.find((e=>e.name===r));l=n.resolve(e.root,e.build.outDir),s=o.pluginOptions.clientFile},transform(e,n){if(n.endsWith(".html")){const{clientFile:n}=i;if(n)return{code:c(e,s,n),map:this.getCombinedSourcemap()}}return{code:e,map:this.getCombinedSourcemap()}},transformIndexHtml(e,{originalUrl:n,server:o}){const{clientFile:r}=i;return r&&"serve"===o?.config.command&&n?.endsWith(".html")?c(e,s,r):e},closeBundle(){const{indexFile:o}=i;if(!o)return;const r=n.resolve(l,n.basename(o));e.existsSync(r)&&e.renameSync(r,n.resolve(l,"index.html"))}}}export{m as ViteHandleCustomEntrypointPlugin,s as getCurrentEntrypoint,i as getCurrentEntrypointName,l as setCurrentEntrypointName};
1
+ import e from"node:fs";import n from"node:path";import r from"node:process";import o from"../constants/plugin-name.js";const t=`${o}-handle-custom-entrypoint`,i=()=>r.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME,l=e=>{r.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME=e},s=(e,n=i())=>{if(!e.length||!n)return null;for(const r of e)if(r.name===n&&!r.serverFile)return r;return null},c=(e,n,r)=>{const o=n.replace("./","/"),t=r.replace("./","/");return e.replace(o,t)};function m(r){const{entrypoint:i}=r;let l="",s="";return{name:t,enforce:"pre",apply:(e,{isSsrBuild:n})=>!n&&Boolean(i),config(e){const{indexFile:r}=i,o=e.build??{},t=r?n.resolve(e.root??"",r):void 0;return{...e,build:{...o,rollupOptions:{...o.rollupOptions??{},input:t}}}},configResolved(e){const r=e.plugins.find(e=>e.name===o);l=n.resolve(e.root,e.build.outDir),s=r.pluginOptions.clientFile},transform(e,n){if(n.endsWith(".html")){const{clientFile:n}=i;if(n)return{code:c(e,s,n),map:JSON.stringify(this.getCombinedSourcemap())}}return{code:e,map:JSON.stringify(this.getCombinedSourcemap())}},transformIndexHtml(e,{originalUrl:n,server:r}){const{clientFile:o}=i;return o&&"serve"===r?.config.command&&n?.endsWith(".html")?c(e,s,o):e},closeBundle(){const{indexFile:r}=i;if(!r)return;const o=n.resolve(l,n.basename(r));e.existsSync(o)&&e.renameSync(o,n.resolve(l,"index.html"))}}}export{m as ViteHandleCustomEntrypointPlugin,s as getCurrentEntrypoint,i as getCurrentEntrypointName,l as setCurrentEntrypointName};
2
2
  //# sourceMappingURL=handle-custom-entrypoint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handle-custom-entrypoint.js","sources":["../../src/plugins/handle-custom-entrypoint.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport type { Plugin } from 'vite';\nimport PLUGIN_NAME from '@constants/plugin-name';\nimport type { IBuildEntrypoint } from '@services/build';\n\nexport interface IPluginOptions {\n entrypoint: IBuildEntrypoint;\n}\n\nconst pluginName = `${PLUGIN_NAME}-handle-custom-entrypoint`;\n\n/**\n * Get current entrypoint name\n */\nconst getCurrentEntrypointName = (): string | undefined =>\n process.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME;\n\n/**\n * Set current entrypoint name\n */\nconst setCurrentEntrypointName = (name: string): void => {\n process.env.SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME = name;\n};\n\n/**\n * Find current entrypoint by env\n */\nconst getCurrentEntrypoint = (\n entrypoint: IBuildEntrypoint[],\n currentEntrypointName = getCurrentEntrypointName(),\n): IBuildEntrypoint | null => {\n if (!entrypoint.length || !currentEntrypointName) {\n return null;\n }\n\n for (const entry of entrypoint) {\n if (entry.name === currentEntrypointName && !entry.serverFile) {\n return entry;\n }\n }\n\n return null;\n};\n\n/**\n * Replace entrypoint in html file\n */\nconst replaceEntrypoint = (code: string, originalPath: string, endpointPath: string): string => {\n const cleanOrigPath = originalPath.replace('./', '/');\n const cleanEndpointPath = endpointPath.replace('./', '/');\n\n return code.replace(cleanOrigPath, cleanEndpointPath);\n};\n\n/**\n * Return custom entrypoint instead default (index.html).\n *\n * E.g. for build multiple entrypoint\n * @constructor\n */\nfunction ViteHandleCustomEntrypointPlugin(options: IPluginOptions): Plugin {\n const { entrypoint } = options;\n let outPath = '';\n let origClientFile = '';\n\n return {\n name: pluginName,\n enforce: 'pre',\n /**\n * Apply only on build but not for SSR and only for custom entrypoint\n */\n apply(_, { isSsrBuild }): boolean {\n return !isSsrBuild && Boolean(entrypoint);\n },\n config(config) {\n const { indexFile } = entrypoint;\n const buildConfig = config.build ?? {};\n const indexFilePath = indexFile ? path.resolve(config.root ?? '', indexFile) : undefined;\n\n return {\n ...config,\n build: {\n ...buildConfig,\n rollupOptions: {\n ...(buildConfig.rollupOptions ?? {}),\n input: indexFilePath,\n },\n },\n };\n },\n configResolved(config) {\n const pluginConfig = config.plugins.find((plugin) => plugin.name === PLUGIN_NAME);\n\n outPath = path.resolve(config.root, config.build.outDir);\n // @ts-expect-error pluginOptions is custom param\n origClientFile = (pluginConfig.pluginOptions as Record<string, any>).clientFile as string;\n },\n transform(code, id) {\n if (id.endsWith('.html')) {\n const { clientFile } = entrypoint;\n\n if (clientFile) {\n return {\n code: replaceEntrypoint(code, origClientFile, clientFile),\n map: this.getCombinedSourcemap(),\n };\n }\n }\n\n return {\n code,\n map: this.getCombinedSourcemap(),\n };\n },\n /**\n * Development mode\n */\n transformIndexHtml(html, { originalUrl, server }): string {\n const { clientFile } = entrypoint;\n\n if (clientFile && server?.config.command === 'serve' && originalUrl?.endsWith('.html')) {\n return replaceEntrypoint(html, origClientFile, clientFile);\n }\n\n return html;\n },\n closeBundle() {\n const { indexFile } = entrypoint;\n\n if (!indexFile) {\n return;\n }\n\n const indexFilePath = path.resolve(outPath, path.basename(indexFile));\n\n if (fs.existsSync(indexFilePath)) {\n fs.renameSync(indexFilePath, path.resolve(outPath, 'index.html'));\n }\n },\n };\n}\n\nexport {\n ViteHandleCustomEntrypointPlugin,\n getCurrentEntrypoint,\n getCurrentEntrypointName,\n setCurrentEntrypointName,\n};\n"],"names":["pluginName","PLUGIN_NAME","getCurrentEntrypointName","process","env","SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME","setCurrentEntrypointName","name","getCurrentEntrypoint","entrypoint","currentEntrypointName","length","entry","serverFile","replaceEntrypoint","code","originalPath","endpointPath","cleanOrigPath","replace","cleanEndpointPath","ViteHandleCustomEntrypointPlugin","options","outPath","origClientFile","enforce","apply","_","isSsrBuild","Boolean","config","indexFile","buildConfig","build","indexFilePath","path","resolve","root","undefined","rollupOptions","input","configResolved","pluginConfig","plugins","find","plugin","outDir","pluginOptions","clientFile","transform","id","endsWith","map","this","getCombinedSourcemap","transformIndexHtml","html","originalUrl","server","command","closeBundle","basename","fs","existsSync","renameSync"],"mappings":"uHAWA,MAAMA,EAAa,GAAGC,6BAKhBC,EAA2B,IAC/BC,EAAQC,IAAIC,uCAKRC,EAA4BC,IAChCJ,EAAQC,IAAIC,uCAAyCE,CAAI,EAMrDC,EAAuB,CAC3BC,EACAC,EAAwBR,OAExB,IAAKO,EAAWE,SAAWD,EACzB,OAAO,KAGT,IAAK,MAAME,KAASH,EAClB,GAAIG,EAAML,OAASG,IAA0BE,EAAMC,WACjD,OAAOD,EAIX,OAAO,IAAI,EAMPE,EAAoB,CAACC,EAAcC,EAAsBC,KAC7D,MAAMC,EAAgBF,EAAaG,QAAQ,KAAM,KAC3CC,EAAoBH,EAAaE,QAAQ,KAAM,KAErD,OAAOJ,EAAKI,QAAQD,EAAeE,EAAkB,EASvD,SAASC,EAAiCC,GACxC,MAAMb,WAAEA,GAAea,EACvB,IAAIC,EAAU,GACVC,EAAiB,GAErB,MAAO,CACLjB,KAAMP,EACNyB,QAAS,MAITC,MAAK,CAACC,GAAGC,WAAEA,MACDA,GAAcC,QAAQpB,GAEhCqB,OAAOA,GACL,MAAMC,UAAEA,GAActB,EAChBuB,EAAcF,EAAOG,OAAS,CAAA,EAC9BC,EAAgBH,EAAYI,EAAKC,QAAQN,EAAOO,MAAQ,GAAIN,QAAaO,EAE/E,MAAO,IACFR,EACHG,MAAO,IACFD,EACHO,cAAe,IACTP,EAAYO,eAAiB,GACjCC,MAAON,IAIf,EACAO,eAAeX,GACb,MAAMY,EAAeZ,EAAOa,QAAQC,MAAMC,GAAWA,EAAOtC,OAASN,IAErEsB,EAAUY,EAAKC,QAAQN,EAAOO,KAAMP,EAAOG,MAAMa,QAEjDtB,EAAkBkB,EAAaK,cAAsCC,UACvE,EACAC,UAAUlC,EAAMmC,GACd,GAAIA,EAAGC,SAAS,SAAU,CACxB,MAAMH,WAAEA,GAAevC,EAEvB,GAAIuC,EACF,MAAO,CACLjC,KAAMD,EAAkBC,EAAMS,EAAgBwB,GAC9CI,IAAKC,KAAKC,uBAGhB,CAEA,MAAO,CACLvC,OACAqC,IAAKC,KAAKC,uBAEd,EAIAC,mBAAmBC,GAAMC,YAAEA,EAAWC,OAAEA,IACtC,MAAMV,WAAEA,GAAevC,EAEvB,OAAIuC,GAAyC,UAA3BU,GAAQ5B,OAAO6B,SAAuBF,GAAaN,SAAS,SACrErC,EAAkB0C,EAAMhC,EAAgBwB,GAG1CQ,CACT,EACAI,cACE,MAAM7B,UAAEA,GAActB,EAEtB,IAAKsB,EACH,OAGF,MAAMG,EAAgBC,EAAKC,QAAQb,EAASY,EAAK0B,SAAS9B,IAEtD+B,EAAGC,WAAW7B,IAChB4B,EAAGE,WAAW9B,EAAeC,EAAKC,QAAQb,EAAS,cAEvD,EAEJ"}
1
+ {"version":3,"file":"handle-custom-entrypoint.js","sources":["../../src/plugins/handle-custom-entrypoint.ts"],"sourcesContent":[null],"names":["pluginName","PLUGIN_NAME","getCurrentEntrypointName","process","env","SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME","setCurrentEntrypointName","name","getCurrentEntrypoint","entrypoint","currentEntrypointName","length","entry","serverFile","replaceEntrypoint","code","originalPath","endpointPath","cleanOrigPath","replace","cleanEndpointPath","ViteHandleCustomEntrypointPlugin","options","outPath","origClientFile","enforce","apply","_","isSsrBuild","Boolean","config","indexFile","buildConfig","build","indexFilePath","path","resolve","root","undefined","rollupOptions","input","configResolved","pluginConfig","plugins","find","plugin","outDir","pluginOptions","clientFile","transform","id","endsWith","map","JSON","stringify","this","getCombinedSourcemap","transformIndexHtml","html","originalUrl","server","command","closeBundle","basename","fs","existsSync","renameSync"],"mappings":"uHAWA,MAAMA,EAAa,GA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AqC,IAAKC,KAAKC,UAAUC,KAAKC,wBAE7B,EAIA,kBAAAC,CAAmBC,GAAMC,YAAEA,EAAWC,OAAEA,IACtC,MAAMZ,WAAEA,GAAevC,EAEvB,OAAIuC,GAAyC,UAA3BY,GAAQ9B,OAAO+B,SAAuBF,GAAaR,SAAS,SACrErC,EAAkB4C,EAAMlC,EAAgBwB,GAG1CU,CACT,EACA,WAAAI,GACE,MAAM/B,UAAEA,GAActB,EAEtB,IAAKsB,EACH,OAGF,MAAMG,EAAgBC,EAAKC,QAAQb,EAASY,EAAK4B,SAAShC,IAEtDiC,EAAGC,WAAW/B,IAChB8B,EAAGE,WAAWhC,EAAeC,EAAKC,QAAQb,EAAS,cAEvD,EAEJ"}
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'vite';
2
- interface IPluginOptions {
1
+ import type { Plugin } from 'vite';
2
+ export interface IPluginOptions {
3
3
  root?: string;
4
4
  tsconfig?: string;
5
5
  }
@@ -9,4 +9,4 @@ interface IPluginOptions {
9
9
  * @constructor
10
10
  */
11
11
  declare function ViteMakeAliasesPlugin(options?: IPluginOptions): Plugin;
12
- export { ViteMakeAliasesPlugin as default, IPluginOptions };
12
+ export default ViteMakeAliasesPlugin;
@@ -1,2 +1,2 @@
1
- import e from"node:fs";import o from"node:path";import s from"node:process";import r from"json5";import t from"../constants/plugin-name.js";import n from"../helpers/vite-aliases.js";const i=`${t}-make-aliases`,a=e=>e.replace(/\/?\*$/,"");function c(t={}){const{root:c,tsconfig:p}=t,f=c??s.cwd(),m=o.resolve(f,p??"tsconfig.json"),l=[];if(e.existsSync(m)){const o=r.parse(e.readFileSync(m,{encoding:"utf-8"})),s=o?.compilerOptions?.paths??{};Object.entries(s).forEach((([e,o])=>{l.push([a(e),a(o[0])])}))}else console.error(`${i}: tsconfig not exist in "${m}"`);return{name:i,config(e){if(l.length){const o=e.resolve??{},s=o.alias??[],r=Array.isArray(s)?s:Object.entries(s).map((([e,o])=>({find:e,replacement:o})));r.push(...n(l,`${f}/${e?.root??""}`)),e.resolve={...o,alias:r}}return e}}}export{c as default};
1
+ import e from"node:fs";import o from"node:path";import s from"node:process";import r from"json5";import t from"../constants/plugin-name.js";import n from"../helpers/vite-aliases.js";const i=`${t}-make-aliases`,a=e=>e.replace(/\/?\*$/,"");function c(t={}){const{root:c,tsconfig:p}=t,f=c??s.cwd(),m=o.resolve(f,p??"tsconfig.json"),l=[];if(e.existsSync(m)){const o=r.parse(e.readFileSync(m,{encoding:"utf-8"})),s=o?.compilerOptions?.paths??{};Object.entries(s).forEach(([e,o])=>{l.push([a(e),a(o[0])])})}else console.error(`${i}: tsconfig not exist in "${m}"`);return{name:i,config(e){if(l.length){const o=e.resolve??{},s=o.alias??[],r=Array.isArray(s)?s:Object.entries(s).map(([e,o])=>({find:e,replacement:o}));r.push(...n(l,`${f}/${e?.root??""}`)),e.resolve={...o,alias:r}}return e}}}export{c as default};
2
2
  //# sourceMappingURL=make-aliases.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-aliases.js","sources":["../../src/plugins/make-aliases.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport JSON5 from 'json5';\nimport type { Plugin } from 'vite';\n// import without aliases for use in vitest.config.ts\nimport PLUGIN_NAME from '../constants/plugin-name';\nimport ViteAliases from '../helpers/vite-aliases';\n\nexport interface IPluginOptions {\n root?: string; // default: cwd()\n tsconfig?: string; // default: tsconfig.json\n}\n\nconst pluginName = `${PLUGIN_NAME}-make-aliases`;\nconst cleanupAlias = (str: string): string => str.replace(/\\/?\\*$/, '');\n\n/**\n * Read tsconfig file and set vite aliases\n * @see PathNormalize.getAliases\n * @constructor\n */\nfunction ViteMakeAliasesPlugin(options: IPluginOptions = {}): Plugin {\n const { root, tsconfig } = options;\n const projectRoot = root ?? process.cwd();\n const tsconfigPath = path.resolve(projectRoot, tsconfig ?? 'tsconfig.json');\n const aliases: [string, string][] = [];\n\n if (!fs.existsSync(tsconfigPath)) {\n console.error(`${pluginName}: tsconfig not exist in \"${tsconfigPath}\"`);\n } else {\n const tsJson = JSON5.parse<{ compilerOptions?: { paths: Record<string, string[]> } }>(\n fs.readFileSync(tsconfigPath, { encoding: 'utf-8' }),\n );\n const paths = tsJson?.compilerOptions?.paths ?? {};\n\n Object.entries(paths).forEach(([alias, aliasPaths]) => {\n aliases.push([cleanupAlias(alias), cleanupAlias(aliasPaths[0])]);\n });\n }\n\n return {\n name: pluginName,\n config(config) {\n if (aliases.length) {\n const resolveConfig = config.resolve ?? {};\n const defaultAliases = resolveConfig.alias ?? [];\n const normalizedAliases = Array.isArray(defaultAliases)\n ? defaultAliases\n : Object.entries(defaultAliases).map(([find, val]) => ({\n find,\n replacement: val as string,\n }));\n\n normalizedAliases.push(...ViteAliases(aliases, `${projectRoot}/${config?.root ?? ''}`));\n\n config.resolve = {\n ...resolveConfig,\n alias: normalizedAliases,\n };\n }\n\n return config;\n },\n };\n}\n\nexport default ViteMakeAliasesPlugin;\n"],"names":["pluginName","PLUGIN_NAME","cleanupAlias","str","replace","ViteMakeAliasesPlugin","options","root","tsconfig","projectRoot","process","cwd","tsconfigPath","path","resolve","aliases","fs","existsSync","tsJson","JSON5","parse","readFileSync","encoding","paths","compilerOptions","Object","entries","forEach","alias","aliasPaths","push","console","error","name","config","length","resolveConfig","defaultAliases","normalizedAliases","Array","isArray","map","find","val","replacement","ViteAliases"],"mappings":"sLAcA,MAAMA,EAAa,GAAGC,iBAChBC,EAAgBC,GAAwBA,EAAIC,QAAQ,SAAU,IAOpE,SAASC,EAAsBC,EAA0B,IACvD,MAAMC,KAAEA,EAAIC,SAAEA,GAAaF,EACrBG,EAAcF,GAAQG,EAAQC,MAC9BC,EAAeC,EAAKC,QAAQL,EAAaD,GAAY,iBACrDO,EAA8B,GAEpC,GAAKC,EAAGC,WAAWL,GAEZ,CACL,MAAMM,EAASC,EAAMC,MACnBJ,EAAGK,aAAaT,EAAc,CAAEU,SAAU,WAEtCC,EAAQL,GAAQM,iBAAiBD,OAAS,CAAA,EAEhDE,OAAOC,QAAQH,GAAOI,SAAQ,EAAEC,EAAOC,MACrCd,EAAQe,KAAK,CAAC5B,EAAa0B,GAAQ1B,EAAa2B,EAAW,KAAK,GAEpE,MAVEE,QAAQC,MAAM,GAAGhC,6BAAsCY,MAYzD,MAAO,CACLqB,KAAMjC,EACNkC,OAAOA,GACL,GAAInB,EAAQoB,OAAQ,CAClB,MAAMC,EAAgBF,EAAOpB,SAAW,CAAA,EAClCuB,EAAiBD,EAAcR,OAAS,GACxCU,EAAoBC,MAAMC,QAAQH,GACpCA,EACAZ,OAAOC,QAAQW,GAAgBI,KAAI,EAAEC,EAAMC,MAAI,CAC7CD,OACAE,YAAaD,MAGnBL,EAAkBR,QAAQe,EAAY9B,EAAS,GAAGN,KAAeyB,GAAQ3B,MAAQ,OAEjF2B,EAAOpB,QAAU,IACZsB,EACHR,MAAOU,EAEX,CAEA,OAAOJ,CACT,EAEJ"}
1
+ {"version":3,"file":"make-aliases.js","sources":["../../src/plugins/make-aliases.ts"],"sourcesContent":[null],"names":["pluginName","PLUGIN_NAME","cleanupAlias","str","replace","ViteMakeAliasesPlugin","options","root","tsconfig","projectRoot","process","cwd","tsconfigPath","path","resolve","aliases","fs","existsSync","tsJson","JSON5","parse","readFileSync","encoding","paths","compilerOptions","Object","entries","forEach","alias","aliasPaths","push","console","error","name","config","length","resolveConfig","defaultAliases","normalizedAliases","Array","isArray","map","find","val","replacement","ViteAliases"],"mappings":"sLAcA,MAAMA,EAAa,GAAGC,iBAChBC,EAAgBC,GAAwBA,EAAIC,QAAQ,SAAU,IAOpE,SAASC,EAAsBC,EAA0B,IACvD,MAAMC,KAAEA,EAAIC,SAAEA,GAAaF,EACrBG,EAAcF,GAAQG,EAAQC,MAC9BC,EAAeC,EAAKC,QAAQL,EAAaD,GAAY,iBACrDO,EAA8B,GAEpC,GAAKC,EAAGC,WAAWL,GAEZ,CACL,MAAMM,EAASC,EAAMC,MACnBJ,EAAGK,aAAaT,EAAc,CAAEU,SAAU,WAEtCC,EAAQL,GAAQM,iBAAiBD,OAAS,CAAA,EAEhDE,OAAOC,QAAQH,GAAOI,QAAQ,EAAEC,EAAOC,MACrCd,EAAQe,KAAK,CAAC5B,EAAa0B,GAAQ1B,EAAa2B,EAAW,OAE/D,MAVEE,QAAQC,MAAM,GAAGhC,6BAAsCY,MAYzD,MAAO,CACLqB,KAAMjC,EACN,MAAAkC,CAAOA,GACL,GAAInB,EAAQoB,OAAQ,CAClB,MAAMC,EAAgBF,EAAOpB,SAAW,CAAA,EAClCuB,EAAiBD,EAAcR,OAAS,GACxCU,EAAoBC,MAAMC,QAAQH,GACpCA,EACAZ,OAAOC,QAAQW,GAAgBI,IAAI,EAAEC,EAAMC,MAAI,CAC7CD,OACAE,YAAaD,KAGnBL,EAAkBR,QAAQe,EAAY9B,EAAS,GAAGN,KAAeyB,GAAQ3B,MAAQ,OAEjF2B,EAAOpB,QAAU,IACZsB,EACHR,MAAOU,EAEX,CAEA,OAAOJ,CACT,EAEJ"}
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'vite';
2
- interface IPluginOptions {
1
+ import type { Plugin } from 'vite';
2
+ export interface IPluginOptions {
3
3
  isSSR?: boolean;
4
4
  isBuild?: boolean;
5
5
  routesPath?: string;
@@ -13,4 +13,4 @@ interface IPluginOptions {
13
13
  * @constructor
14
14
  */
15
15
  declare function ViteNormalizeRouterPlugin(options?: IPluginOptions): Plugin;
16
- export { ViteNormalizeRouterPlugin as default, IPluginOptions };
16
+ export default ViteNormalizeRouterPlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-route.js","sources":["../../src/plugins/normalize-route.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport type { Plugin } from 'vite';\nimport PLUGIN_NAME from '@constants/plugin-name';\nimport isRoutesFile from '@helpers/is-route-file';\nimport ParseRoutes from '@services/parse-routes';\n\nexport interface IPluginOptions {\n isSSR?: boolean;\n isBuild?: boolean;\n routesPath?: string;\n}\n\n/**\n * Add possibility to export route components like FCRoute or FCCRoute\n * USAGE: { path: '/', lazy: () => import('./pages/home') }\n * @see FCRoute\n * @see FCCRoute\n * @see importRoute\n * @constructor\n */\nfunction ViteNormalizeRouterPlugin(options: IPluginOptions = {}): Plugin {\n const { routesPath, isSSR = false, isBuild = false } = options;\n\n return {\n name: `${PLUGIN_NAME}-normalize-route`,\n enforce: 'pre',\n transform(code, id) {\n const [extName] = extname(id).split('?');\n const isRoutesPath = !routesPath || id.includes(routesPath);\n\n if (\n id.includes('node_modules') ||\n !['.js', '.mjs', '.ts', '.tsx'].includes(extName) ||\n !isRoutesPath ||\n !isRoutesFile(code)\n ) {\n return;\n }\n\n return {\n code: ParseRoutes.handleRoutes(\n code,\n // always add pathId to routes for development\n isSSR && !isBuild,\n ),\n map: { mappings: '' },\n };\n },\n };\n}\n\nexport default ViteNormalizeRouterPlugin;\n"],"names":["ViteNormalizeRouterPlugin","options","routesPath","isSSR","isBuild","name","PLUGIN_NAME","enforce","transform","code","id","extName","extname","split","isRoutesPath","includes","isRoutesFile","ParseRoutes","handleRoutes","map","mappings"],"mappings":"qKAoBA,SAASA,EAA0BC,EAA0B,IAC3D,MAAMC,WAAEA,EAAUC,MAAEA,GAAQ,EAAKC,QAAEA,GAAU,GAAUH,EAEvD,MAAO,CACLI,KAAM,GAAGC,oBACTC,QAAS,MACTC,UAAUC,EAAMC,GACd,MAAOC,GAAWC,EAAQF,GAAIG,MAAM,KAC9BC,GAAgBZ,GAAcQ,EAAGK,SAASb,GAEhD,IACEQ,EAAGK,SAAS,iBACX,CAAC,MAAO,OAAQ,MAAO,QAAQA,SAASJ,IACxCG,GACAE,EAAaP,GAKhB,MAAO,CACLA,KAAMQ,EAAYC,aAChBT,EAEAN,IAAUC,GAEZe,IAAK,CAAEC,SAAU,IAErB,EAEJ"}
1
+ {"version":3,"file":"normalize-route.js","sources":["../../src/plugins/normalize-route.ts"],"sourcesContent":[null],"names":["ViteNormalizeRouterPlugin","options","routesPath","isSSR","isBuild","name","PLUGIN_NAME","enforce","transform","code","id","extName","extname","split","isRoutesPath","includes","isRoutesFile","ParseRoutes","handleRoutes","map","mappings"],"mappings":"qKAoBA,SAASA,EAA0BC,EAA0B,IAC3D,MAAMC,WAAEA,EAAUC,MAAEA,GAAQ,EAAKC,QAAEA,GAAU,GAAUH,EAEvD,MAAO,CACLI,KAAM,GAAGC,oBACTC,QAAS,MACT,SAAAC,CAAUC,EAAMC,GACd,MAAOC,GAAWC,EAAQF,GAAIG,MAAM,KAC9BC,GAAgBZ,GAAcQ,EAAGK,SAASb,GAEhD,IACEQ,EAAGK,SAAS,iBACX,CAAC,MAAO,OAAQ,MAAO,QAAQA,SAASJ,IACxCG,GACAE,EAAaP,GAKhB,MAAO,CACLA,KAAMQ,EAAYC,aAChBT,EAEAN,IAAUC,GAEZe,IAAK,CAAEC,SAAU,IAErB,EAEJ"}
@@ -1,8 +1,7 @@
1
- /// <reference types="node" />
2
1
  import childProcess from 'node:child_process';
3
- import { ResolvedConfig } from 'vite';
4
- import { IPluginConfig } from "../helpers/plugin-config.js";
5
- interface IBuildParams {
2
+ import type { ResolvedConfig } from 'vite';
3
+ import type { IPluginConfig } from '../helpers/plugin-config.js';
4
+ export interface IBuildParams {
6
5
  mode: string;
7
6
  onFinish?: () => void;
8
7
  clientOptions?: string;
@@ -23,7 +22,7 @@ interface ISpawnBuildParams {
23
22
  focusOnly?: IBuildParams['focusOnly'];
24
23
  env?: Record<string, string>;
25
24
  }
26
- interface IBuildEntrypoint {
25
+ export interface IBuildEntrypoint {
27
26
  name: string;
28
27
  type: 'spa' | 'ssr';
29
28
  indexFile?: string;
@@ -74,110 +73,65 @@ declare class Build {
74
73
  * Listener for preview has attached
75
74
  */
76
75
  protected hasPreviewModeExitListener: boolean;
77
- /**
78
- * @constructor
79
- */
80
76
  /**
81
77
  * @constructor
82
78
  */
83
79
  constructor(params: IBuildParams);
84
- /**
85
- * Make config
86
- */
87
80
  /**
88
81
  * Make config
89
82
  */
90
83
  protected makeConfig(): Promise<void>;
91
- /**
92
- * Clear build folder
93
- */
94
84
  /**
95
85
  * Clear build folder
96
86
  */
97
87
  clearBuildFolder(): void;
98
- /**
99
- * Return is prod indicator value
100
- */
101
88
  /**
102
89
  * Return is prod indicator value
103
90
  */
104
91
  getIsProd(): boolean;
105
- /**
106
- * Return node env value
107
- */
108
92
  /**
109
93
  * Return node env value
110
94
  */
111
95
  getNodeEnv(): string;
112
- /**
113
- * Return build names
114
- */
115
96
  /**
116
97
  * Return build names
117
98
  */
118
99
  getRunningBuildNames(): string[];
119
- /**
120
- * Promisify spawn process
121
- */
122
100
  /**
123
101
  * Promisify spawn process
124
102
  */
125
103
  protected promisifyProcess(command: childProcess.ChildProcess, isRejectWarnings?: boolean): IBuildProcess;
126
- /**
127
- * Build assets manifest file
128
- */
129
104
  /**
130
105
  * Build assets manifest file
131
106
  */
132
107
  protected buildManifest(): void;
133
- /**
134
- * Change general directive Disallow to Allow in robots.txt.
135
- */
136
108
  /**
137
109
  * Change general directive Disallow to Allow in robots.txt.
138
110
  */
139
111
  protected unlockRobots(): void;
140
- /**
141
- * Eject cli to run app via node
142
- */
143
112
  /**
144
113
  * Eject cli to run app via node
145
114
  */
146
115
  protected eject(): void;
147
- /**
148
- * Create serverless entrypoint
149
- */
150
116
  /**
151
117
  * Create serverless entrypoint
152
118
  */
153
119
  protected createServerless(): void;
154
- /**
155
- * Build specified entrypoint
156
- */
157
120
  /**
158
121
  * Build specified entrypoint
159
122
  */
160
123
  protected spawnBuild(name: string, buildOptions: string, params?: ISpawnBuildParams): Promise<void>;
161
- /**
162
- * Wait latest build and stop process in case error
163
- */
164
124
  /**
165
125
  * Wait latest build and stop process in case error
166
126
  */
167
127
  protected waitLastBuild(): Promise<void>;
168
- /**
169
- * Run preview mode
170
- */
171
128
  /**
172
129
  * Run preview mode
173
130
  */
174
131
  protected runPreviewMode(): void;
175
- /**
176
- * Run app build
177
- */
178
132
  /**
179
133
  * Run app build
180
134
  */
181
135
  build(): Promise<void>;
182
136
  }
183
- export { Build as default, IBuildParams, IBuildEntrypoint };
137
+ export default Build;
package/services/build.js CHANGED
@@ -1,2 +1,2 @@
1
- import i from"node:child_process";import s from"node:fs";import t from"node:path";import e from"chalk";import{resolveConfig as o}from"vite";import r from"../cli/helpers/vite-reset-cache.js";import n from"../helpers/create-focus-only.js";import{createDevMarker as l}from"../helpers/dev-marker.js";import a from"../helpers/plugin-config.js";import u from"../helpers/process-stop.js";import c from"./server-config.js";import d from"./ssr-manifest.js";class h{isProd;nodeEnv;buildDir;viteConfig;pluginConfig;params={mode:"",clientOptions:"",serverOptions:"",focusOnly:"app",isWatch:!1,isUnlockRobots:!1,isEject:!1,isServerless:!1,isNoWarnings:!1};abortController=null;runningBuild=[];hasPreviewModeExitListener=!1;constructor(i){this.params={...this.params,...i}}async makeConfig(){const{mode:i}=this.params;this.viteConfig=await o({},"build",i,"production"),this.pluginConfig=a(this.viteConfig),this.buildDir=t.resolve(this.viteConfig.root,this.viteConfig.build.outDir),this.nodeEnv=process.env.NODE_ENV||"production",this.isProd="production"===this.nodeEnv}clearBuildFolder(){s.existsSync(this.buildDir)&&s.rmSync(this.buildDir,{recursive:!0})}getIsProd(){return this.isProd}getNodeEnv(){return this.nodeEnv}getRunningBuildNames(){return this.runningBuild.map((({name:i})=>i))}promisifyProcess(i,s=!1){const t=new Promise(((t,e)=>{i.on("exit",(i=>{t(i)})),i.on("close",(i=>{t(i)})),i.on("error",(i=>{e(i)})),s&&i.stderr?.on("data",(i=>{const s=Buffer.from(i).toString();(s.includes("warning")||s.includes("WARNING"))&&t(1)}))}));return i.stdout?.pipe(process.stdout),i.stderr?.pipe(process.stderr),{promise:t,command:i}}buildManifest(){console.info(e.blue("Building routes manifest file"));const i=c.init({isProd:this.isProd,mode:this.params.mode},{root:this.viteConfig.root,clientFile:this.pluginConfig.clientFile});d.get(i,{buildDir:this.viteConfig.build.outDir,viteAliases:this.viteConfig.resolve.alias,basename:this.viteConfig.base,renderBuiltUrl:this.viteConfig?.experimental?.renderBuiltUrl}).buildRoutesManifest()}unlockRobots(){const i=`${this.buildDir}/client/robots.txt`;if(!s.existsSync(i))return void console.warn(`Failed to unlock robots.txt, file not exist: ${i}`);const t=s.readFileSync(i,{encoding:"utf-8"}).replace(/Disallow: \/$/m,"Allow: /");s.writeFileSync(i,t,{encoding:"utf-8"}),console.info(e.blue("\nrobots.txt unlocked."))}eject(){const i=`${this.buildDir}/server/start.js`;s.writeFileSync(i,"import runProd from '@lomray/vite-ssr-boost/cli/run-prod.js';\n\nconst VERSION = process.env.VERSION || \"1.0.0\";\nconst PORT = process.env.PORT || 3000;\nconst IS_HOST = process.env.IS_HOST || \"0\";\nconst ONLY_CLIENT = process.env.ONLY_CLIENT || \"0\";\n\nawait runProd({\n version: VERSION,\n isHost: IS_HOST === '1',\n isPrintInfo: true,\n port: PORT,\n onlyClient: ONLY_CLIENT === '1',\n });\n",{encoding:"utf-8"})}createServerless(){const i=`${this.buildDir}/server/serverless.js`;s.writeFileSync(i,"import runServerless from '@lomray/vite-ssr-boost/cli/run-serverless.js';\n\nexport default await runServerless({ version: process.env.VERSION || \"1.0.0\" });\n",{encoding:"utf-8"})}async spawnBuild(s,t,e={}){const{mode:o,isNoWarnings:r}=this.params,{focusOnly:l=this.params.focusOnly,shouldWait:a=!1,env:u={}}=e,c=o&&!t.includes("--mode")?`--mode ${o}`:"",d=this.promisifyProcess(i.spawn(`vite build ${t} ${c} --emptyOutDir`,{signal:this.abortController.signal,stdio:[process.stdin,"pipe","pipe"],shell:!0,env:{...process.env,...u,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:n(l).isOnlyClient()?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}}),r);this.runningBuild.push({name:s,buildProcess:d}),a&&await this.waitLastBuild()}async waitLastBuild(){const i=this.runningBuild.at(-1);if(!i)return;const s=await i.buildProcess.promise;u(s,!0)}runPreviewMode(){this.hasPreviewModeExitListener||(process.on("exit",(()=>{this.abortController.abort()})),this.hasPreviewModeExitListener=!0);const{onFinish:i}=this.params;let s=this.runningBuild.length;const t=e=>{Buffer.from(e).toString().includes("built in")&&(s-=1,s||(this.runningBuild.forEach((({buildProcess:i})=>{i.command.stdout?.removeListener("data",t)})),l(this.isProd,this.viteConfig),i?.()))};this.runningBuild.forEach((({buildProcess:i})=>{i.command.stdout?.on("data",t)}))}async build(){await this.makeConfig(),await r(),this.clearBuildFolder();const{clientOptions:i,serverOptions:s,onFinish:t,isWatch:e,focusOnly:o,isEject:a,isServerless:u,isUnlockRobots:c}=this.params,{outDir:d}=this.viteConfig.build,h=n(o);this.abortController=new AbortController,this.runningBuild=[],h.isClient()&&await this.spawnBuild("client",`${i} --outDir ${d}/client`,{shouldWait:!e}),h.isServer()&&(await this.spawnBuild("server",`${s} --outDir ${d}/server --ssr ${this.pluginConfig.serverFile}`,{shouldWait:!e}),e||(this.buildManifest(),a&&this.eject(),u&&this.createServerless()));const{entrypoint:p}=this.pluginConfig;if(p?.length&&h.isEntrypoint())for(const{name:i,type:s,serverFile:t,buildOptions:o=""}of p){const r=t&&"ssr"===s?`--ssr ${t}`:"";await this.spawnBuild(i,`${o} ${r} --outDir ${d}/${i}`,{shouldWait:!e,focusOnly:"ssr"===s?"server":"client",env:{SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME:i}})}e?this.runPreviewMode():(c&&this.unlockRobots(),l(this.isProd,this.viteConfig),t?.())}}export{h as default};
1
+ import i from"node:child_process";import s from"node:fs";import t from"node:path";import e from"chalk";import{resolveConfig as o}from"vite";import r from"../cli/helpers/vite-reset-cache.js";import n from"../helpers/create-focus-only.js";import{createDevMarker as l}from"../helpers/dev-marker.js";import a from"../helpers/plugin-config.js";import u from"../helpers/process-stop.js";import c from"./server-config.js";import d from"./ssr-manifest.js";class h{isProd;nodeEnv;buildDir;viteConfig;pluginConfig;params={mode:"",clientOptions:"",serverOptions:"",focusOnly:"app",isWatch:!1,isUnlockRobots:!1,isEject:!1,isServerless:!1,isNoWarnings:!1};abortController=null;runningBuild=[];hasPreviewModeExitListener=!1;constructor(i){this.params={...this.params,...i}}async makeConfig(){const{mode:i}=this.params;this.viteConfig=await o({},"build",i,"production"),this.pluginConfig=a(this.viteConfig),this.buildDir=t.resolve(this.viteConfig.root,this.viteConfig.build.outDir),this.nodeEnv=process.env.NODE_ENV||"production",this.isProd="production"===this.nodeEnv}clearBuildFolder(){s.existsSync(this.buildDir)&&s.rmSync(this.buildDir,{recursive:!0})}getIsProd(){return this.isProd}getNodeEnv(){return this.nodeEnv}getRunningBuildNames(){return this.runningBuild.map(({name:i})=>i)}promisifyProcess(i,s=!1){const t=new Promise((t,e)=>{i.on("exit",i=>{t(i)}),i.on("close",i=>{t(i)}),i.on("error",i=>{e(i)}),s&&i.stderr?.on("data",i=>{const s=Buffer.from(i).toString();(s.includes("warning")||s.includes("WARNING"))&&t(1)})});return i.stdout?.pipe(process.stdout),i.stderr?.pipe(process.stderr),{promise:t,command:i}}buildManifest(){console.info(e.blue("Building routes manifest file"));const i=c.init({isProd:this.isProd,mode:this.params.mode},{root:this.viteConfig.root,clientFile:this.pluginConfig.clientFile});d.get(i,{buildDir:this.viteConfig.build.outDir,viteAliases:this.viteConfig.resolve.alias,basename:this.viteConfig.base,renderBuiltUrl:this.viteConfig?.experimental?.renderBuiltUrl}).buildRoutesManifest()}unlockRobots(){const i=`${this.buildDir}/client/robots.txt`;if(!s.existsSync(i))return void console.warn(`Failed to unlock robots.txt, file not exist: ${i}`);const t=s.readFileSync(i,{encoding:"utf-8"}).replace(/Disallow: \/$/m,"Allow: /");s.writeFileSync(i,t,{encoding:"utf-8"}),console.info(e.blue("\nrobots.txt unlocked."))}eject(){const i=`${this.buildDir}/server/start.js`;s.writeFileSync(i,"import runProd from '@lomray/vite-ssr-boost/cli/run-prod.js';\n\nconst VERSION = process.env.VERSION || \"1.0.0\";\nconst PORT = process.env.PORT || 3000;\nconst IS_HOST = process.env.IS_HOST || \"0\";\nconst ONLY_CLIENT = process.env.ONLY_CLIENT || \"0\";\n\nawait runProd({\n version: VERSION,\n isHost: IS_HOST === '1',\n isPrintInfo: true,\n port: PORT,\n onlyClient: ONLY_CLIENT === '1',\n });\n",{encoding:"utf-8"})}createServerless(){const i=`${this.buildDir}/server/serverless.js`;s.writeFileSync(i,"import runServerless from '@lomray/vite-ssr-boost/cli/run-serverless.js';\n\nexport default await runServerless({ version: process.env.VERSION || \"1.0.0\" });\n",{encoding:"utf-8"})}async spawnBuild(s,t,e={}){const{mode:o,isNoWarnings:r}=this.params,{focusOnly:l=this.params.focusOnly,shouldWait:a=!1,env:u={}}=e,c=o&&!t.includes("--mode")?`--mode ${o}`:"",d=this.promisifyProcess(i.spawn(`vite build ${t} ${c} --emptyOutDir`,{signal:this.abortController.signal,stdio:[process.stdin,"pipe","pipe"],shell:!0,env:{...process.env,...u,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:n(l).isOnlyClient()?"0":"1",SSR_BOOST_ACTION:global.viteBoostAction}}),r);this.runningBuild.push({name:s,buildProcess:d}),a&&await this.waitLastBuild()}async waitLastBuild(){const i=this.runningBuild.at(-1);if(!i)return;const s=await i.buildProcess.promise;u(s,!0)}runPreviewMode(){this.hasPreviewModeExitListener||(process.on("exit",()=>{this.abortController.abort()}),this.hasPreviewModeExitListener=!0);const{onFinish:i}=this.params;let s=this.runningBuild.length;const t=e=>{Buffer.from(e).toString().includes("built in")&&(s-=1,s||(this.runningBuild.forEach(({buildProcess:i})=>{i.command.stdout?.removeListener("data",t)}),l(this.isProd,this.viteConfig),i?.()))};this.runningBuild.forEach(({buildProcess:i})=>{i.command.stdout?.on("data",t)})}async build(){await this.makeConfig(),await r(),this.clearBuildFolder();const{clientOptions:i,serverOptions:s,onFinish:t,isWatch:e,focusOnly:o,isEject:a,isServerless:u,isUnlockRobots:c}=this.params,{outDir:d}=this.viteConfig.build,h=n(o);this.abortController=new AbortController,this.runningBuild=[],h.isClient()&&await this.spawnBuild("client",`${i} --outDir ${d}/client`,{shouldWait:!e}),h.isServer()&&(await this.spawnBuild("server",`${s} --outDir ${d}/server --ssr ${this.pluginConfig.serverFile}`,{shouldWait:!e}),e||(this.buildManifest(),a&&this.eject(),u&&this.createServerless()));const{entrypoint:p}=this.pluginConfig;if(p?.length&&h.isEntrypoint())for(const{name:i,type:s,serverFile:t,buildOptions:o=""}of p){const r=t&&"ssr"===s?`--ssr ${t}`:"";await this.spawnBuild(i,`${o} ${r} --outDir ${d}/${i}`,{shouldWait:!e,focusOnly:"ssr"===s?"server":"client",env:{SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME:i}})}e?this.runPreviewMode():(c&&this.unlockRobots(),l(this.isProd,this.viteConfig),t?.())}}export{h as default};
2
2
  //# sourceMappingURL=build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sources":["../../src/services/build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chalk from 'chalk';\nimport type { ResolvedConfig } from 'vite';\nimport { resolveConfig } from 'vite';\nimport viteResetCache from '@cli/helpers/vite-reset-cache';\nimport createFocusOnly from '@helpers/create-focus-only';\nimport { createDevMarker } from '@helpers/dev-marker';\nimport type { IPluginConfig } from '@helpers/plugin-config';\nimport getPluginConfig from '@helpers/plugin-config';\nimport processStop from '@helpers/process-stop';\nimport ServerConfig from '@services/server-config';\nimport SsrManifest from '@services/ssr-manifest';\n\nexport interface IBuildParams {\n mode: string;\n onFinish?: () => void;\n clientOptions?: string;\n serverOptions?: string;\n focusOnly?: 'all' | 'app' | 'client' | 'server' | 'entrypoint';\n isWatch?: boolean;\n isUnlockRobots?: boolean;\n isEject?: boolean;\n isServerless?: boolean;\n isNoWarnings?: boolean;\n}\n\ninterface IBuildProcess {\n promise: Promise<number | null | string>;\n command: childProcess.ChildProcess;\n}\n\ninterface ISpawnBuildParams {\n shouldWait?: boolean;\n focusOnly?: IBuildParams['focusOnly'];\n env?: Record<string, string>;\n}\n\nexport interface IBuildEntrypoint {\n // entrypoint name\n name: string;\n type: 'spa' | 'ssr';\n // custom index file, default: indexFile from plugin config\n indexFile?: string;\n // custom entry file for replace in indexFile, default: undefined (do nothing)\n clientFile?: string;\n // custom server file, indexFile and clientFile will be ignored\n serverFile?: string;\n // additional options for vite build command\n buildOptions?: string;\n}\n\n/**\n * Build service\n */\nclass Build {\n /**\n * Is production build\n */\n protected isProd: boolean;\n\n /**\n * Node environment\n */\n protected nodeEnv: string;\n\n /**\n * Build folder\n */\n protected buildDir: string;\n\n /**\n * Vite config\n */\n protected viteConfig: ResolvedConfig;\n\n /**\n * Plugin config\n */\n protected pluginConfig: IPluginConfig;\n\n /**\n * Build params\n */\n protected params: IBuildParams = {\n mode: '',\n clientOptions: '',\n serverOptions: '',\n focusOnly: 'app',\n isWatch: false,\n isUnlockRobots: false,\n isEject: false,\n isServerless: false,\n isNoWarnings: false,\n };\n\n /**\n * Abort controller for builds\n */\n protected abortController: AbortController | null = null;\n\n /**\n * Running builds\n */\n protected runningBuild: { name: string; buildProcess: IBuildProcess }[] = [];\n\n /**\n * Listener for preview has attached\n */\n protected hasPreviewModeExitListener = false;\n\n /**\n * @constructor\n */\n public constructor(params: IBuildParams) {\n this.params = { ...this.params, ...params };\n }\n\n /**\n * Make config\n */\n protected async makeConfig(): Promise<void> {\n const { mode } = this.params;\n\n this.viteConfig = await resolveConfig({}, 'build', mode, 'production');\n this.pluginConfig = getPluginConfig(this.viteConfig);\n this.buildDir = path.resolve(this.viteConfig.root, this.viteConfig.build.outDir);\n this.nodeEnv = process.env.NODE_ENV || 'production';\n this.isProd = this.nodeEnv === 'production';\n }\n\n /**\n * Clear build folder\n */\n public clearBuildFolder(): void {\n // clear build folder\n if (fs.existsSync(this.buildDir)) {\n fs.rmSync(this.buildDir, { recursive: true });\n }\n }\n\n /**\n * Return is prod indicator value\n */\n public getIsProd(): boolean {\n return this.isProd;\n }\n\n /**\n * Return node env value\n */\n public getNodeEnv(): string {\n return this.nodeEnv;\n }\n\n /**\n * Return build names\n */\n public getRunningBuildNames(): string[] {\n return this.runningBuild.map(({ name }) => name);\n }\n\n /**\n * Promisify spawn process\n */\n protected promisifyProcess(\n command: childProcess.ChildProcess,\n isRejectWarnings = false,\n ): IBuildProcess {\n const promise = new Promise<number | null | string>((resolve, reject): void => {\n command.on('exit', (code) => {\n resolve(code);\n });\n\n command.on('close', (code: number): void => {\n resolve(code);\n });\n\n command.on('error', (message: string): void => {\n reject(message);\n });\n\n if (isRejectWarnings) {\n command.stderr?.on('data', (buff: Uint8Array): void => {\n const msg = Buffer.from(buff).toString();\n\n if (msg.includes('warning') || msg.includes('WARNING')) {\n resolve(1);\n }\n });\n }\n });\n\n command.stdout?.pipe(process.stdout);\n command.stderr?.pipe(process.stderr);\n\n return { promise, command };\n }\n\n /**\n * Build assets manifest file\n */\n protected buildManifest(): void {\n console.info(chalk.blue('Building routes manifest file'));\n\n const serverConfig = ServerConfig.init(\n { isProd: this.isProd, mode: this.params.mode },\n { root: this.viteConfig.root, clientFile: this.pluginConfig.clientFile },\n );\n\n SsrManifest.get(serverConfig, {\n buildDir: this.viteConfig.build.outDir,\n viteAliases: this.viteConfig.resolve.alias,\n basename: this.viteConfig.base,\n renderBuiltUrl: this.viteConfig?.experimental?.renderBuiltUrl,\n }).buildRoutesManifest();\n }\n\n /**\n * Change general directive Disallow to Allow in robots.txt.\n */\n protected unlockRobots(): void {\n const robotsFile = `${this.buildDir}/client/robots.txt`;\n\n if (!fs.existsSync(robotsFile)) {\n console.warn(`Failed to unlock robots.txt, file not exist: ${robotsFile}`);\n\n return;\n }\n\n const data = fs\n .readFileSync(robotsFile, { encoding: 'utf-8' })\n .replace(/Disallow: \\/$/m, 'Allow: /');\n\n fs.writeFileSync(robotsFile, data, { encoding: 'utf-8' });\n\n console.info(chalk.blue('\\nrobots.txt unlocked.'));\n }\n\n /**\n * Eject cli to run app via node\n */\n protected eject(): void {\n const entrypoint = `${this.buildDir}/server/start.js`;\n const script =\n \"import runProd from '@lomray/vite-ssr-boost/cli/run-prod.js';\\n\\n\" +\n 'const VERSION = process.env.VERSION || \"1.0.0\";\\n' +\n 'const PORT = process.env.PORT || 3000;\\n' +\n 'const IS_HOST = process.env.IS_HOST || \"0\";\\n' +\n 'const ONLY_CLIENT = process.env.ONLY_CLIENT || \"0\";\\n\\n' +\n `await runProd({\n version: VERSION,\n isHost: IS_HOST === '1',\n isPrintInfo: true,\n port: PORT,\n onlyClient: ONLY_CLIENT === '1',\n });\\n`;\n\n fs.writeFileSync(entrypoint, script, {\n encoding: 'utf-8',\n });\n }\n\n /**\n * Create serverless entrypoint\n */\n protected createServerless(): void {\n const entrypoint = `${this.buildDir}/server/serverless.js`;\n const script =\n \"import runServerless from '@lomray/vite-ssr-boost/cli/run-serverless.js';\\n\\n\" +\n `export default await runServerless({ version: process.env.VERSION || \"1.0.0\" });\\n`;\n\n fs.writeFileSync(entrypoint, script, {\n encoding: 'utf-8',\n });\n }\n\n /**\n * Build specified entrypoint\n */\n protected async spawnBuild(\n name: string,\n buildOptions: string,\n params: ISpawnBuildParams = {},\n ): Promise<void> {\n const { mode, isNoWarnings } = this.params;\n const { focusOnly = this.params.focusOnly, shouldWait = false, env = {} } = params;\n const modeOpt = mode && !buildOptions.includes('--mode') ? `--mode ${mode}` : '';\n\n const buildProcess = this.promisifyProcess(\n childProcess.spawn(`vite build ${buildOptions} ${modeOpt} --emptyOutDir`, {\n signal: this.abortController!.signal,\n stdio: [process.stdin, 'pipe', 'pipe'],\n shell: true,\n env: {\n ...process.env,\n ...env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: createFocusOnly(focusOnly).isOnlyClient() ? '0' : '1',\n SSR_BOOST_ACTION: global.viteBoostAction,\n },\n }),\n isNoWarnings,\n );\n\n this.runningBuild.push({ name, buildProcess });\n\n if (!shouldWait) {\n return;\n }\n\n await this.waitLastBuild();\n }\n\n /**\n * Wait latest build and stop process in case error\n */\n protected async waitLastBuild(): Promise<void> {\n const latestProcess = this.runningBuild.at(-1);\n\n if (!latestProcess) {\n return;\n }\n\n const exitCode = await latestProcess.buildProcess.promise;\n\n processStop(exitCode, true);\n }\n\n /**\n * Run preview mode\n */\n protected runPreviewMode(): void {\n if (!this.hasPreviewModeExitListener) {\n process.on('exit', () => {\n this.abortController!.abort();\n });\n\n this.hasPreviewModeExitListener = true;\n }\n\n const { onFinish } = this.params;\n let buildCount = this.runningBuild.length;\n\n /**\n * Detect finished builds for process\n */\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 this.runningBuild.forEach(({ buildProcess }) => {\n buildProcess.command.stdout?.removeListener('data', listener);\n });\n createDevMarker(this.isProd, this.viteConfig);\n onFinish?.();\n }\n }\n };\n\n /**\n * Listen output for call onFinish\n */\n this.runningBuild.forEach(({ buildProcess }) => {\n buildProcess.command.stdout?.on('data', listener);\n });\n }\n\n /**\n * Run app build\n */\n public async build(): Promise<void> {\n await this.makeConfig();\n // this is required step - build with different env may cause problems\n await viteResetCache();\n this.clearBuildFolder();\n\n const {\n clientOptions,\n serverOptions,\n onFinish,\n isWatch,\n focusOnly,\n isEject,\n isServerless,\n isUnlockRobots,\n } = this.params;\n const { outDir } = this.viteConfig.build;\n const focus = createFocusOnly(focusOnly);\n\n this.abortController = new AbortController();\n this.runningBuild = [];\n\n if (focus.isClient()) {\n /**\n * Build client\n */\n await this.spawnBuild('client', `${clientOptions} --outDir ${outDir}/client`, {\n shouldWait: !isWatch,\n });\n }\n\n /**\n * Build server\n */\n if (focus.isServer()) {\n await this.spawnBuild(\n 'server',\n `${serverOptions} --outDir ${outDir}/server --ssr ${this.pluginConfig.serverFile}`,\n {\n shouldWait: !isWatch,\n },\n );\n\n if (!isWatch) {\n this.buildManifest();\n\n if (isEject) {\n this.eject();\n }\n\n if (isServerless) {\n this.createServerless();\n }\n }\n }\n\n /**\n * Build additional entrypoint\n */\n const { entrypoint } = this.pluginConfig;\n\n if (entrypoint?.length && focus.isEntrypoint()) {\n for (const { name, type, serverFile, buildOptions = '' } of entrypoint) {\n const cliOptions = serverFile && type === 'ssr' ? `--ssr ${serverFile}` : '';\n\n await this.spawnBuild(name, `${buildOptions} ${cliOptions} --outDir ${outDir}/${name}`, {\n shouldWait: !isWatch,\n focusOnly: type === 'ssr' ? 'server' : 'client',\n env: {\n SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME: name,\n },\n });\n }\n }\n\n /**\n * Preview mode\n */\n if (isWatch) {\n this.runPreviewMode();\n\n return;\n }\n\n if (isUnlockRobots) {\n this.unlockRobots();\n }\n\n createDevMarker(this.isProd, this.viteConfig);\n onFinish?.();\n }\n}\n\nexport default Build;\n"],"names":["Build","isProd","nodeEnv","buildDir","viteConfig","pluginConfig","params","mode","clientOptions","serverOptions","focusOnly","isWatch","isUnlockRobots","isEject","isServerless","isNoWarnings","abortController","runningBuild","hasPreviewModeExitListener","constructor","this","async","resolveConfig","getPluginConfig","path","resolve","root","build","outDir","process","env","NODE_ENV","clearBuildFolder","fs","existsSync","rmSync","recursive","getIsProd","getNodeEnv","getRunningBuildNames","map","name","promisifyProcess","command","isRejectWarnings","promise","Promise","reject","on","code","message","stderr","buff","msg","Buffer","from","toString","includes","stdout","pipe","buildManifest","console","info","chalk","blue","serverConfig","ServerConfig","init","clientFile","SsrManifest","get","viteAliases","alias","basename","base","renderBuiltUrl","experimental","buildRoutesManifest","unlockRobots","robotsFile","warn","data","readFileSync","encoding","replace","writeFileSync","eject","entrypoint","createServerless","buildOptions","shouldWait","modeOpt","buildProcess","childProcess","spawn","signal","stdio","stdin","shell","FORCE_COLOR","SSR_BOOST_IS_SSR","createFocusOnly","isOnlyClient","SSR_BOOST_ACTION","global","viteBoostAction","push","waitLastBuild","latestProcess","at","exitCode","processStop","runPreviewMode","abort","onFinish","buildCount","length","listener","forEach","removeListener","createDevMarker","makeConfig","viteResetCache","focus","AbortController","isClient","spawnBuild","isServer","serverFile","isEntrypoint","type","cliOptions","SSR_BOOST_CUSTOM_ENTRYPO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A,GACEQ,KAAKd,QACHsB,OAAEA,GAAWR,KAAKhB,WAAWuB,MAC7BgG,EAAQtB,EAAgB3F,GAE9BU,KAAKJ,gBAAkB,IAAI4G,gBAC3BxG,KAAKH,aAAe,GAEhB0G,EAAME,kBAIFzG,KAAK0G,WAAW,SAAU,GAAGtH,cAA0BoB,WAAiB,CAC5E8D,YAAa/E,IAObgH,EAAMI,mBACF3G,KAAK0G,WACT,SACA,GAAGrH,cAA0BmB,kBAAuBR,KAAKf,aAAa2H,aACtE,CACEtC,YAAa/E,IAIZA,IACHS,KAAKwC,gBAED/C,GACFO,KAAKkE,QAGHxE,GACFM,KAAKoE,qBAQX,MAAMD,WAAEA,GAAenE,KAAKf,aAE5B,GAAIkF,GAAY6B,QAAUO,EAAMM,eAC9B,IAAK,MAAMxF,KAAEA,EAAIyF,KAAEA,EAAIF,WAAEA,EAAUvC,aAAEA,EAAe,MAAQF,EAAY,CACtE,MAAM4C,EAAaH,GAAuB,QAATE,EAAiB,SAASF,IAAe,SAEpE5G,KAAK0G,WAAWrF,EAAM,GAAGgD,KAAgB0C,cAAuBvG,KAAUa,IAAQ,CACtFiD,YAAa/E,EACbD,UAAoB,QAATwH,EAAiB,SAAW,SACvCpG,IAAK,CACHsG,uCAAwC3F,IAG9C,CAME9B,EACFS,KAAK4F,kBAKHpG,GACFQ,KAAK0D,eAGP0C,EAAgBpG,KAAKnB,OAAQmB,KAAKhB,YAClC8G,MACF"}
1
+ {"version":3,"file":"build.js","sources":["../../src/services/build.ts"],"sourcesContent":[null],"names":["Build","isProd","nodeEnv","buildDir","viteConfig","pluginConfig","params","mode","clientOptions","serverOptions","focusOnly","isWatch","isUnlockRobots","isEject","isServerless","isNoWarnings","abortController","runningBuild","hasPreviewModeExitListener","constructor","this","makeConfig","resolveConfig","getPluginConfig","path","resolve","root","build","outDir","process","env","NODE_ENV","clearBuildFolder","fs","existsSync","rmSync","recursive","getIsProd","getNodeEnv","getRunningBuildNames","map","name","promisifyProcess","command","isRejectWarnings","promise","Promise","reject","on","code","message","stderr","buff","msg","Buffer","from","toString","includes","stdout","pipe","buildManifest","console","info","chalk","blue","serverConfig","ServerConfig","init","clientFile","SsrManifest","get","viteAliases","alias","basename","base","renderBuiltUrl","experimental","buildRoutesManifest","unlockRobots","robotsFile","warn","data","readFileSync","encoding","replace","writeFileSync","eject","entrypoint","createServerless","spawnBuild","buildOptions","shouldWait","modeOpt","buildProcess","childProcess","spawn","signal","stdio","stdin","shell","FORCE_COLOR","SSR_BOOST_IS_SSR","createFocusOnly","isOnlyClient","SSR_BOOST_ACTION","global","viteBoostAction","push","waitLastBuild","latestProcess","at","exitCode","processStop","runPreviewMode","abort","onFinish","buildCount","length","listener","forEach","removeListener","createDevMarker","viteResetCache","focus","AbortController","isClient","isServer","serverFile","isEntrypoint","type","cliOptions","SSR_BOOST_CUSTOM_ENTRYPOINT_BUILD_NAME"],"mappings":"gcAwDA,MAAMA,EAIMC,OAKAC,QAKAC,SAKAC,WAKAC,aAKAC,OAAuB,CAC/BC,KAAM,GACNC,cAAe,GACfC,cAAe,GACfC,UAAW,MACXC,SAAS,EACTC,gBAAgB,EAChBC,SAAS,EACTC,cAAc,EACdC,cAAc,GAMNC,gBAA0C,KAK1CC,aAAgE,GAKhEC,4BAA6B,EAKvC,WAAAC,CAAmBb,GACjBc,KAAKd,OAAS,IAAKc,KAAKd,UAAWA,EACrC,CAKU,gBAAMe,GACd,MAAMd,KAAEA,GAASa,KAAKd,OAEtBc,KAAKhB,iBAAmBkB,EAAc,CAAA,EAAI,QAASf,EAAM,cACzDa,KAAKf,aAAekB,EAAgBH,KAAKhB,YACzCgB,KAAKjB,SAAWqB,EAAKC,QAAQL,KAAKhB,WAAWsB,KAAMN,KAAKhB,WAAWuB,MAAMC,QACzER,KAAKlB,QAAU2B,QAAQC,IAAIC,UAAY,aACvCX,KAAKnB,OAA0B,eAAjBmB,KAAKlB,OACrB,CAKO,gBAAA8B,GAEDC,EAAGC,WAAWd,KAAKjB,WACrB8B,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