@lomray/vite-ssr-boost 4.0.0-beta.1 → 4.0.0-beta.3

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 (44) hide show
  1. package/cli/helpers/keyboard-input.js.map +1 -1
  2. package/cli/helpers/vite-reset-cache.js.map +1 -1
  3. package/cli/run-amplify-build.js.map +1 -1
  4. package/cli/run-docker-build.js.map +1 -1
  5. package/cli/run-vercel-build.js.map +1 -1
  6. package/cli.js.map +1 -1
  7. package/components/navigate.js.map +1 -1
  8. package/helpers/dev-marker.js.map +1 -1
  9. package/helpers/get-server-state.js.map +1 -1
  10. package/helpers/import-route.d.ts +1 -1
  11. package/helpers/import-route.js +1 -1
  12. package/helpers/import-route.js.map +1 -1
  13. package/helpers/print-server-info.js.map +1 -1
  14. package/helpers/resolve-server-urls.js.map +1 -1
  15. package/helpers/serialize-errors.js.map +1 -1
  16. package/node/render.js.map +1 -1
  17. package/node/server.js.map +1 -1
  18. package/node/write-response.js.map +1 -1
  19. package/package.json +19 -18
  20. package/plugin.d.ts +0 -1
  21. package/plugin.js +1 -1
  22. package/plugin.js.map +1 -1
  23. package/plugins/handle-custom-entrypoint.js.map +1 -1
  24. package/plugins/make-aliases.js.map +1 -1
  25. package/plugins/normalize-route.d.ts +0 -3
  26. package/plugins/normalize-route.js +1 -1
  27. package/plugins/normalize-route.js.map +1 -1
  28. package/services/build.d.ts +1 -8
  29. package/services/build.js +1 -1
  30. package/services/build.js.map +1 -1
  31. package/services/logger.js.map +1 -1
  32. package/services/parse-routes.d.ts +5 -3
  33. package/services/parse-routes.js +1 -1
  34. package/services/parse-routes.js.map +1 -1
  35. package/services/path-normalize.js.map +1 -1
  36. package/services/prepare-server.js.map +1 -1
  37. package/services/server-api.js.map +1 -1
  38. package/services/server-config.js.map +1 -1
  39. package/services/ssr-manifest.d.ts +2 -9
  40. package/services/ssr-manifest.js +1 -1
  41. package/services/ssr-manifest.js.map +1 -1
  42. package/helpers/ssr-meta.d.ts +0 -18
  43. package/helpers/ssr-meta.js +0 -2
  44. package/helpers/ssr-meta.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"keyboard-input.js","sources":["../../../src/cli/helpers/keyboard-input.ts"],"sourcesContent":["import chalk from 'chalk';\nimport cliContext from '@constants/cli-context';\nimport defaultShortcuts from '@constants/cli-shortcuts';\nimport getPluginConfig from '@helpers/plugin-config';\nimport processStop from '@helpers/process-stop';\n\nlet isActionRunning = false;\n\n/**\n * Handle keyboard press buttons\n */\nfunction onKeyPress(input: string): void {\n void runAction(input);\n}\n\n/**\n * Run shortcut\n */\nasync function runAction(input: string): Promise<void> {\n // ctrl+c or ctrl+d\n if (input === '\\x03' || input === '\\x04') {\n if (!cliContext.server?.close((e) => processStop(e ? 1 : 0))) {\n processStop();\n }\n\n return;\n }\n\n if (isActionRunning) {\n return;\n }\n\n const { config } = cliContext;\n const Logger = config?.getLogger();\n const { customShortcuts = [] } =\n typeof config?.getVite()?.config === 'object' ? getPluginConfig(config.getVite()!.config) : {};\n\n const shortcuts = customShortcuts\n .filter(Boolean)\n .concat(defaultShortcuts)\n .filter(({ isOnlyDev = false }) => !isOnlyDev || (isOnlyDev && !config?.isProd));\n\n // print empty line\n if (input === '\\r') {\n return Logger?.info('\\r');\n }\n\n // print help\n if (input === 'h') {\n Logger?.info(\n [\n '',\n chalk.bold(' Shortcuts'),\n ...shortcuts.map(\n (shortcut) =>\n chalk.dim(' press ') +\n chalk.bold(shortcut.key) +\n chalk.dim(` to ${shortcut.description}`),\n ),\n ].join('\\n'),\n );\n }\n\n // execute shortcut command\n const shortcut = shortcuts.find(({ key }) => key === input);\n\n if (!shortcut) {\n return;\n }\n\n isActionRunning = true;\n await shortcut.action(cliContext);\n isActionRunning = false;\n}\n\nexport default onKeyPress;\n"],"names":["isActionRunning","onKeyPress","input","async","cliContext","server","close","e","processStop","config","Logger","getLogger","customShortcuts","getVite","getPluginConfig","shortcuts","filter","Boolean","concat","defaultShortcuts","isOnlyDev","isProd","info","chalk","bold","map","shortcut","dim","key","description","join","find","action","runAction"],"mappings":"8MAMA,IAAIA,GAAkB,EAKtB,SAASC,EAAWC,IAOpBC,eAAyBD,GAEvB,GAAc,MAAVA,GAA8B,MAAVA,EAKtB,YAJKE,EAAWC,QAAQC,OAAOC,GAAMC,EAAYD,EAAI,EAAI,MACvDC,KAMJ,GAAIR,EACF,OAGF,MAAMS,OAAEA,GAAWL,EACbM,EAASD,GAAQE,aACjBC,gBAAEA,EAAkB,IACa,iBAA9BH,GAAQI,WAAWJ,OAAsBK,EAAgBL,EAAOI,UAAWJ,QAAU,CAAA,EAExFM,EAAYH,EACfI,OAAOC,SACPC,OAAOC,GACPH,QAAO,EAAGI,aAAY,MAAaA,GAAcA,IAAcX,GAAQY,SAG1E,GAAc,OAAVnB,EACF,OAAOQ,GAAQY,KAAK,MAIR,MAAVpB,GACFQ,GAAQY,KACN,CACE,GACAC,EAAMC,KAAK,kBACRT,EAAUU,KACVC,GACCH,EAAMI,IAAI,YACVJ,EAAMC,KAAKE,EAASE,KACpBL,EAAMI,IAAI,OAAOD,EAASG,kBAE9BC,KAAK,OAKX,MAAMJ,EAAWX,EAAUgB,MAAK,EAAGH,SAAUA,IAAQ1B,IAErD,IAAKwB,EACH,OAGF1B,GAAkB,QACZ0B,EAASM,OAAO5B,GACtBJ,GAAkB,CACpB,CA7DOiC,CAAU/B,EACjB"}
1
+ {"version":3,"file":"keyboard-input.js","sources":["../../../src/cli/helpers/keyboard-input.ts"],"sourcesContent":["import chalk from 'chalk';\nimport cliContext from '@constants/cli-context';\nimport defaultShortcuts from '@constants/cli-shortcuts';\nimport getPluginConfig from '@helpers/plugin-config';\nimport processStop from '@helpers/process-stop';\n\nlet isActionRunning = false;\n\n/**\n * Handle keyboard press buttons\n */\nfunction onKeyPress(input: string): void {\n void runAction(input);\n}\n\n/**\n * Run shortcut\n */\nasync function runAction(input: string): Promise<void> {\n // ctrl+c or ctrl+d\n if (input === '\\x03' || input === '\\x04') {\n if (!cliContext.server?.close((e) => processStop(e ? 1 : 0))) {\n processStop();\n }\n\n return;\n }\n\n if (isActionRunning) {\n return;\n }\n\n const { config } = cliContext;\n const Logger = config?.getLogger();\n const { customShortcuts = [] } =\n typeof config?.getVite()?.config === 'object' ? getPluginConfig(config.getVite()!.config) : {};\n\n const shortcuts = customShortcuts\n .filter(Boolean)\n .concat(defaultShortcuts)\n .filter(({ isOnlyDev = false }) => !isOnlyDev || (isOnlyDev && !config?.isProd));\n\n // print empty line\n if (input === '\\r') {\n return Logger?.info('\\r');\n }\n\n // print help\n if (input === 'h') {\n Logger?.info(\n [\n '',\n chalk.bold(' Shortcuts'),\n ...shortcuts.map(\n (shortcut) =>\n chalk.dim(' press ') +\n chalk.bold(shortcut.key) +\n chalk.dim(` to ${shortcut.description}`),\n ),\n ].join('\\n'),\n );\n }\n\n // execute shortcut command\n const shortcut = shortcuts.find(({ key }) => key === input);\n\n if (!shortcut) {\n return;\n }\n\n isActionRunning = true;\n await shortcut.action(cliContext);\n isActionRunning = false;\n}\n\nexport default onKeyPress;\n"],"names":["isActionRunning","onKeyPress","input","async","cliContext","server","close","e","processStop","config","Logger","getLogger","customShortcuts","getVite","getPluginConfig","shortcuts","filter","Boolean","concat","defaultShortcuts","isOnlyDev","isProd","info","chalk","bold","map","shortcut","dim","key","description","join","find","action","runAction"],"mappings":"8MAMA,IAAIA,GAAkB,EAKtB,SAASC,EAAWC,IAOpBC,eAAyBD,GAEvB,GAAc,MAAVA,GAA8B,MAAVA,EAKtB,YAJKE,EAAWC,QAAQC,OAAOC,GAAMC,EAAYD,EAAI,EAAI,MACvDC,KAMJ,GAAIR,EACF,OAGF,MAAMS,OAAEA,GAAWL,EACbM,EAASD,GAAQE,aACjBC,gBAAEA,EAAkB,IACa,iBAA9BH,GAAQI,WAAWJ,OAAsBK,EAAgBL,EAAOI,UAAWJ,QAAU,CAAE,EAE1FM,EAAYH,EACfI,OAAOC,SACPC,OAAOC,GACPH,QAAO,EAAGI,aAAY,MAAaA,GAAcA,IAAcX,GAAQY,SAG1E,GAAc,OAAVnB,EACF,OAAOQ,GAAQY,KAAK,MAIR,MAAVpB,GACFQ,GAAQY,KACN,CACE,GACAC,EAAMC,KAAK,kBACRT,EAAUU,KACVC,GACCH,EAAMI,IAAI,YACVJ,EAAMC,KAAKE,EAASE,KACpBL,EAAMI,IAAI,OAAOD,EAASG,kBAE9BC,KAAK,OAKX,MAAMJ,EAAWX,EAAUgB,MAAK,EAAGH,SAAUA,IAAQ1B,IAErD,IAAKwB,EACH,OAGF1B,GAAkB,QACZ0B,EAASM,OAAO5B,GACtBJ,GAAkB,CACpB,CA7DOiC,CAAU/B,EACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-reset-cache.js","sources":["../../../src/cli/helpers/vite-reset-cache.ts"],"sourcesContent":["import fs from 'node:fs';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\n\n/**\n * Reset vite cache\n */\nasync function viteResetCache(): Promise<void> {\n const config = await resolveConfig({}, 'build');\n const { cacheDir } = config;\n\n if (fs.existsSync(cacheDir)) {\n fs.rmSync(cacheDir, { recursive: true, force: true });\n }\n\n console.info(chalk.dim(chalk.yellowBright('vite cache cleared.')));\n}\n\nexport default viteResetCache;\n"],"names":["async","viteResetCache","config","resolveConfig","cacheDir","fs","existsSync","rmSync","recursive","force","console","info","chalk","dim","yellowBright"],"mappings":"iFAOAA,eAAeC,IACb,MAAMC,QAAeC,EAAc,CAAE,EAAE,UACjCC,SAAEA,GAAaF,EAEjBG,EAAGC,WAAWF,IAChBC,EAAGE,OAAOH,EAAU,CAAEI,WAAW,EAAMC,OAAO,IAGhDC,QAAQC,KAAKC,EAAMC,IAAID,EAAME,aAAa,wBAC5C"}
1
+ {"version":3,"file":"vite-reset-cache.js","sources":["../../../src/cli/helpers/vite-reset-cache.ts"],"sourcesContent":["import fs from 'node:fs';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\n\n/**\n * Reset vite cache\n */\nasync function viteResetCache(): Promise<void> {\n const config = await resolveConfig({}, 'build');\n const { cacheDir } = config;\n\n if (fs.existsSync(cacheDir)) {\n fs.rmSync(cacheDir, { recursive: true, force: true });\n }\n\n console.info(chalk.dim(chalk.yellowBright('vite cache cleared.')));\n}\n\nexport default viteResetCache;\n"],"names":["async","viteResetCache","config","resolveConfig","cacheDir","fs","existsSync","rmSync","recursive","force","console","info","chalk","dim","yellowBright"],"mappings":"iFAOAA,eAAeC,IACb,MAAMC,QAAeC,EAAc,CAAA,EAAI,UACjCC,SAAEA,GAAaF,EAEjBG,EAAGC,WAAWF,IAChBC,EAAGE,OAAOH,EAAU,CAAEI,WAAW,EAAMC,OAAO,IAGhDC,QAAQC,KAAKC,EAAMC,IAAID,EAAME,aAAa,wBAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"run-amplify-build.js","sources":["../../src/cli/run-amplify-build.ts"],"sourcesContent":["import type { ExecSyncOptions } from 'child_process';\nimport childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunAmplifyBuildParams {\n manifestFile?: string;\n mode?: string;\n isOptimize?: boolean;\n}\n\n/**\n * Create AWS Amplify SSR build\n */\nasync function runAmplifyBuild({\n manifestFile,\n mode = '',\n isOptimize = false,\n}: IRunAmplifyBuildParams): Promise<void> {\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 manFile = manifestFile || `${pluginConfig.pluginPath}/workflow/amplify-manifest.json`;\n const amplifyDir = `${projectRoot}/.amplify-hosting`;\n const computeDir = `${amplifyDir}/compute/default`;\n const stdOpts: ExecSyncOptions = {\n stdio: 'inherit',\n };\n\n // Check build server\n if (!fs.existsSync(`${buildDir}/server/start.js`)) {\n console.error(\n chalk.red(\n 'Failed create Amplify build: Before, you should create standard build with `eject` option.',\n ),\n );\n\n return;\n }\n\n if (fs.existsSync(amplifyDir)) {\n childProcess.execSync(`rm -rf ${amplifyDir}`, stdOpts);\n }\n\n fs.mkdirSync(computeDir, { recursive: true });\n childProcess.execSync(`cp -r ${buildDir} ${computeDir}/build`, stdOpts);\n childProcess.execSync(`cp ${projectRoot}/package.json ${computeDir}/package.json`, stdOpts);\n childProcess.execSync(\n `cp ${projectRoot}/package-lock.json ${computeDir}/package-lock.json`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir}/client ${amplifyDir}/static`, stdOpts);\n childProcess.execSync(`cp ${manFile} ${amplifyDir}/deploy-manifest.json`, stdOpts);\n childProcess.execSync(`cp -r ${projectRoot}/node_modules ${computeDir}/node_modules`);\n\n if (isOptimize) {\n childProcess.execSync(`cd ${computeDir} && npm ci --omit=dev`, stdOpts);\n }\n\n // cleanup\n childProcess.execSync(`rm -rf ${computeDir}/build/client/assets`, stdOpts);\n\n console.info(`\\n${chalk.cyan('AWS Amplify build success created.')}`);\n}\n\nexport default runAmplifyBuild;\n"],"names":["async","runAmplifyBuild","manifestFile","mode","isOptimize","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","manFile","pluginPath","amplifyDir","computeDir","stdOpts","stdio","fs","existsSync","childProcess","execSync","mkdirSync","recursive","console","info","chalk","cyan","error","red"],"mappings":"0NAkBAA,eAAeC,GAAgBC,aAC7BA,EAAYC,KACZA,EAAO,GAAEC,WACTA,GAAa,IAEb,MAAMC,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,EAAUhB,GAAgB,GAAGK,EAAaY,4CAC1CC,EAAa,GAAGR,qBAChBS,EAAa,GAAGD,oBAChBE,EAA2B,CAC/BC,MAAO,WAIJC,EAAGC,WAAW,GAAGX,sBAUlBU,EAAGC,WAAWL,IAChBM,EAAaC,SAAS,UAAUP,IAAcE,GAGhDE,EAAGI,UAAUP,EAAY,CAAEQ,WAAW,IACtCH,EAAaC,SAAS,SAASb,KAAYO,UAAoBC,GAC/DI,EAAaC,SAAS,MAAMf,kBAA4BS,iBAA2BC,GACnFI,EAAaC,SACX,MAAMf,uBAAiCS,sBACvCC,GAEFI,EAAaC,SAAS,SAASb,YAAmBM,WAAqBE,GACvEI,EAAaC,SAAS,MAAMT,KAAWE,yBAAmCE,GAC1EI,EAAaC,SAAS,SAASf,kBAA4BS,kBAEvDjB,GACFsB,EAAaC,SAAS,MAAMN,yBAAmCC,GAIjEI,EAAaC,SAAS,UAAUN,wBAAkCC,GAElEQ,QAAQC,KAAK,KAAKC,EAAMC,KAAK,0CA/B3BH,QAAQI,MACNF,EAAMG,IACJ,8FA8BR"}
1
+ {"version":3,"file":"run-amplify-build.js","sources":["../../src/cli/run-amplify-build.ts"],"sourcesContent":["import type { ExecSyncOptions } from 'child_process';\nimport childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunAmplifyBuildParams {\n manifestFile?: string;\n mode?: string;\n isOptimize?: boolean;\n}\n\n/**\n * Create AWS Amplify SSR build\n */\nasync function runAmplifyBuild({\n manifestFile,\n mode = '',\n isOptimize = false,\n}: IRunAmplifyBuildParams): Promise<void> {\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 manFile = manifestFile || `${pluginConfig.pluginPath}/workflow/amplify-manifest.json`;\n const amplifyDir = `${projectRoot}/.amplify-hosting`;\n const computeDir = `${amplifyDir}/compute/default`;\n const stdOpts: ExecSyncOptions = {\n stdio: 'inherit',\n };\n\n // Check build server\n if (!fs.existsSync(`${buildDir}/server/start.js`)) {\n console.error(\n chalk.red(\n 'Failed create Amplify build: Before, you should create standard build with `eject` option.',\n ),\n );\n\n return;\n }\n\n if (fs.existsSync(amplifyDir)) {\n childProcess.execSync(`rm -rf ${amplifyDir}`, stdOpts);\n }\n\n fs.mkdirSync(computeDir, { recursive: true });\n childProcess.execSync(`cp -r ${buildDir} ${computeDir}/build`, stdOpts);\n childProcess.execSync(`cp ${projectRoot}/package.json ${computeDir}/package.json`, stdOpts);\n childProcess.execSync(\n `cp ${projectRoot}/package-lock.json ${computeDir}/package-lock.json`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir}/client ${amplifyDir}/static`, stdOpts);\n childProcess.execSync(`cp ${manFile} ${amplifyDir}/deploy-manifest.json`, stdOpts);\n childProcess.execSync(`cp -r ${projectRoot}/node_modules ${computeDir}/node_modules`);\n\n if (isOptimize) {\n childProcess.execSync(`cd ${computeDir} && npm ci --omit=dev`, stdOpts);\n }\n\n // cleanup\n childProcess.execSync(`rm -rf ${computeDir}/build/client/assets`, stdOpts);\n\n console.info(`\\n${chalk.cyan('AWS Amplify build success created.')}`);\n}\n\nexport default runAmplifyBuild;\n"],"names":["async","runAmplifyBuild","manifestFile","mode","isOptimize","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","manFile","pluginPath","amplifyDir","computeDir","stdOpts","stdio","fs","existsSync","childProcess","execSync","mkdirSync","recursive","console","info","chalk","cyan","error","red"],"mappings":"0NAkBAA,eAAeC,GAAgBC,aAC7BA,EAAYC,KACZA,EAAO,GAAEC,WACTA,GAAa,IAEb,MAAMC,QAAeC,EAAc,CAAA,EAAI,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUhB,GAAgB,GAAGK,EAAaY,4CAC1CC,EAAa,GAAGR,qBAChBS,EAAa,GAAGD,oBAChBE,EAA2B,CAC/BC,MAAO,WAIJC,EAAGC,WAAW,GAAGX,sBAUlBU,EAAGC,WAAWL,IAChBM,EAAaC,SAAS,UAAUP,IAAcE,GAGhDE,EAAGI,UAAUP,EAAY,CAAEQ,WAAW,IACtCH,EAAaC,SAAS,SAASb,KAAYO,UAAoBC,GAC/DI,EAAaC,SAAS,MAAMf,kBAA4BS,iBAA2BC,GACnFI,EAAaC,SACX,MAAMf,uBAAiCS,sBACvCC,GAEFI,EAAaC,SAAS,SAASb,YAAmBM,WAAqBE,GACvEI,EAAaC,SAAS,MAAMT,KAAWE,yBAAmCE,GAC1EI,EAAaC,SAAS,SAASf,kBAA4BS,kBAEvDjB,GACFsB,EAAaC,SAAS,MAAMN,yBAAmCC,GAIjEI,EAAaC,SAAS,UAAUN,wBAAkCC,GAElEQ,QAAQC,KAAK,KAAKC,EAAMC,KAAK,0CA/B3BH,QAAQI,MACNF,EAAMG,IACJ,8FA8BR"}
@@ -1 +1 @@
1
- {"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport createFocusOnly from '@helpers/create-focus-only';\nimport getPluginConfig from '@helpers/plugin-config';\nimport type { IBuildParams } from '@services/build';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n focusOnly?: IBuildParams['focusOnly'];\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n focusOnly,\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 = createFocusOnly(focusOnly).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","focusOnly","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","createFocusOnly","isOnlyClient","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"6NAmBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,UACVA,EAASC,cACTA,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,EAAUC,EAAgBlB,GAAWmB,eAAiB,MAAQ,MAC9DC,EAAUrB,GAAc,GAAGO,EAAae,iCAE9CC,EAAaC,SACX,mBAAmBH,4BACUP,0BACFI,0BAAgCd,KACrDF,QAAoBH,KAAaa,IACvC,CACEa,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
1
+ {"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport createFocusOnly from '@helpers/create-focus-only';\nimport getPluginConfig from '@helpers/plugin-config';\nimport type { IBuildParams } from '@services/build';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n focusOnly?: IBuildParams['focusOnly'];\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n focusOnly,\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 = createFocusOnly(focusOnly).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","focusOnly","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","createFocusOnly","isOnlyClient","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"6NAmBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,UACVA,EAASC,cACTA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAmB,eAATD,EAAwB,aAAe,cACjDE,QAAeC,EAAc,CAAA,EAAI,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUC,EAAgBlB,GAAWmB,eAAiB,MAAQ,MAC9DC,EAAUrB,GAAc,GAAGO,EAAae,iCAE9CC,EAAaC,SACX,mBAAmBH,4BACUP,0BACFI,0BAAgCd,KACrDF,QAAoBH,KAAaa,IACvC,CACEa,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
@@ -1 +1 @@
1
- {"version":3,"file":"run-vercel-build.js","sources":["../../src/cli/run-vercel-build.ts"],"sourcesContent":["import type { ExecSyncOptions } from 'child_process';\nimport childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunVercelBuildParams {\n configFile?: string;\n configVcFile?: string;\n mode?: string;\n isOptimize?: boolean;\n}\n\n/**\n * Create Vercel SSR build\n */\nasync function runVercelBuild({\n configFile,\n configVcFile,\n mode = '',\n isOptimize = false,\n}: IRunVercelBuildParams): Promise<void> {\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 manFile = configFile || `${pluginConfig.pluginPath}/workflow/vercel.config.json`;\n const manVcFile = configVcFile || `${pluginConfig.pluginPath}/workflow/vercel.vc-config.json`;\n const outputDir = `${projectRoot}/.vercel/output`;\n const stdOpts: ExecSyncOptions = {\n stdio: 'inherit',\n };\n\n // Check build serverless\n if (!fs.existsSync(`${buildDir}/server/serverless.js`)) {\n console.error(\n chalk.red(\n 'Failed create Vercel build: Before, you should create standard build with `serverless` option.',\n ),\n );\n\n return;\n }\n\n if (fs.existsSync(outputDir)) {\n childProcess.execSync(`rm -rf ${outputDir}`, stdOpts);\n }\n\n fs.mkdirSync(outputDir, { recursive: true });\n fs.mkdirSync(`${outputDir}/functions/index.func`, { recursive: true });\n childProcess.execSync(`cp ${manFile} ${outputDir}/config.json`, stdOpts);\n childProcess.execSync(\n `cp ${manVcFile} ${outputDir}/functions/index.func/.vc-config.json`,\n stdOpts,\n );\n childProcess.execSync(\n `cp ${buildDir}/server/serverless.js ${outputDir}/functions/index.func/index.js`,\n stdOpts,\n );\n childProcess.execSync(\n `cp -r ${projectRoot}/node_modules ${outputDir}/functions/index.func/node_modules`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir} ${outputDir}/functions/index.func/build`, stdOpts);\n childProcess.execSync(\n `cp -r ${projectRoot}/package.json ${outputDir}/functions/index.func/package.json`,\n stdOpts,\n );\n childProcess.execSync(\n `cp -r ${projectRoot}/package-lock.json ${outputDir}/functions/index.func/package-lock.json`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir}/client ${outputDir}/static`, stdOpts);\n\n if (isOptimize) {\n childProcess.execSync(`cd ${outputDir}/functions/index.func && npm ci --omit=dev`, stdOpts);\n }\n\n console.info(`\\n${chalk.cyan('Vercel build success created.')}`);\n}\n\nexport default runVercelBuild;\n"],"names":["async","runVercelBuild","configFile","configVcFile","mode","isOptimize","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","manFile","pluginPath","manVcFile","outputDir","stdOpts","stdio","fs","existsSync","childProcess","execSync","mkdirSync","recursive","console","info","chalk","cyan","error","red"],"mappings":"0NAmBAA,eAAeC,GAAeC,WAC5BA,EAAUC,aACVA,EAAYC,KACZA,EAAO,GAAEC,WACTA,GAAa,IAEb,MAAMC,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,GAAc,GAAGM,EAAaY,yCACxCC,EAAYlB,GAAgB,GAAGK,EAAaY,4CAC5CE,EAAY,GAAGT,mBACfU,EAA2B,CAC/BC,MAAO,WAIJC,EAAGC,WAAW,GAAGX,2BAUlBU,EAAGC,WAAWJ,IAChBK,EAAaC,SAAS,UAAUN,IAAaC,GAG/CE,EAAGI,UAAUP,EAAW,CAAEQ,WAAW,IACrCL,EAAGI,UAAU,GAAGP,yBAAkC,CAAEQ,WAAW,IAC/DH,EAAaC,SAAS,MAAMT,KAAWG,gBAAyBC,GAChEI,EAAaC,SACX,MAAMP,KAAaC,yCACnBC,GAEFI,EAAaC,SACX,MAAMb,0BAAiCO,kCACvCC,GAEFI,EAAaC,SACX,SAASf,kBAA4BS,sCACrCC,GAEFI,EAAaC,SAAS,SAASb,KAAYO,+BAAwCC,GACnFI,EAAaC,SACX,SAASf,kBAA4BS,sCACrCC,GAEFI,EAAaC,SACX,SAASf,uBAAiCS,2CAC1CC,GAEFI,EAAaC,SAAS,SAASb,YAAmBO,WAAoBC,GAElElB,GACFsB,EAAaC,SAAS,MAAMN,8CAAuDC,GAGrFQ,QAAQC,KAAK,KAAKC,EAAMC,KAAK,qCA3C3BH,QAAQI,MACNF,EAAMG,IACJ,kGA0CR"}
1
+ {"version":3,"file":"run-vercel-build.js","sources":["../../src/cli/run-vercel-build.ts"],"sourcesContent":["import type { ExecSyncOptions } from 'child_process';\nimport childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunVercelBuildParams {\n configFile?: string;\n configVcFile?: string;\n mode?: string;\n isOptimize?: boolean;\n}\n\n/**\n * Create Vercel SSR build\n */\nasync function runVercelBuild({\n configFile,\n configVcFile,\n mode = '',\n isOptimize = false,\n}: IRunVercelBuildParams): Promise<void> {\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 manFile = configFile || `${pluginConfig.pluginPath}/workflow/vercel.config.json`;\n const manVcFile = configVcFile || `${pluginConfig.pluginPath}/workflow/vercel.vc-config.json`;\n const outputDir = `${projectRoot}/.vercel/output`;\n const stdOpts: ExecSyncOptions = {\n stdio: 'inherit',\n };\n\n // Check build serverless\n if (!fs.existsSync(`${buildDir}/server/serverless.js`)) {\n console.error(\n chalk.red(\n 'Failed create Vercel build: Before, you should create standard build with `serverless` option.',\n ),\n );\n\n return;\n }\n\n if (fs.existsSync(outputDir)) {\n childProcess.execSync(`rm -rf ${outputDir}`, stdOpts);\n }\n\n fs.mkdirSync(outputDir, { recursive: true });\n fs.mkdirSync(`${outputDir}/functions/index.func`, { recursive: true });\n childProcess.execSync(`cp ${manFile} ${outputDir}/config.json`, stdOpts);\n childProcess.execSync(\n `cp ${manVcFile} ${outputDir}/functions/index.func/.vc-config.json`,\n stdOpts,\n );\n childProcess.execSync(\n `cp ${buildDir}/server/serverless.js ${outputDir}/functions/index.func/index.js`,\n stdOpts,\n );\n childProcess.execSync(\n `cp -r ${projectRoot}/node_modules ${outputDir}/functions/index.func/node_modules`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir} ${outputDir}/functions/index.func/build`, stdOpts);\n childProcess.execSync(\n `cp -r ${projectRoot}/package.json ${outputDir}/functions/index.func/package.json`,\n stdOpts,\n );\n childProcess.execSync(\n `cp -r ${projectRoot}/package-lock.json ${outputDir}/functions/index.func/package-lock.json`,\n stdOpts,\n );\n childProcess.execSync(`cp -r ${buildDir}/client ${outputDir}/static`, stdOpts);\n\n if (isOptimize) {\n childProcess.execSync(`cd ${outputDir}/functions/index.func && npm ci --omit=dev`, stdOpts);\n }\n\n console.info(`\\n${chalk.cyan('Vercel build success created.')}`);\n}\n\nexport default runVercelBuild;\n"],"names":["async","runVercelBuild","configFile","configVcFile","mode","isOptimize","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","manFile","pluginPath","manVcFile","outputDir","stdOpts","stdio","fs","existsSync","childProcess","execSync","mkdirSync","recursive","console","info","chalk","cyan","error","red"],"mappings":"0NAmBAA,eAAeC,GAAeC,WAC5BA,EAAUC,aACVA,EAAYC,KACZA,EAAO,GAAEC,WACTA,GAAa,IAEb,MAAMC,QAAeC,EAAc,CAAA,EAAI,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,GAAc,GAAGM,EAAaY,yCACxCC,EAAYlB,GAAgB,GAAGK,EAAaY,4CAC5CE,EAAY,GAAGT,mBACfU,EAA2B,CAC/BC,MAAO,WAIJC,EAAGC,WAAW,GAAGX,2BAUlBU,EAAGC,WAAWJ,IAChBK,EAAaC,SAAS,UAAUN,IAAaC,GAG/CE,EAAGI,UAAUP,EAAW,CAAEQ,WAAW,IACrCL,EAAGI,UAAU,GAAGP,yBAAkC,CAAEQ,WAAW,IAC/DH,EAAaC,SAAS,MAAMT,KAAWG,gBAAyBC,GAChEI,EAAaC,SACX,MAAMP,KAAaC,yCACnBC,GAEFI,EAAaC,SACX,MAAMb,0BAAiCO,kCACvCC,GAEFI,EAAaC,SACX,SAASf,kBAA4BS,sCACrCC,GAEFI,EAAaC,SAAS,SAASb,KAAYO,+BAAwCC,GACnFI,EAAaC,SACX,SAASf,kBAA4BS,sCACrCC,GAEFI,EAAaC,SACX,SAASf,uBAAiCS,2CAC1CC,GAEFI,EAAaC,SAAS,SAASb,YAAmBO,WAAoBC,GAElElB,GACFsB,EAAaC,SAAS,MAAMN,8CAAuDC,GAGrFQ,QAAQC,KAAK,KAAKC,EAAMC,KAAK,qCA3C3BH,QAAQI,MACNF,EAAMG,IACJ,kGA0CR"}
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/helpers/keyboard-input';\nimport viteResetCache from '@cli/helpers/vite-reset-cache';\nimport type {\n IBuildActionParams,\n IBuildAmplifyActionParams,\n IBuildDockerActionParams,\n IBuildVercelActionParams,\n IDevActionParams,\n IPreviewActionParams,\n IStartActionParams,\n} from '@cli/interfaces/actions';\nimport runAmplifyBuild from '@cli/run-amplify-build';\nimport runDev from '@cli/run-dev';\nimport runDockerBuild from '@cli/run-docker-build';\nimport runProd from '@cli/run-prod';\nimport runVercelBuild from '@cli/run-vercel-build';\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 focusOnlyOption = new Option(\n '--focus-only [focusOnly]',\n 'Build or Start only specified part of app.',\n)\n .default('app')\n .choices(['all', 'app', 'client', 'server', 'entrypoint']);\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');\nconst buildDirOption = new Option('--build-dir [buildDir]', 'Build directory output.');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(portOption)\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 .addOption(new Option('--entrypoint [entrypoint]', 'Run only entrypoint by name.'))\n .action(async ({ host, port, resetCache, mode, entrypoint }: IDevActionParams) => {\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({\n version,\n isHost: host,\n isPrintInfo,\n port,\n mode,\n entrypointName: entrypoint,\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.build)\n .description('Create production build.')\n .addOption(focusOnlyOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option(\n '--unlock-robots',\n 'Change general directive Disallow to Allow in robots.txt',\n ).default(false),\n )\n .addOption(\n new Option('--eject', 'Produces entrypoint file to run app without cli').default(false),\n )\n .addOption(\n new Option(\n '--serverless',\n 'Produces entrypoint file to run app like serverless function',\n ).default(false),\n )\n .addOption(\n new Option(\n '--throw-warnings',\n 'The build will abort with an error if warnings occur in the process.',\n ).default(false),\n )\n .action(\n async ({\n focusOnly,\n clientOptions,\n serverOptions,\n mode,\n unlockRobots,\n eject,\n serverless,\n throwWarnings,\n }: IBuildActionParams) => {\n await runBuild({\n focusOnly,\n isUnlockRobots: unlockRobots,\n isNoWarnings: throwWarnings,\n isEject: eject,\n isServerless: serverless,\n clientOptions,\n serverOptions,\n mode: mode!,\n });\n },\n );\n\nprogram\n .command(CliActions.start)\n .description('Run production server.')\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(focusOnlyOption)\n .addOption(buildDirOption)\n .addOption(\n new Option('--module-preload', 'Add module preload scripts to server output.').default(false),\n )\n .action(({ host, port, focusOnly, modulePreload, buildDir }: IStartActionParams) => {\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n focusOnly,\n modulePreload,\n buildDir,\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(focusOnlyOption)\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(envModeOption)\n .addOption(buildDirOption)\n .action(async ({ host, port, focusOnly, mode, buildDir }: IPreviewActionParams) => {\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 focusOnly,\n buildDir,\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: mode!,\n isWatch: true,\n focusOnly,\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(focusOnlyOption)\n .addOption(envModeOption)\n .action(\n async ({ imageName, dockerOptions, dockerFile, focusOnly, mode }: IBuildDockerActionParams) => {\n await runDockerBuild({\n imageName,\n dockerOptions,\n dockerFile,\n focusOnly,\n mode,\n });\n },\n );\n\nprogram\n .command(CliActions.buildAmplify)\n .description('Create AWS Amplify production build.')\n .addOption(\n new Option(\n '--manifest-file [manifest-file]',\n 'Path to the Amplify manifest file (Default is PLUGIN_PATH/workflow/amplify-manifest.json).',\n ),\n )\n .addOption(new Option('--is-optimize', 'Optimize node_modules folder.').default(false))\n .addOption(envModeOption)\n .action(async ({ manifestFile, mode, isOptimize }: IBuildAmplifyActionParams) => {\n await runAmplifyBuild({\n manifestFile,\n mode,\n isOptimize,\n });\n });\n\nprogram\n .command(CliActions.buildVercel)\n .description('Create Vercel serverless production build.')\n .addOption(\n new Option(\n '--config-file [config-file]',\n 'Path to the Vercel config.json file (Default is PLUGIN_PATH/workflow/vercel.config.json).',\n ),\n )\n .addOption(\n new Option(\n '--config-vc-file [config-vc-file]',\n 'Path to the Vercel vc-config.json file (Default is PLUGIN_PATH/workflow/vercel.vc-config.json).',\n ),\n )\n .addOption(new Option('--is-optimize', 'Optimize node_modules folder.').default(false))\n .addOption(envModeOption)\n .action(async ({ configFile, configVcFile, mode, isOptimize }: IBuildVercelActionParams) => {\n await runVercelBuild({\n configFile,\n configVcFile,\n mode,\n isOptimize,\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","focusOnlyOption","choices","portOption","envModeOption","env","buildDirOption","command","CliActions","dev","addOption","action","async","host","port","resetCache","mode","entrypoint","viteResetCache","isPrintInfo","console","info","chalk","cyan","server","config","runDev","isHost","entrypointName","cliContext","reboot","build","focusOnly","clientOptions","serverOptions","unlockRobots","eject","serverless","throwWarnings","runBuild","isUnlockRobots","isNoWarnings","isEject","isServerless","start","modulePreload","buildDir","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild","buildAmplify","manifestFile","isOptimize","runAmplifyBuild","buildVercel","configFile","configVcFile","runVercelBuild"],"mappings":"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"}
1
+ {"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport chalk from 'chalk';\nimport { Command, Option } from 'commander';\nimport runBuild from '@cli/build';\nimport onKeyPress from '@cli/helpers/keyboard-input';\nimport viteResetCache from '@cli/helpers/vite-reset-cache';\nimport type {\n IBuildActionParams,\n IBuildAmplifyActionParams,\n IBuildDockerActionParams,\n IBuildVercelActionParams,\n IDevActionParams,\n IPreviewActionParams,\n IStartActionParams,\n} from '@cli/interfaces/actions';\nimport runAmplifyBuild from '@cli/run-amplify-build';\nimport runDev from '@cli/run-dev';\nimport runDockerBuild from '@cli/run-docker-build';\nimport runProd from '@cli/run-prod';\nimport runVercelBuild from '@cli/run-vercel-build';\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 focusOnlyOption = new Option(\n '--focus-only [focusOnly]',\n 'Build or Start only specified part of app.',\n)\n .default('app')\n .choices(['all', 'app', 'client', 'server', 'entrypoint']);\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');\nconst buildDirOption = new Option('--build-dir [buildDir]', 'Build directory output.');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(portOption)\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 .addOption(new Option('--entrypoint [entrypoint]', 'Run only entrypoint by name.'))\n .action(async ({ host, port, resetCache, mode, entrypoint }: IDevActionParams) => {\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({\n version,\n isHost: host,\n isPrintInfo,\n port,\n mode,\n entrypointName: entrypoint,\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.build)\n .description('Create production build.')\n .addOption(focusOnlyOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option(\n '--unlock-robots',\n 'Change general directive Disallow to Allow in robots.txt',\n ).default(false),\n )\n .addOption(\n new Option('--eject', 'Produces entrypoint file to run app without cli').default(false),\n )\n .addOption(\n new Option(\n '--serverless',\n 'Produces entrypoint file to run app like serverless function',\n ).default(false),\n )\n .addOption(\n new Option(\n '--throw-warnings',\n 'The build will abort with an error if warnings occur in the process.',\n ).default(false),\n )\n .action(\n async ({\n focusOnly,\n clientOptions,\n serverOptions,\n mode,\n unlockRobots,\n eject,\n serverless,\n throwWarnings,\n }: IBuildActionParams) => {\n await runBuild({\n focusOnly,\n isUnlockRobots: unlockRobots,\n isNoWarnings: throwWarnings,\n isEject: eject,\n isServerless: serverless,\n clientOptions,\n serverOptions,\n mode: mode!,\n });\n },\n );\n\nprogram\n .command(CliActions.start)\n .description('Run production server.')\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(focusOnlyOption)\n .addOption(buildDirOption)\n .addOption(\n new Option('--module-preload', 'Add module preload scripts to server output.').default(false),\n )\n .action(({ host, port, focusOnly, modulePreload, buildDir }: IStartActionParams) => {\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n focusOnly,\n modulePreload,\n buildDir,\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(focusOnlyOption)\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(envModeOption)\n .addOption(buildDirOption)\n .action(async ({ host, port, focusOnly, mode, buildDir }: IPreviewActionParams) => {\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 focusOnly,\n buildDir,\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: mode!,\n isWatch: true,\n focusOnly,\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(focusOnlyOption)\n .addOption(envModeOption)\n .action(\n async ({ imageName, dockerOptions, dockerFile, focusOnly, mode }: IBuildDockerActionParams) => {\n await runDockerBuild({\n imageName,\n dockerOptions,\n dockerFile,\n focusOnly,\n mode,\n });\n },\n );\n\nprogram\n .command(CliActions.buildAmplify)\n .description('Create AWS Amplify production build.')\n .addOption(\n new Option(\n '--manifest-file [manifest-file]',\n 'Path to the Amplify manifest file (Default is PLUGIN_PATH/workflow/amplify-manifest.json).',\n ),\n )\n .addOption(new Option('--is-optimize', 'Optimize node_modules folder.').default(false))\n .addOption(envModeOption)\n .action(async ({ manifestFile, mode, isOptimize }: IBuildAmplifyActionParams) => {\n await runAmplifyBuild({\n manifestFile,\n mode,\n isOptimize,\n });\n });\n\nprogram\n .command(CliActions.buildVercel)\n .description('Create Vercel serverless production build.')\n .addOption(\n new Option(\n '--config-file [config-file]',\n 'Path to the Vercel config.json file (Default is PLUGIN_PATH/workflow/vercel.config.json).',\n ),\n )\n .addOption(\n new Option(\n '--config-vc-file [config-vc-file]',\n 'Path to the Vercel vc-config.json file (Default is PLUGIN_PATH/workflow/vercel.vc-config.json).',\n ),\n )\n .addOption(new Option('--is-optimize', 'Optimize node_modules folder.').default(false))\n .addOption(envModeOption)\n .action(async ({ configFile, configVcFile, mode, isOptimize }: IBuildVercelActionParams) => {\n await runVercelBuild({\n configFile,\n configVcFile,\n mode,\n isOptimize,\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","focusOnlyOption","choices","portOption","envModeOption","env","buildDirOption","command","CliActions","dev","addOption","action","async","host","port","resetCache","mode","entrypoint","viteResetCache","isPrintInfo","console","info","chalk","cyan","server","config","runDev","isHost","entrypointName","cliContext","reboot","build","focusOnly","clientOptions","serverOptions","unlockRobots","eject","serverless","throwWarnings","runBuild","isUnlockRobots","isNoWarnings","isEject","isServerless","start","modulePreload","buildDir","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild","buildAmplify","manifestFile","isOptimize","runAmplifyBuild","buildVercel","configFile","configVcFile","runVercelBuild"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"navigate.js","sources":["../../src/components/navigate.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport React from 'react';\nimport type { NavigateProps } from 'react-router';\nimport { Navigate as DefaultNavigate } from 'react-router';\nimport { useServerContext } from '@context/server';\n\ninterface INavigate {\n status?: number;\n}\n\ntype TProps = INavigate & NavigateProps;\n\n/**\n * React router navigate with server support\n * @constructor\n */\nconst Navigate: FC<TProps> = ({ to, status = 301, ...rest }) => {\n const context = useServerContext();\n\n if (!context.isServer) {\n return <DefaultNavigate to={to} {...rest} />;\n }\n\n if (context) {\n const { basename } = context;\n const location = [basename, typeof to === 'string' ? to : [to.pathname, to.search, to.hash]]\n .flat()\n .filter(Boolean)\n .join('')\n .replace(/\\/+/g, '/');\n\n context.response = new Response('', { status, headers: new Headers({ Location: location }) });\n }\n\n return null;\n};\n\nexport default Navigate;\n"],"names":["Navigate","to","status","rest","context","useServerContext","isServer","React","createElement","DefaultNavigate","basename","location","pathname","search","hash","flat","filter","Boolean","join","replace","response","Response","headers","Headers","Location"],"mappings":"qHAgBA,MAAMA,EAAuB,EAAGC,KAAIC,SAAS,OAAQC,MACnD,MAAMC,EAAUC,IAEhB,IAAKD,EAAQE,SACX,OAAOC,EAAAC,cAACC,EAAgB,CAAAR,GAAIA,KAAQE,IAGtC,GAAIC,EAAS,CACX,MAAMM,SAAEA,GAAaN,EACfO,EAAW,CAACD,EAAwB,iBAAPT,EAAkBA,EAAK,CAACA,EAAGW,SAAUX,EAAGY,OAAQZ,EAAGa,OACnFC,OACAC,OAAOC,SACPC,KAAK,IACLC,QAAQ,OAAQ,KAEnBf,EAAQgB,SAAW,IAAIC,SAAS,GAAI,CAAEnB,SAAQoB,QAAS,IAAIC,QAAQ,CAAEC,SAAUb,KAChF,CAED,OAAO,IAAI"}
1
+ {"version":3,"file":"navigate.js","sources":["../../src/components/navigate.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport React from 'react';\nimport type { NavigateProps } from 'react-router';\nimport { Navigate as DefaultNavigate } from 'react-router';\nimport { useServerContext } from '@context/server';\n\ninterface INavigate {\n status?: number;\n}\n\ntype TProps = INavigate & NavigateProps;\n\n/**\n * React router navigate with server support\n * @constructor\n */\nconst Navigate: FC<TProps> = ({ to, status = 301, ...rest }) => {\n const context = useServerContext();\n\n if (!context.isServer) {\n return <DefaultNavigate to={to} {...rest} />;\n }\n\n if (context) {\n const { basename } = context;\n const location = [basename, typeof to === 'string' ? to : [to.pathname, to.search, to.hash]]\n .flat()\n .filter(Boolean)\n .join('')\n .replace(/\\/+/g, '/');\n\n context.response = new Response('', { status, headers: new Headers({ Location: location }) });\n }\n\n return null;\n};\n\nexport default Navigate;\n"],"names":["Navigate","to","status","rest","context","useServerContext","isServer","React","createElement","DefaultNavigate","basename","location","pathname","search","hash","flat","filter","Boolean","join","replace","response","Response","headers","Headers","Location"],"mappings":"qHAgBA,MAAMA,EAAuB,EAAGC,KAAIC,SAAS,OAAQC,MACnD,MAAMC,EAAUC,IAEhB,IAAKD,EAAQE,SACX,OAAOC,EAAAC,cAACC,EAAgB,CAAAR,GAAIA,KAAQE,IAGtC,GAAIC,EAAS,CACX,MAAMM,SAAEA,GAAaN,EACfO,EAAW,CAACD,EAAwB,iBAAPT,EAAkBA,EAAK,CAACA,EAAGW,SAAUX,EAAGY,OAAQZ,EAAGa,OACnFC,OACAC,OAAOC,SACPC,KAAK,IACLC,QAAQ,OAAQ,KAEnBf,EAAQgB,SAAW,IAAIC,SAAS,GAAI,CAAEnB,SAAQoB,QAAS,IAAIC,QAAQ,CAAEC,SAAUb,MAGjF,OAAO,IAAI"}
@@ -1 +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 getMarkerFile = (root: string, withFile = true): string =>\n [root, 'server', withFile && '.dev'].filter(Boolean).join('/');\n\n/**\n * Create dev marker\n *\n * @see printServerInfo\n */\nconst createDevMarker = (isProd: boolean, { root, build: buildConf }: ResolvedConfig): void => {\n const buildRoot = path.resolve(root, buildConf.outDir);\n const devMarkerPath = getMarkerFile(buildRoot, false);\n const devMarker = getMarkerFile(buildRoot);\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, getMarkerFile };\n"],"names":["getMarkerFile","root","withFile","filter","Boolean","join","createDevMarker","isProd","build","buildConf","buildRoot","path","resolve","outDir","devMarkerPath","devMarker","fs","existsSync","rmSync","mkdirSync","recursive","writeFileSync"],"mappings":"gDAIA,MAAMA,EAAgB,CAACC,EAAcC,GAAW,IAC9C,CAACD,EAAM,SAAUC,GAAY,QAAQC,OAAOC,SAASC,KAAK,KAOtDC,EAAkB,CAACC,GAAmBN,OAAMO,MAAOC,MACvD,MAAMC,EAAYC,EAAKC,QAAQX,EAAMQ,EAAUI,QACzCC,EAAgBd,EAAcU,GAAW,GACzCK,EAAYf,EAAcU,GAE3BH,EAMMS,EAAGC,WAAWF,IACvBC,EAAGE,OAAOH,IANLC,EAAGC,WAAWH,IACjBE,EAAGG,UAAUL,EAAe,CAAEM,WAAW,IAG3CJ,EAAGK,cAAcN,EAAW,IAG7B"}
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 getMarkerFile = (root: string, withFile = true): string =>\n [root, 'server', withFile && '.dev'].filter(Boolean).join('/');\n\n/**\n * Create dev marker\n *\n * @see printServerInfo\n */\nconst createDevMarker = (isProd: boolean, { root, build: buildConf }: ResolvedConfig): void => {\n const buildRoot = path.resolve(root, buildConf.outDir);\n const devMarkerPath = getMarkerFile(buildRoot, false);\n const devMarker = getMarkerFile(buildRoot);\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, getMarkerFile };\n"],"names":["getMarkerFile","root","withFile","filter","Boolean","join","createDevMarker","isProd","build","buildConf","buildRoot","path","resolve","outDir","devMarkerPath","devMarker","fs","existsSync","rmSync","mkdirSync","recursive","writeFileSync"],"mappings":"gDAIA,MAAMA,EAAgB,CAACC,EAAcC,GAAW,IAC9C,CAACD,EAAM,SAAUC,GAAY,QAAQC,OAAOC,SAASC,KAAK,KAOtDC,EAAkB,CAACC,GAAmBN,OAAMO,MAAOC,MACvD,MAAMC,EAAYC,EAAKC,QAAQX,EAAMQ,EAAUI,QACzCC,EAAgBd,EAAcU,GAAW,GACzCK,EAAYf,EAAcU,GAE3BH,EAMMS,EAAGC,WAAWF,IACvBC,EAAGE,OAAOH,IANLC,EAAGC,WAAWH,IACjBE,EAAGG,UAAUL,EAAe,CAAEM,WAAW,IAG3CJ,EAAGK,cAAcN,EAAW"}
@@ -1 +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 = <TP = Record<string, any>>(name: string, shouldRemove = true): TP => {\n const data = (window as Record<any, any>)[name] as TP;\n\n if (shouldRemove && data) {\n delete (window as Record<any, any>)[name];\n }\n\n return (data ?? {}) as TP;\n};\n\nexport default getServerState;\n"],"names":["getServerState","name","shouldRemove","data","window"],"mappings":"AAGM,MAAAA,EAAiB,CAA2BC,EAAcC,GAAe,KAC7E,MAAMC,EAAQC,OAA4BH,GAM1C,OAJIC,GAAgBC,UACVC,OAA4BH,GAG9BE,GAAQ,CAAA,CAAU"}
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 = <TP = Record<string, any>>(name: string, shouldRemove = true): TP => {\n const data = (window as Record<any, any>)[name] as TP;\n\n if (shouldRemove && data) {\n delete (window as Record<any, any>)[name];\n }\n\n return (data ?? {}) as TP;\n};\n\nexport default getServerState;\n"],"names":["getServerState","name","shouldRemove","data","window"],"mappings":"AAGM,MAAAA,EAAiB,CAA2BC,EAAcC,GAAe,KAC7E,MAAMC,EAAQC,OAA4BH,GAM1C,OAJIC,GAAgBC,UACVC,OAA4BH,GAG9BE,GAAQ,CAAE,CAAA"}
@@ -10,5 +10,5 @@ type IAsyncRoute = {
10
10
  /**
11
11
  * Import dynamic route
12
12
  */
13
- declare const importRoute: (route: IDynamicRoute, id?: string) => (() => Promise<IAsyncRoute>);
13
+ declare const importRoute: (route: IDynamicRoute) => (() => Promise<IAsyncRoute>);
14
14
  export { importRoute as default, IDynamicRoute, ImmutableRouteKey, IAsyncRoute };
@@ -1,2 +1,2 @@
1
- import t from"../components/with-suspense.js";import{keys as n}from"../interfaces/fc-route.js";const e=(e,o)=>async()=>{const s=await e();if("Component"in s)return{...s,pathId:o};const p=s.default,r={Component:p,pathId:o};return n.forEach((t=>{p[t]&&(r[t]=p[t])})),p.Suspense&&(r.Component=t(p,p.Suspense)),r};export{e as default};
1
+ import n from"../components/with-suspense.js";import{keys as e}from"../interfaces/fc-route.js";const o=o=>async()=>{const t=await o();if("Component"in t)return{...t};const s=t.default,r={Component:s};return e.forEach((n=>{s[n]&&(r[n]=s[n])})),s.Suspense&&(r.Component=n(s,s.Suspense)),r};export{o as default};
2
2
  //# sourceMappingURL=import-route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"import-route.js","sources":["../../src/helpers/import-route.ts"],"sourcesContent":["import type { IndexRouteObject, NonIndexRouteObject } from 'react-router';\nimport withSuspense from '@components/with-suspense';\nimport type { FCCRoute, FCRoute } from '@interfaces/fc-route';\nimport { keys } from '@interfaces/fc-route';\n\nexport type IDynamicRoute = () => Promise<{ default: FCRoute | FCCRoute<any> }>;\n\nexport type ImmutableRouteKey = 'lazy' | 'caseSensitive' | 'path' | 'id' | 'index' | 'children';\n\nexport type IAsyncRoute = { pathId?: string } & (\n | Omit<IndexRouteObject, ImmutableRouteKey>\n | Omit<NonIndexRouteObject, ImmutableRouteKey>\n);\n\n/**\n * Import dynamic route\n */\nconst importRoute = (route: IDynamicRoute, id?: string): (() => Promise<IAsyncRoute>) => {\n return async (): Promise<IAsyncRoute> => {\n const resolved = await route();\n\n // fallback to react router export style\n if ('Component' in resolved) {\n return { ...resolved, pathId: id } as IAsyncRoute;\n }\n\n const Component = resolved.default;\n const result: IAsyncRoute = { Component, pathId: id };\n\n keys.forEach((key) => {\n if (Component[key]) {\n // @ts-ignore\n result[key] = Component[key] as NonNullable<IAsyncRoute[typeof key]>;\n }\n });\n\n if (Component.Suspense) {\n result.Component = withSuspense(Component, Component.Suspense);\n }\n\n return result;\n };\n};\n\nexport default importRoute;\n"],"names":["importRoute","route","id","async","resolved","pathId","Component","default","result","keys","forEach","key","Suspense","withSuspense"],"mappings":"+FAiBA,MAAMA,EAAc,CAACC,EAAsBC,IAClCC,UACL,MAAMC,QAAiBH,IAGvB,GAAI,cAAeG,EACjB,MAAO,IAAKA,EAAUC,OAAQH,GAGhC,MAAMI,EAAYF,EAASG,QACrBC,EAAsB,CAAEF,YAAWD,OAAQH,GAajD,OAXAO,EAAKC,SAASC,IACRL,EAAUK,KAEZH,EAAOG,GAAOL,EAAUK,GACzB,IAGCL,EAAUM,WACZJ,EAAOF,UAAYO,EAAaP,EAAWA,EAAUM,WAGhDJ,CAAM"}
1
+ {"version":3,"file":"import-route.js","sources":["../../src/helpers/import-route.ts"],"sourcesContent":["import type { IndexRouteObject, NonIndexRouteObject } from 'react-router';\nimport withSuspense from '@components/with-suspense';\nimport type { FCCRoute, FCRoute } from '@interfaces/fc-route';\nimport { keys } from '@interfaces/fc-route';\n\nexport type IDynamicRoute = () => Promise<{ default: FCRoute | FCCRoute<any> }>;\n\nexport type ImmutableRouteKey = 'lazy' | 'caseSensitive' | 'path' | 'id' | 'index' | 'children';\n\nexport type IAsyncRoute = { pathId?: string } & (\n | Omit<IndexRouteObject, ImmutableRouteKey>\n | Omit<NonIndexRouteObject, ImmutableRouteKey>\n);\n\n/**\n * Import dynamic route\n */\nconst importRoute = (route: IDynamicRoute): (() => Promise<IAsyncRoute>) => {\n return async (): Promise<IAsyncRoute> => {\n const resolved = await route();\n\n // fallback to react router export style\n if ('Component' in resolved) {\n return { ...resolved } as IAsyncRoute;\n }\n\n const Component = resolved.default;\n const result: IAsyncRoute = { Component };\n\n keys.forEach((key) => {\n if (Component[key]) {\n // @ts-ignore\n result[key] = Component[key] as NonNullable<IAsyncRoute[typeof key]>;\n }\n });\n\n if (Component.Suspense) {\n result.Component = withSuspense(Component, Component.Suspense);\n }\n\n return result;\n };\n};\n\nexport default importRoute;\n"],"names":["importRoute","route","async","resolved","Component","default","result","keys","forEach","key","Suspense","withSuspense"],"mappings":"+FAiBA,MAAMA,EAAeC,GACZC,UACL,MAAMC,QAAiBF,IAGvB,GAAI,cAAeE,EACjB,MAAO,IAAKA,GAGd,MAAMC,EAAYD,EAASE,QACrBC,EAAsB,CAAEF,aAa9B,OAXAG,EAAKC,SAASC,IACRL,EAAUK,KAEZH,EAAOG,GAAOL,EAAUK,OAIxBL,EAAUM,WACZJ,EAAOF,UAAYO,EAAaP,EAAWA,EAAUM,WAGhDJ,CAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"print-server-info.js","sources":["../../src/helpers/print-server-info.ts"],"sourcesContent":["import fs from 'node:fs';\nimport type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport type { ResolvedConfig } from 'vite';\nimport CliActions from '@constants/cli-actions';\nimport cliName from '@constants/cli-name';\nimport { getMarkerFile } from '@helpers/dev-marker';\nimport printServerUrls from '@helpers/print-server-urls';\nimport resolveServerUrls from '@helpers/resolve-server-urls';\nimport type ServerConfig from '@services/server-config';\n\ninterface IPrintServerInfoParams {\n version?: string;\n server?: Server;\n}\n\n/**\n * Print server info\n */\nasync function printServerInfo(\n config: ServerConfig,\n { server, version = 'unknown' }: IPrintServerInfoParams = {},\n): Promise<void> {\n const { action } = config.getPluginConfig() ?? {};\n const { isProd, host, root, isSPA } = config.getParams();\n const devMarker = getMarkerFile(root);\n\n const Logger = config.getLogger();\n const perfStart = global.viteBoostStartTime ?? performance.now();\n const startupDurationString = chalk.dim(\n `ready in ${chalk.reset(chalk.bold(Math.ceil(performance.now() - perfStart)))} ms`,\n );\n\n Logger.info(\n `\\n ${chalk.green(\n `${chalk.bold(cliName.toUpperCase())} v${version}`,\n )} ${startupDurationString}\\n`,\n { clear: !Logger.hasWarned },\n );\n\n const viteConfig = config.getVite()?.config as\n | (ResolvedConfig & { rawBase?: string })\n | undefined;\n const isProdBuild = !viteConfig?.mode && !fs.existsSync(devMarker);\n const resolvedUrls = server\n ? await resolveServerUrls(server, {\n host,\n isHttps: Boolean(viteConfig?.server.https),\n rawBase: viteConfig?.rawBase,\n })\n : null;\n const mode =\n viteConfig?.mode || isProdBuild\n ? config.mode\n : `production ${chalk.red('NODE_ENV=development')}`;\n const type = isSPA ? 'SPA' : 'SSR';\n\n Logger.info(chalk.dim(chalk.green(' ➜')) + chalk.dim(' Mode: ') + chalk.blue(mode));\n Logger.info(chalk.dim(chalk.green(' ➜')) + chalk.dim(' Type: ') + chalk.blue(type));\n\n if (!isProd) {\n const vite = config.getVite()!;\n\n vite.resolvedUrls = resolvedUrls;\n vite.printUrls();\n } else if (resolvedUrls) {\n printServerUrls(resolvedUrls, (msg) => Logger.info(msg));\n }\n\n if (action === CliActions.dev) {\n Logger.info(\n chalk.dim(chalk.green(' ➜')) +\n chalk.dim(' press ') +\n chalk.bold('h') +\n chalk.dim(' to show help'),\n );\n }\n}\n\nexport default printServerInfo;\n"],"names":["async","printServerInfo","config","server","version","action","getPluginConfig","isProd","host","root","isSPA","getParams","devMarker","getMarkerFile","Logger","getLogger","perfStart","global","viteBoostStartTime","performance","now","startupDurationString","chalk","dim","reset","bold","Math","ceil","info","green","cliName","toUpperCase","clear","hasWarned","viteConfig","getVite","isProdBuild","mode","fs","existsSync","resolvedUrls","resolveServerUrls","isHttps","Boolean","https","rawBase","red","type","blue","printServerUrls","msg","vite","printUrls","CliActions","dev"],"mappings":"2SAoBAA,eAAeC,EACbC,GACAC,OAAEA,EAAMC,QAAEA,EAAU,WAAsC,IAE1D,MAAMC,OAAEA,GAAWH,EAAOI,mBAAqB,CAAA,GACzCC,OAAEA,EAAMC,KAAEA,EAAIC,KAAEA,EAAIC,MAAEA,GAAUR,EAAOS,YACvCC,EAAYC,EAAcJ,GAE1BK,EAASZ,EAAOa,YAChBC,EAAYC,OAAOC,oBAAsBC,EAAYC,MACrDC,EAAwBC,EAAMC,IAClC,YAAYD,EAAME,MAAMF,EAAMG,KAAKC,KAAKC,KAAKR,EAAYC,MAAQJ,WAGnEF,EAAOc,KACL,OAAON,EAAMO,MACX,GAAGP,EAAMG,KAAKK,EAAQC,mBAAmB3B,SACrCiB,MACN,CAAEW,OAAQlB,EAAOmB,YAGnB,MAAMC,EAAahC,EAAOiC,WAAWjC,OAG/BkC,GAAeF,GAAYG,OAASC,EAAGC,WAAW3B,GAClD4B,EAAerC,QACXsC,EAAkBtC,EAAQ,CAC9BK,OACAkC,QAASC,QAAQT,GAAY/B,OAAOyC,OACpCC,QAASX,GAAYW,UAEvB,KACER,EACJH,GAAYG,MAAQD,EAChBlC,EAAOmC,KACP,cAAcf,EAAMwB,IAAI,0BACxBC,EAAOrC,EAAQ,MAAQ,MAK7B,GAHAI,EAAOc,KAAKN,EAAMC,IAAID,EAAMO,MAAM,QAAUP,EAAMC,IAAI,eAAiBD,EAAM0B,KAAKX,IAClFvB,EAAOc,KAAKN,EAAMC,IAAID,EAAMO,MAAM,QAAUP,EAAMC,IAAI,eAAiBD,EAAM0B,KAAKD,IAE7ExC,EAKMiC,GACTS,EAAgBT,GAAeU,GAAQpC,EAAOc,KAAKsB,SANxC,CACX,MAAMC,EAAOjD,EAAOiC,UAEpBgB,EAAKX,aAAeA,EACpBW,EAAKC,WACN,CAIG/C,IAAWgD,EAAWC,KACxBxC,EAAOc,KACLN,EAAMC,IAAID,EAAMO,MAAM,QACpBP,EAAMC,IAAI,YACVD,EAAMG,KAAK,KACXH,EAAMC,IAAI,iBAGlB"}
1
+ {"version":3,"file":"print-server-info.js","sources":["../../src/helpers/print-server-info.ts"],"sourcesContent":["import fs from 'node:fs';\nimport type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport type { ResolvedConfig } from 'vite';\nimport CliActions from '@constants/cli-actions';\nimport cliName from '@constants/cli-name';\nimport { getMarkerFile } from '@helpers/dev-marker';\nimport printServerUrls from '@helpers/print-server-urls';\nimport resolveServerUrls from '@helpers/resolve-server-urls';\nimport type ServerConfig from '@services/server-config';\n\ninterface IPrintServerInfoParams {\n version?: string;\n server?: Server;\n}\n\n/**\n * Print server info\n */\nasync function printServerInfo(\n config: ServerConfig,\n { server, version = 'unknown' }: IPrintServerInfoParams = {},\n): Promise<void> {\n const { action } = config.getPluginConfig() ?? {};\n const { isProd, host, root, isSPA } = config.getParams();\n const devMarker = getMarkerFile(root);\n\n const Logger = config.getLogger();\n const perfStart = global.viteBoostStartTime ?? performance.now();\n const startupDurationString = chalk.dim(\n `ready in ${chalk.reset(chalk.bold(Math.ceil(performance.now() - perfStart)))} ms`,\n );\n\n Logger.info(\n `\\n ${chalk.green(\n `${chalk.bold(cliName.toUpperCase())} v${version}`,\n )} ${startupDurationString}\\n`,\n { clear: !Logger.hasWarned },\n );\n\n const viteConfig = config.getVite()?.config as\n | (ResolvedConfig & { rawBase?: string })\n | undefined;\n const isProdBuild = !viteConfig?.mode && !fs.existsSync(devMarker);\n const resolvedUrls = server\n ? await resolveServerUrls(server, {\n host,\n isHttps: Boolean(viteConfig?.server.https),\n rawBase: viteConfig?.rawBase,\n })\n : null;\n const mode =\n viteConfig?.mode || isProdBuild\n ? config.mode\n : `production ${chalk.red('NODE_ENV=development')}`;\n const type = isSPA ? 'SPA' : 'SSR';\n\n Logger.info(chalk.dim(chalk.green(' ➜')) + chalk.dim(' Mode: ') + chalk.blue(mode));\n Logger.info(chalk.dim(chalk.green(' ➜')) + chalk.dim(' Type: ') + chalk.blue(type));\n\n if (!isProd) {\n const vite = config.getVite()!;\n\n vite.resolvedUrls = resolvedUrls;\n vite.printUrls();\n } else if (resolvedUrls) {\n printServerUrls(resolvedUrls, (msg) => Logger.info(msg));\n }\n\n if (action === CliActions.dev) {\n Logger.info(\n chalk.dim(chalk.green(' ➜')) +\n chalk.dim(' press ') +\n chalk.bold('h') +\n chalk.dim(' to show help'),\n );\n }\n}\n\nexport default printServerInfo;\n"],"names":["async","printServerInfo","config","server","version","action","getPluginConfig","isProd","host","root","isSPA","getParams","devMarker","getMarkerFile","Logger","getLogger","perfStart","global","viteBoostStartTime","performance","now","startupDurationString","chalk","dim","reset","bold","Math","ceil","info","green","cliName","toUpperCase","clear","hasWarned","viteConfig","getVite","isProdBuild","mode","fs","existsSync","resolvedUrls","resolveServerUrls","isHttps","Boolean","https","rawBase","red","type","blue","printServerUrls","msg","vite","printUrls","CliActions","dev"],"mappings":"2SAoBAA,eAAeC,EACbC,GACAC,OAAEA,EAAMC,QAAEA,EAAU,WAAsC,IAE1D,MAAMC,OAAEA,GAAWH,EAAOI,mBAAqB,CAAE,GAC3CC,OAAEA,EAAMC,KAAEA,EAAIC,KAAEA,EAAIC,MAAEA,GAAUR,EAAOS,YACvCC,EAAYC,EAAcJ,GAE1BK,EAASZ,EAAOa,YAChBC,EAAYC,OAAOC,oBAAsBC,EAAYC,MACrDC,EAAwBC,EAAMC,IAClC,YAAYD,EAAME,MAAMF,EAAMG,KAAKC,KAAKC,KAAKR,EAAYC,MAAQJ,WAGnEF,EAAOc,KACL,OAAON,EAAMO,MACX,GAAGP,EAAMG,KAAKK,EAAQC,mBAAmB3B,SACrCiB,MACN,CAAEW,OAAQlB,EAAOmB,YAGnB,MAAMC,EAAahC,EAAOiC,WAAWjC,OAG/BkC,GAAeF,GAAYG,OAASC,EAAGC,WAAW3B,GAClD4B,EAAerC,QACXsC,EAAkBtC,EAAQ,CAC9BK,OACAkC,QAASC,QAAQT,GAAY/B,OAAOyC,OACpCC,QAASX,GAAYW,UAEvB,KACER,EACJH,GAAYG,MAAQD,EAChBlC,EAAOmC,KACP,cAAcf,EAAMwB,IAAI,0BACxBC,EAAOrC,EAAQ,MAAQ,MAK7B,GAHAI,EAAOc,KAAKN,EAAMC,IAAID,EAAMO,MAAM,QAAUP,EAAMC,IAAI,eAAiBD,EAAM0B,KAAKX,IAClFvB,EAAOc,KAAKN,EAAMC,IAAID,EAAMO,MAAM,QAAUP,EAAMC,IAAI,eAAiBD,EAAM0B,KAAKD,IAE7ExC,EAKMiC,GACTS,EAAgBT,GAAeU,GAAQpC,EAAOc,KAAKsB,SANxC,CACX,MAAMC,EAAOjD,EAAOiC,UAEpBgB,EAAKX,aAAeA,EACpBW,EAAKC,YAKH/C,IAAWgD,EAAWC,KACxBxC,EAAOc,KACLN,EAAMC,IAAID,EAAMO,MAAM,QACpBP,EAAMC,IAAI,YACVD,EAAMG,KAAK,KACXH,EAAMC,IAAI,iBAGlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-server-urls.js","sources":["../../src/helpers/resolve-server-urls.ts"],"sourcesContent":["import { promises as dns } from 'node:dns';\nimport type { AddressInfo, Server } from 'node:net';\nimport os from 'node:os';\nimport type { ResolvedServerUrls } from 'vite';\n\ninterface IHostname {\n host: string | undefined;\n name: string;\n}\n\nconst loopbackHosts = new Set([\n 'localhost',\n '127.0.0.1',\n '::1',\n '0000:0000:0000:0000:0000:0000:0000:0001',\n]);\n\nconst wildcardHosts = new Set(['0.0.0.0', '::', '0000:0000:0000:0000:0000:0000:0000:0000']);\n\n/**\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#LL819C8-L830C2\n */\nasync function getLocalhostAddressIfDiffersFromDNS(): Promise<string | undefined> {\n const [nodeResult, dnsResult] = await Promise.all([\n dns.lookup('localhost'),\n dns.lookup('localhost', { verbatim: true }),\n ]);\n const isSame = nodeResult.family === dnsResult.family && nodeResult.address === dnsResult.address;\n\n return isSame ? undefined : nodeResult.address;\n}\n\n/**\n * Resolve hostname\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#LL852C1-L878C2\n * vite not export this function\n */\nasync function resolveHostname(optionsHost: string | boolean | undefined): Promise<IHostname> {\n let host: string | undefined;\n\n if (optionsHost === undefined || optionsHost === false) {\n // Use a secure default\n host = 'localhost';\n } else if (optionsHost === true) {\n // If passed --host in the CLI without arguments\n host = undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)\n } else {\n host = optionsHost;\n }\n\n // Set host name to localhost when possible\n let name = host === undefined || wildcardHosts.has(host) ? 'localhost' : host;\n\n if (host === 'localhost') {\n // See #8647 for more details.\n const localhostAddr = await getLocalhostAddressIfDiffersFromDNS();\n\n if (localhostAddr) {\n name = localhostAddr;\n }\n }\n\n return { host, name };\n}\n\ninterface IResolveServerUrlsOptions {\n host: string;\n isHttps?: boolean;\n rawBase?: string;\n}\n\n/**\n * Resolve server urls\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#L956\n * vite not export this function\n */\nasync function resolveServerUrls(\n server: Server,\n options: IResolveServerUrlsOptions,\n): Promise<ResolvedServerUrls> {\n const address = server.address();\n\n const isAddressInfo = (x: AddressInfo | null | string): x is AddressInfo =>\n (typeof x === 'object' && Boolean(x?.address)) || false;\n\n if (!isAddressInfo(address)) {\n return { local: [], network: [] };\n }\n\n const { host, isHttps, rawBase } = options;\n\n const local: string[] = [];\n const network: string[] = [];\n const hostname = await resolveHostname(host);\n const protocol = isHttps ? 'https' : 'http';\n const { port } = address;\n const base = rawBase === './' || rawBase === '' || !rawBase ? '/' : rawBase;\n\n if (hostname.host !== undefined && !wildcardHosts.has(hostname.host)) {\n let hostnameName = hostname.name;\n\n // ipv6 host\n if (hostnameName.includes(':')) {\n hostnameName = `[${hostnameName}]`;\n }\n\n const addressUrl = `${protocol}://${hostnameName}:${port}${base}`;\n\n if (loopbackHosts.has(hostname.host)) {\n local.push(addressUrl);\n } else {\n network.push(addressUrl);\n }\n } else {\n Object.values(os.networkInterfaces())\n .flatMap((nInterface) => nInterface ?? [])\n .filter(\n (detail) =>\n detail &&\n detail.address &&\n (detail.family === 'IPv4' ||\n // @ts-expect-error Node 18.0 - 18.3 returns number\n detail.family === 4),\n )\n .forEach((detail) => {\n let resultHost = detail.address.replace('127.0.0.1', hostname.name);\n\n // ipv6 host\n if (resultHost.includes(':')) {\n resultHost = `[${resultHost}]`;\n }\n\n const url = `${protocol}://${resultHost}:${port}${base}`;\n\n if (detail.address.includes('127.0.0.1')) {\n local.push(url);\n } else {\n network.push(url);\n }\n });\n }\n\n return { local, network };\n}\n\nexport default resolveServerUrls;\n"],"names":["loopbackHosts","Set","wildcardHosts","async","resolveHostname","optionsHost","host","undefined","name","has","localhostAddr","nodeResult","dnsResult","Promise","all","dns","lookup","verbatim","family","address","getLocalhostAddressIfDiffersFromDNS","resolveServerUrls","server","options","x","Boolean","local","network","isHttps","rawBase","hostname","protocol","port","base","Object","values","os","networkInterfaces","flatMap","nInterface","filter","detail","forEach","resultHost","replace","includes","url","push","hostnameName","addressUrl"],"mappings":"2DAUA,MAAMA,EAAgB,IAAIC,IAAI,CAC5B,YACA,YACA,MACA,4CAGIC,EAAgB,IAAID,IAAI,CAAC,UAAW,KAAM,4CAoBhDE,eAAeC,EAAgBC,GAC7B,IAAIC,EAIFA,OAFkBC,IAAhBF,IAA6C,IAAhBA,EAExB,aACkB,IAAhBA,OAEFE,EAEAF,EAIT,IAAIG,OAAgBD,IAATD,GAAsBJ,EAAcO,IAAIH,GAAQ,YAAcA,EAEzE,GAAa,cAATA,EAAsB,CAExB,MAAMI,QAjCVP,iBACE,MAAOQ,EAAYC,SAAmBC,QAAQC,IAAI,CAChDC,EAAIC,OAAO,aACXD,EAAIC,OAAO,YAAa,CAAEC,UAAU,MAItC,OAFeN,EAAWO,SAAWN,EAAUM,QAAUP,EAAWQ,UAAYP,EAAUO,aAE1EZ,EAAYI,EAAWQ,OACzC,CAyBgCC,GAExBV,IACFF,EAAOE,EAEV,CAED,MAAO,CAAEJ,OAAME,OACjB,CAaAL,eAAekB,EACbC,EACAC,GAEA,MAAMJ,EAAUG,EAAOH,UAKvB,GAFgB,iBADOK,EAGJL,KAFSM,QAAQD,GAAGL,SAGrC,MAAO,CAAEO,MAAO,GAAIC,QAAS,IAJT,IAACH,EAOvB,MAAMlB,KAAEA,EAAIsB,QAAEA,EAAOC,QAAEA,GAAYN,EAE7BG,EAAkB,GAClBC,EAAoB,GACpBG,QAAiB1B,EAAgBE,GACjCyB,EAAWH,EAAU,QAAU,QAC/BI,KAAEA,GAASb,EACXc,EAAmB,OAAZJ,GAAgC,KAAZA,GAAmBA,EAAgBA,EAAN,IAE9D,QAAsBtB,IAAlBuB,EAASxB,MAAuBJ,EAAcO,IAAIqB,EAASxB,MAgB7D4B,OAAOC,OAAOC,EAAGC,qBACdC,SAASC,GAAeA,GAAc,KACtCC,QACEC,GACCA,GACAA,EAAOtB,UACY,SAAlBsB,EAAOvB,QAEY,IAAlBuB,EAAOvB,UAEZwB,SAASD,IACR,IAAIE,EAAaF,EAAOtB,QAAQyB,QAAQ,YAAad,EAAStB,MAG1DmC,EAAWE,SAAS,OACtBF,EAAa,IAAIA,MAGnB,MAAMG,EAAM,GAAGf,OAAcY,KAAcX,IAAOC,IAE9CQ,EAAOtB,QAAQ0B,SAAS,aAC1BnB,EAAMqB,KAAKD,GAEXnB,EAAQoB,KAAKD,EACd,QAxC+D,CACpE,IAAIE,EAAelB,EAAStB,KAGxBwC,EAAaH,SAAS,OACxBG,EAAe,IAAIA,MAGrB,MAAMC,EAAa,GAAGlB,OAAciB,KAAgBhB,IAAOC,IAEvDjC,EAAcS,IAAIqB,EAASxB,MAC7BoB,EAAMqB,KAAKE,GAEXtB,EAAQoB,KAAKE,EAEhB,CA6BD,MAAO,CAAEvB,QAAOC,UAClB"}
1
+ {"version":3,"file":"resolve-server-urls.js","sources":["../../src/helpers/resolve-server-urls.ts"],"sourcesContent":["import { promises as dns } from 'node:dns';\nimport type { AddressInfo, Server } from 'node:net';\nimport os from 'node:os';\nimport type { ResolvedServerUrls } from 'vite';\n\ninterface IHostname {\n host: string | undefined;\n name: string;\n}\n\nconst loopbackHosts = new Set([\n 'localhost',\n '127.0.0.1',\n '::1',\n '0000:0000:0000:0000:0000:0000:0000:0001',\n]);\n\nconst wildcardHosts = new Set(['0.0.0.0', '::', '0000:0000:0000:0000:0000:0000:0000:0000']);\n\n/**\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#LL819C8-L830C2\n */\nasync function getLocalhostAddressIfDiffersFromDNS(): Promise<string | undefined> {\n const [nodeResult, dnsResult] = await Promise.all([\n dns.lookup('localhost'),\n dns.lookup('localhost', { verbatim: true }),\n ]);\n const isSame = nodeResult.family === dnsResult.family && nodeResult.address === dnsResult.address;\n\n return isSame ? undefined : nodeResult.address;\n}\n\n/**\n * Resolve hostname\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#LL852C1-L878C2\n * vite not export this function\n */\nasync function resolveHostname(optionsHost: string | boolean | undefined): Promise<IHostname> {\n let host: string | undefined;\n\n if (optionsHost === undefined || optionsHost === false) {\n // Use a secure default\n host = 'localhost';\n } else if (optionsHost === true) {\n // If passed --host in the CLI without arguments\n host = undefined; // undefined typically means 0.0.0.0 or :: (listen on all IPs)\n } else {\n host = optionsHost;\n }\n\n // Set host name to localhost when possible\n let name = host === undefined || wildcardHosts.has(host) ? 'localhost' : host;\n\n if (host === 'localhost') {\n // See #8647 for more details.\n const localhostAddr = await getLocalhostAddressIfDiffersFromDNS();\n\n if (localhostAddr) {\n name = localhostAddr;\n }\n }\n\n return { host, name };\n}\n\ninterface IResolveServerUrlsOptions {\n host: string;\n isHttps?: boolean;\n rawBase?: string;\n}\n\n/**\n * Resolve server urls\n * @see https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts#L956\n * vite not export this function\n */\nasync function resolveServerUrls(\n server: Server,\n options: IResolveServerUrlsOptions,\n): Promise<ResolvedServerUrls> {\n const address = server.address();\n\n const isAddressInfo = (x: AddressInfo | null | string): x is AddressInfo =>\n (typeof x === 'object' && Boolean(x?.address)) || false;\n\n if (!isAddressInfo(address)) {\n return { local: [], network: [] };\n }\n\n const { host, isHttps, rawBase } = options;\n\n const local: string[] = [];\n const network: string[] = [];\n const hostname = await resolveHostname(host);\n const protocol = isHttps ? 'https' : 'http';\n const { port } = address;\n const base = rawBase === './' || rawBase === '' || !rawBase ? '/' : rawBase;\n\n if (hostname.host !== undefined && !wildcardHosts.has(hostname.host)) {\n let hostnameName = hostname.name;\n\n // ipv6 host\n if (hostnameName.includes(':')) {\n hostnameName = `[${hostnameName}]`;\n }\n\n const addressUrl = `${protocol}://${hostnameName}:${port}${base}`;\n\n if (loopbackHosts.has(hostname.host)) {\n local.push(addressUrl);\n } else {\n network.push(addressUrl);\n }\n } else {\n Object.values(os.networkInterfaces())\n .flatMap((nInterface) => nInterface ?? [])\n .filter(\n (detail) =>\n detail &&\n detail.address &&\n (detail.family === 'IPv4' ||\n // @ts-expect-error Node 18.0 - 18.3 returns number\n detail.family === 4),\n )\n .forEach((detail) => {\n let resultHost = detail.address.replace('127.0.0.1', hostname.name);\n\n // ipv6 host\n if (resultHost.includes(':')) {\n resultHost = `[${resultHost}]`;\n }\n\n const url = `${protocol}://${resultHost}:${port}${base}`;\n\n if (detail.address.includes('127.0.0.1')) {\n local.push(url);\n } else {\n network.push(url);\n }\n });\n }\n\n return { local, network };\n}\n\nexport default resolveServerUrls;\n"],"names":["loopbackHosts","Set","wildcardHosts","async","resolveHostname","optionsHost","host","undefined","name","has","localhostAddr","nodeResult","dnsResult","Promise","all","dns","lookup","verbatim","family","address","getLocalhostAddressIfDiffersFromDNS","resolveServerUrls","server","options","x","Boolean","local","network","isHttps","rawBase","hostname","protocol","port","base","Object","values","os","networkInterfaces","flatMap","nInterface","filter","detail","forEach","resultHost","replace","includes","url","push","hostnameName","addressUrl"],"mappings":"2DAUA,MAAMA,EAAgB,IAAIC,IAAI,CAC5B,YACA,YACA,MACA,4CAGIC,EAAgB,IAAID,IAAI,CAAC,UAAW,KAAM,4CAoBhDE,eAAeC,EAAgBC,GAC7B,IAAIC,EAIFA,OAFkBC,IAAhBF,IAA6C,IAAhBA,EAExB,aACkB,IAAhBA,OAEFE,EAEAF,EAIT,IAAIG,OAAgBD,IAATD,GAAsBJ,EAAcO,IAAIH,GAAQ,YAAcA,EAEzE,GAAa,cAATA,EAAsB,CAExB,MAAMI,QAjCVP,iBACE,MAAOQ,EAAYC,SAAmBC,QAAQC,IAAI,CAChDC,EAAIC,OAAO,aACXD,EAAIC,OAAO,YAAa,CAAEC,UAAU,MAItC,OAFeN,EAAWO,SAAWN,EAAUM,QAAUP,EAAWQ,UAAYP,EAAUO,aAE1EZ,EAAYI,EAAWQ,OACzC,CAyBgCC,GAExBV,IACFF,EAAOE,GAIX,MAAO,CAAEJ,OAAME,OACjB,CAaAL,eAAekB,EACbC,EACAC,GAEA,MAAMJ,EAAUG,EAAOH,UAKvB,GAFgB,iBADOK,EAGJL,KAFSM,QAAQD,GAAGL,SAGrC,MAAO,CAAEO,MAAO,GAAIC,QAAS,IAJT,IAACH,EAOvB,MAAMlB,KAAEA,EAAIsB,QAAEA,EAAOC,QAAEA,GAAYN,EAE7BG,EAAkB,GAClBC,EAAoB,GACpBG,QAAiB1B,EAAgBE,GACjCyB,EAAWH,EAAU,QAAU,QAC/BI,KAAEA,GAASb,EACXc,EAAmB,OAAZJ,GAAgC,KAAZA,GAAmBA,EAAgBA,EAAN,IAE9D,QAAsBtB,IAAlBuB,EAASxB,MAAuBJ,EAAcO,IAAIqB,EAASxB,MAgB7D4B,OAAOC,OAAOC,EAAGC,qBACdC,SAASC,GAAeA,GAAc,KACtCC,QACEC,GACCA,GACAA,EAAOtB,UACY,SAAlBsB,EAAOvB,QAEY,IAAlBuB,EAAOvB,UAEZwB,SAASD,IACR,IAAIE,EAAaF,EAAOtB,QAAQyB,QAAQ,YAAad,EAAStB,MAG1DmC,EAAWE,SAAS,OACtBF,EAAa,IAAIA,MAGnB,MAAMG,EAAM,GAAGf,OAAcY,KAAcX,IAAOC,IAE9CQ,EAAOtB,QAAQ0B,SAAS,aAC1BnB,EAAMqB,KAAKD,GAEXnB,EAAQoB,KAAKD,UAvCiD,CACpE,IAAIE,EAAelB,EAAStB,KAGxBwC,EAAaH,SAAS,OACxBG,EAAe,IAAIA,MAGrB,MAAMC,EAAa,GAAGlB,OAAciB,KAAgBhB,IAAOC,IAEvDjC,EAAcS,IAAIqB,EAASxB,MAC7BoB,EAAMqB,KAAKE,GAEXtB,EAAQoB,KAAKE,GA+BjB,MAAO,CAAEvB,QAAOC,UAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"serialize-errors.js","sources":["../../src/helpers/serialize-errors.ts"],"sourcesContent":["import { isRouteErrorResponse } from 'react-router';\nimport type { StaticHandlerContext } from 'react-router';\n\n/**\n * Serialize react router errors\n * @see https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/server.tsx#LL166C1-L188C2\n * https://github.com/remix-run/react-router/blob/main/LICENSE.md\n */\nfunction serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'] {\n if (!errors) {\n return null;\n }\n\n const entries = Object.entries(errors);\n const serialized: StaticHandlerContext['errors'] = {};\n for (const [key, val] of entries) {\n // Hey you! If you change this, please change the corresponding logic in\n // deserializeErrors in react-router-dom/index.tsx :)\n if (isRouteErrorResponse(val)) {\n serialized[key] = { ...val, __type: 'RouteErrorResponse' };\n } else if (val instanceof Error) {\n // Do not serialize stack traces from SSR for security reasons\n serialized[key] = {\n message: val.message,\n __type: 'Error',\n };\n } else {\n serialized[key] = val as unknown;\n }\n }\n\n return serialized;\n}\n\nexport default serializeErrors;\n"],"names":["serializeErrors","errors","entries","Object","serialized","key","val","isRouteErrorResponse","__type","Error","message"],"mappings":"oDAQA,SAASA,EAAgBC,GACvB,IAAKA,EACH,OAAO,KAGT,MAAMC,EAAUC,OAAOD,QAAQD,GACzBG,EAA6C,CAAA,EACnD,IAAK,MAAOC,EAAKC,KAAQJ,EAGnBK,EAAqBD,GACvBF,EAAWC,GAAO,IAAKC,EAAKE,OAAQ,sBAC3BF,aAAeG,MAExBL,EAAWC,GAAO,CAChBK,QAASJ,EAAII,QACbF,OAAQ,SAGVJ,EAAWC,GAAOC,EAItB,OAAOF,CACT"}
1
+ {"version":3,"file":"serialize-errors.js","sources":["../../src/helpers/serialize-errors.ts"],"sourcesContent":["import { isRouteErrorResponse } from 'react-router';\nimport type { StaticHandlerContext } from 'react-router';\n\n/**\n * Serialize react router errors\n * @see https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/server.tsx#LL166C1-L188C2\n * https://github.com/remix-run/react-router/blob/main/LICENSE.md\n */\nfunction serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'] {\n if (!errors) {\n return null;\n }\n\n const entries = Object.entries(errors);\n const serialized: StaticHandlerContext['errors'] = {};\n for (const [key, val] of entries) {\n // Hey you! If you change this, please change the corresponding logic in\n // deserializeErrors in react-router-dom/index.tsx :)\n if (isRouteErrorResponse(val)) {\n serialized[key] = { ...val, __type: 'RouteErrorResponse' };\n } else if (val instanceof Error) {\n // Do not serialize stack traces from SSR for security reasons\n serialized[key] = {\n message: val.message,\n __type: 'Error',\n };\n } else {\n serialized[key] = val as unknown;\n }\n }\n\n return serialized;\n}\n\nexport default serializeErrors;\n"],"names":["serializeErrors","errors","entries","Object","serialized","key","val","isRouteErrorResponse","__type","Error","message"],"mappings":"oDAQA,SAASA,EAAgBC,GACvB,IAAKA,EACH,OAAO,KAGT,MAAMC,EAAUC,OAAOD,QAAQD,GACzBG,EAA6C,CAAE,EACrD,IAAK,MAAOC,EAAKC,KAAQJ,EAGnBK,EAAqBD,GACvBF,EAAWC,GAAO,IAAKC,EAAKE,OAAQ,sBAC3BF,aAAeG,MAExBL,EAAWC,GAAO,CAChBK,QAASJ,EAAII,QACbF,OAAQ,SAGVJ,EAAWC,GAAOC,EAItB,OAAOF,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sources":["../../src/node/render.tsx"],"sourcesContent":["import chalk from 'chalk';\nimport type { Request, Response as ExpressResponse } from 'express';\nimport React from 'react';\nimport { renderToPipeableStream } from 'react-dom/server';\nimport type { StaticHandlerContext, StaticHandler } from 'react-router';\nimport { createStaticRouter, StaticRouterProvider } from 'react-router';\nimport StreamError from '@constants/stream-error';\nimport type { IServerContext } from '@context/server';\nimport { ServerProvider } from '@context/server';\nimport handleResponse from '@helpers/handle-response';\nimport type { IObtainStreamErrorOut } from '@helpers/obtain-stream-error';\nimport obtainStreamError from '@helpers/obtain-stream-error';\nimport createFetchRequest from '@node/create-fetch-request';\nimport type { TApp } from '@node/entry';\nimport writeResponse from '@node/write-response';\nimport type ServerConfig from '@services/server-config';\nimport SsrManifest from '@services/ssr-manifest';\n\nexport interface IRequestContext<TAppProps = Record<any, any>> {\n req: Request;\n res: ExpressResponse;\n appProps: NonNullable<TAppProps>;\n html: { header: string; footer: string };\n routerContext?: StaticHandlerContext;\n serverContext?: IServerContext;\n isStream?: boolean;\n hasEarlyHints?: boolean;\n didError?: StreamError;\n}\n\nexport type TRender<TAppProps = Record<any, any>> = (\n config: ServerConfig,\n context: IRequestContext<TAppProps>,\n options: IRenderOptions,\n) => Promise<void>;\n\nexport interface IRenderParams<TAppProps = Record<string, any>> {\n App: TApp<TAppProps>;\n handler: StaticHandler;\n}\n\nexport interface IRenderOptions<TAppProps = Record<string, any>> {\n abortDelay?: number;\n onRouterReady?: (params: {\n context: IRequestContext<TAppProps>;\n }) => Promise<IRouterReadyOut> | IRouterReadyOut;\n onShellReady?: (params: { context: IRequestContext<TAppProps> }) => IShellReadyOut;\n onShellError?: (params: {\n context: IRequestContext<TAppProps>;\n error: Error;\n }) => string | undefined | void; // return html or undefined\n onError?: (params: { context: IRequestContext<TAppProps>; error: IObtainStreamErrorOut }) => void;\n onResponse?: (params: {\n context: IRequestContext<TAppProps>;\n html: string;\n }) => string | undefined | void;\n getState?: (params: {\n context: IRequestContext<TAppProps>;\n }) => Record<string, Record<string, any>> | undefined | void;\n}\n\nexport interface IRouterReadyOut {\n isStream?: boolean;\n}\n\nexport interface IShellReadyOut {\n header?: string;\n footer?: string;\n}\n\n/**\n * Render application\n */\nasync function render(\n { App, handler }: IRenderParams, // @see entry (bind)\n config: ServerConfig,\n context: IRequestContext,\n {\n onRouterReady,\n onShellReady,\n onResponse,\n onShellError,\n onError,\n getState,\n abortDelay = 15000,\n }: IRenderOptions,\n): Promise<void> {\n const { req, res } = context;\n const fetchRequest = createFetchRequest(req);\n\n context.routerContext = (await handler.query(fetchRequest, {\n requestContext: context,\n })) as StaticHandlerContext;\n\n /**\n * Handle response from page loader, router context can be Response\n */\n const statusCode = handleResponse(res, context.routerContext);\n\n if (!statusCode) {\n return;\n }\n\n SsrManifest.get(config).injectAssets(context);\n\n const { isStream = true } = (await onRouterReady?.({ context })) ?? {};\n\n context.isStream = isStream;\n context.serverContext = {\n response: null,\n isServer: true,\n basename: context.routerContext?.basename,\n };\n\n const router = createStaticRouter(handler.dataRoutes, context.routerContext);\n const write = res.write.bind(res) as ExpressResponse['write'];\n const Logger = config.getLogger();\n let abortTimer: NodeJS.Timer | undefined = undefined;\n\n /**\n * Listen response and stream to add possibility modify html on fly\n * E.g. listen stream and append some data\n */\n res.write = (data: string | Uint8Array, ...args): boolean => {\n const isString = typeof data === 'string';\n const html = isString ? data : Buffer.from(data).toString();\n const modifiedHtml = onResponse?.({ context, html });\n\n if (modifiedHtml) {\n // @ts-ignore\n return write(isString ? modifiedHtml : Buffer.from(modifiedHtml), ...args) as boolean;\n }\n\n // @ts-ignore\n return write(data, ...args) as boolean;\n };\n\n const { serverContext, routerContext, appProps } = context;\n\n const { pipe, abort } = renderToPipeableStream(\n <ServerProvider context={serverContext}>\n <App server={{ ...appProps, req }}>\n <StaticRouterProvider router={router} context={routerContext} hydrate={false} />\n </App>\n </ServerProvider>,\n {\n onShellReady(): void {\n if (!isStream) {\n return;\n }\n\n writeResponse(context, {\n pipe,\n statusCode,\n onShellReady,\n getState,\n });\n },\n onAllReady(): void {\n clearTimeout(abortTimer);\n\n if (isStream) {\n return;\n }\n\n writeResponse(context, {\n pipe,\n statusCode,\n onShellReady,\n getState,\n });\n },\n onShellError(e: Error): void {\n const htmlError =\n onShellError?.({ context, error: e }) ||\n `<!doctype html><p>Something went wrong: ${e.message}</p>`;\n\n res.status(500);\n res.setHeader('content-type', 'text/html');\n res.send(htmlError);\n },\n onError(err): void {\n clearTimeout(abortTimer);\n\n const error = obtainStreamError(err);\n const { code, message } = error;\n const { didError } = context;\n\n context.didError = didError ?? code;\n\n onError?.({ context, error });\n Logger.info(chalk.red(`Stream error. Code: ${code}`));\n\n if (\n [StreamError.RenderAborted, StreamError.RenderTimeout, StreamError.RenderCancel].includes(\n code,\n )\n ) {\n Logger.info(chalk.dim(message));\n\n return;\n }\n\n Logger.error(err as string);\n },\n },\n );\n\n // Abandon and switch to client rendering if enough time passes.\n abortTimer = setTimeout(() => {\n context.didError = StreamError.RenderTimeout;\n abort();\n }, abortDelay);\n\n // Detect cancel request\n req.on('close', () => {\n context.didError = StreamError.RenderCancel;\n abort();\n });\n}\n\nexport default render;\n"],"names":["async","render","App","handler","config","context","onRouterReady","onShellReady","onResponse","onShellError","onError","getState","abortDelay","req","res","fetchRequest","createFetchRequest","routerContext","query","requestContext","statusCode","handleResponse","SsrManifest","get","injectAssets","isStream","serverContext","response","isServer","basename","router","createStaticRouter","dataRoutes","write","bind","Logger","getLogger","abortTimer","data","args","isString","html","Buffer","from","toString","modifiedHtml","appProps","pipe","abort","renderToPipeableStream","React","createElement","ServerProvider","server","StaticRouterProvider","hydrate","writeResponse","onAllReady","clearTimeout","e","htmlError","error","message","status","setHeader","send","err","obtainStreamError","code","didError","info","chalk","red","StreamError","RenderAborted","RenderTimeout","RenderCancel","includes","dim","setTimeout","on"],"mappings":"ueAyEAA,eAAeC,GACbC,IAAEA,EAAGC,QAAEA,GACPC,EACAC,GACAC,cACEA,EAAaC,aACbA,EAAYC,WACZA,EAAUC,aACVA,EAAYC,QACZA,EAAOC,SACPA,EAAQC,WACRA,EAAa,OAGf,MAAMC,IAAEA,EAAGC,IAAEA,GAAQT,EACfU,EAAeC,EAAmBH,GAExCR,EAAQY,oBAAuBd,EAAQe,MAAMH,EAAc,CACzDI,eAAgBd,IAMlB,MAAMe,EAAaC,EAAeP,EAAKT,EAAQY,eAE/C,IAAKG,EACH,OAGFE,EAAYC,IAAInB,GAAQoB,aAAanB,GAErC,MAAMoB,SAAEA,GAAW,SAAgBnB,IAAgB,CAAED,cAAe,GAEpEA,EAAQoB,SAAWA,EACnBpB,EAAQqB,cAAgB,CACtBC,SAAU,KACVC,UAAU,EACVC,SAAUxB,EAAQY,eAAeY,UAGnC,MAAMC,EAASC,EAAmB5B,EAAQ6B,WAAY3B,EAAQY,eACxDgB,EAAQnB,EAAImB,MAAMC,KAAKpB,GACvBqB,EAAS/B,EAAOgC,YACtB,IAAIC,EAMJvB,EAAImB,MAAQ,CAACK,KAA8BC,KACzC,MAAMC,EAA2B,iBAATF,EAClBG,EAAOD,EAAWF,EAAOI,OAAOC,KAAKL,GAAMM,WAC3CC,EAAerC,IAAa,CAAEH,UAASoC,SAE7C,OAAII,EAEKZ,EAAMO,EAAWK,EAAeH,OAAOC,KAAKE,MAAkBN,GAIhEN,EAAMK,KAASC,EAAgB,EAGxC,MAAMb,cAAEA,EAAaT,cAAEA,EAAa6B,SAAEA,GAAazC,GAE7C0C,KAAEA,EAAIC,MAAEA,GAAUC,EACtBC,EAACC,cAAAC,EAAe,CAAA/C,QAASqB,GACvBwB,EAACC,cAAAjD,GAAImD,OAAQ,IAAKP,EAAUjC,QAC1BqC,EAAAC,cAACG,EAAqB,CAAAxB,OAAQA,EAAQzB,QAASY,EAAesC,SAAS,MAG3E,CACEhD,eACOkB,GAIL+B,EAAcnD,EAAS,CACrB0C,OACA3B,aACAb,eACAI,YAEH,EACD8C,aACEC,aAAarB,GAETZ,GAIJ+B,EAAcnD,EAAS,CACrB0C,OACA3B,aACAb,eACAI,YAEH,EACDF,aAAakD,GACX,MAAMC,EACJnD,IAAe,CAAEJ,UAASwD,MAAOF,KACjC,2CAA2CA,EAAEG,cAE/ChD,EAAIiD,OAAO,KACXjD,EAAIkD,UAAU,eAAgB,aAC9BlD,EAAImD,KAAKL,EACV,EACDlD,QAAQwD,GACNR,aAAarB,GAEb,MAAMwB,EAAQM,EAAkBD,IAC1BE,KAAEA,EAAIN,QAAEA,GAAYD,GACpBQ,SAAEA,GAAahE,EAErBA,EAAQgE,SAAWA,GAAYD,EAE/B1D,IAAU,CAAEL,UAASwD,UACrB1B,EAAOmC,KAAKC,EAAMC,IAAI,uBAAuBJ,MAG3C,CAACK,EAAYC,cAAeD,EAAYE,cAAeF,EAAYG,cAAcC,SAC/ET,GAGFjC,EAAOmC,KAAKC,EAAMO,IAAIhB,IAKxB3B,EAAO0B,MAAMK,EACd,IAKL7B,EAAa0C,YAAW,KACtB1E,EAAQgE,SAAWI,EAAYE,cAC/B3B,GAAO,GACNpC,GAGHC,EAAImE,GAAG,SAAS,KACd3E,EAAQgE,SAAWI,EAAYG,aAC/B5B,GAAO,GAEX"}
1
+ {"version":3,"file":"render.js","sources":["../../src/node/render.tsx"],"sourcesContent":["import chalk from 'chalk';\nimport type { Request, Response as ExpressResponse } from 'express';\nimport React from 'react';\nimport { renderToPipeableStream } from 'react-dom/server';\nimport type { StaticHandlerContext, StaticHandler } from 'react-router';\nimport { createStaticRouter, StaticRouterProvider } from 'react-router';\nimport StreamError from '@constants/stream-error';\nimport type { IServerContext } from '@context/server';\nimport { ServerProvider } from '@context/server';\nimport handleResponse from '@helpers/handle-response';\nimport type { IObtainStreamErrorOut } from '@helpers/obtain-stream-error';\nimport obtainStreamError from '@helpers/obtain-stream-error';\nimport createFetchRequest from '@node/create-fetch-request';\nimport type { TApp } from '@node/entry';\nimport writeResponse from '@node/write-response';\nimport type ServerConfig from '@services/server-config';\nimport SsrManifest from '@services/ssr-manifest';\n\nexport interface IRequestContext<TAppProps = Record<any, any>> {\n req: Request;\n res: ExpressResponse;\n appProps: NonNullable<TAppProps>;\n html: { header: string; footer: string };\n routerContext?: StaticHandlerContext;\n serverContext?: IServerContext;\n isStream?: boolean;\n hasEarlyHints?: boolean;\n didError?: StreamError;\n}\n\nexport type TRender<TAppProps = Record<any, any>> = (\n config: ServerConfig,\n context: IRequestContext<TAppProps>,\n options: IRenderOptions,\n) => Promise<void>;\n\nexport interface IRenderParams<TAppProps = Record<string, any>> {\n App: TApp<TAppProps>;\n handler: StaticHandler;\n}\n\nexport interface IRenderOptions<TAppProps = Record<string, any>> {\n abortDelay?: number;\n onRouterReady?: (params: {\n context: IRequestContext<TAppProps>;\n }) => Promise<IRouterReadyOut> | IRouterReadyOut;\n onShellReady?: (params: { context: IRequestContext<TAppProps> }) => IShellReadyOut;\n onShellError?: (params: {\n context: IRequestContext<TAppProps>;\n error: Error;\n }) => string | undefined | void; // return html or undefined\n onError?: (params: { context: IRequestContext<TAppProps>; error: IObtainStreamErrorOut }) => void;\n onResponse?: (params: {\n context: IRequestContext<TAppProps>;\n html: string;\n }) => string | undefined | void;\n getState?: (params: {\n context: IRequestContext<TAppProps>;\n }) => Record<string, Record<string, any>> | undefined | void;\n}\n\nexport interface IRouterReadyOut {\n isStream?: boolean;\n}\n\nexport interface IShellReadyOut {\n header?: string;\n footer?: string;\n}\n\n/**\n * Render application\n */\nasync function render(\n { App, handler }: IRenderParams, // @see entry (bind)\n config: ServerConfig,\n context: IRequestContext,\n {\n onRouterReady,\n onShellReady,\n onResponse,\n onShellError,\n onError,\n getState,\n abortDelay = 15000,\n }: IRenderOptions,\n): Promise<void> {\n const { req, res } = context;\n const fetchRequest = createFetchRequest(req);\n\n context.routerContext = (await handler.query(fetchRequest, {\n requestContext: context,\n })) as StaticHandlerContext;\n\n /**\n * Handle response from page loader, router context can be Response\n */\n const statusCode = handleResponse(res, context.routerContext);\n\n if (!statusCode) {\n return;\n }\n\n SsrManifest.get(config).injectAssets(context);\n\n const { isStream = true } = (await onRouterReady?.({ context })) ?? {};\n\n context.isStream = isStream;\n context.serverContext = {\n response: null,\n isServer: true,\n basename: context.routerContext?.basename,\n };\n\n const router = createStaticRouter(handler.dataRoutes, context.routerContext);\n const write = res.write.bind(res) as ExpressResponse['write'];\n const Logger = config.getLogger();\n let abortTimer: NodeJS.Timer | undefined = undefined;\n\n /**\n * Listen response and stream to add possibility modify html on fly\n * E.g. listen stream and append some data\n */\n res.write = (data: string | Uint8Array, ...args): boolean => {\n const isString = typeof data === 'string';\n const html = isString ? data : Buffer.from(data).toString();\n const modifiedHtml = onResponse?.({ context, html });\n\n if (modifiedHtml) {\n // @ts-ignore\n return write(isString ? modifiedHtml : Buffer.from(modifiedHtml), ...args) as boolean;\n }\n\n // @ts-ignore\n return write(data, ...args) as boolean;\n };\n\n const { serverContext, routerContext, appProps } = context;\n\n const { pipe, abort } = renderToPipeableStream(\n <ServerProvider context={serverContext}>\n <App server={{ ...appProps, req }}>\n <StaticRouterProvider router={router} context={routerContext} hydrate={false} />\n </App>\n </ServerProvider>,\n {\n onShellReady(): void {\n if (!isStream) {\n return;\n }\n\n writeResponse(context, {\n pipe,\n statusCode,\n onShellReady,\n getState,\n });\n },\n onAllReady(): void {\n clearTimeout(abortTimer);\n\n if (isStream) {\n return;\n }\n\n writeResponse(context, {\n pipe,\n statusCode,\n onShellReady,\n getState,\n });\n },\n onShellError(e: Error): void {\n const htmlError =\n onShellError?.({ context, error: e }) ||\n `<!doctype html><p>Something went wrong: ${e.message}</p>`;\n\n res.status(500);\n res.setHeader('content-type', 'text/html');\n res.send(htmlError);\n },\n onError(err): void {\n clearTimeout(abortTimer);\n\n const error = obtainStreamError(err);\n const { code, message } = error;\n const { didError } = context;\n\n context.didError = didError ?? code;\n\n onError?.({ context, error });\n Logger.info(chalk.red(`Stream error. Code: ${code}`));\n\n if (\n [StreamError.RenderAborted, StreamError.RenderTimeout, StreamError.RenderCancel].includes(\n code,\n )\n ) {\n Logger.info(chalk.dim(message));\n\n return;\n }\n\n Logger.error(err as string);\n },\n },\n );\n\n // Abandon and switch to client rendering if enough time passes.\n abortTimer = setTimeout(() => {\n context.didError = StreamError.RenderTimeout;\n abort();\n }, abortDelay);\n\n // Detect cancel request\n req.on('close', () => {\n context.didError = StreamError.RenderCancel;\n abort();\n });\n}\n\nexport default render;\n"],"names":["async","render","App","handler","config","context","onRouterReady","onShellReady","onResponse","onShellError","onError","getState","abortDelay","req","res","fetchRequest","createFetchRequest","routerContext","query","requestContext","statusCode","handleResponse","SsrManifest","get","injectAssets","isStream","serverContext","response","isServer","basename","router","createStaticRouter","dataRoutes","write","bind","Logger","getLogger","abortTimer","data","args","isString","html","Buffer","from","toString","modifiedHtml","appProps","pipe","abort","renderToPipeableStream","React","createElement","ServerProvider","server","StaticRouterProvider","hydrate","writeResponse","onAllReady","clearTimeout","e","htmlError","error","message","status","setHeader","send","err","obtainStreamError","code","didError","info","chalk","red","StreamError","RenderAborted","RenderTimeout","RenderCancel","includes","dim","setTimeout","on"],"mappings":"ueAyEAA,eAAeC,GACbC,IAAEA,EAAGC,QAAEA,GACPC,EACAC,GACAC,cACEA,EAAaC,aACbA,EAAYC,WACZA,EAAUC,aACVA,EAAYC,QACZA,EAAOC,SACPA,EAAQC,WACRA,EAAa,OAGf,MAAMC,IAAEA,EAAGC,IAAEA,GAAQT,EACfU,EAAeC,EAAmBH,GAExCR,EAAQY,oBAAuBd,EAAQe,MAAMH,EAAc,CACzDI,eAAgBd,IAMlB,MAAMe,EAAaC,EAAeP,EAAKT,EAAQY,eAE/C,IAAKG,EACH,OAGFE,EAAYC,IAAInB,GAAQoB,aAAanB,GAErC,MAAMoB,SAAEA,GAAW,SAAgBnB,IAAgB,CAAED,cAAe,CAAE,EAEtEA,EAAQoB,SAAWA,EACnBpB,EAAQqB,cAAgB,CACtBC,SAAU,KACVC,UAAU,EACVC,SAAUxB,EAAQY,eAAeY,UAGnC,MAAMC,EAASC,EAAmB5B,EAAQ6B,WAAY3B,EAAQY,eACxDgB,EAAQnB,EAAImB,MAAMC,KAAKpB,GACvBqB,EAAS/B,EAAOgC,YACtB,IAAIC,EAMJvB,EAAImB,MAAQ,CAACK,KAA8BC,KACzC,MAAMC,EAA2B,iBAATF,EAClBG,EAAOD,EAAWF,EAAOI,OAAOC,KAAKL,GAAMM,WAC3CC,EAAerC,IAAa,CAAEH,UAASoC,SAE7C,OAAII,EAEKZ,EAAMO,EAAWK,EAAeH,OAAOC,KAAKE,MAAkBN,GAIhEN,EAAMK,KAASC,EAAgB,EAGxC,MAAMb,cAAEA,EAAaT,cAAEA,EAAa6B,SAAEA,GAAazC,GAE7C0C,KAAEA,EAAIC,MAAEA,GAAUC,EACtBC,EAACC,cAAAC,EAAe,CAAA/C,QAASqB,GACvBwB,EAACC,cAAAjD,GAAImD,OAAQ,IAAKP,EAAUjC,QAC1BqC,EAAAC,cAACG,EAAqB,CAAAxB,OAAQA,EAAQzB,QAASY,EAAesC,SAAS,MAG3E,CACEhD,eACOkB,GAIL+B,EAAcnD,EAAS,CACrB0C,OACA3B,aACAb,eACAI,YAEH,EACD8C,aACEC,aAAarB,GAETZ,GAIJ+B,EAAcnD,EAAS,CACrB0C,OACA3B,aACAb,eACAI,YAEH,EACDF,aAAakD,GACX,MAAMC,EACJnD,IAAe,CAAEJ,UAASwD,MAAOF,KACjC,2CAA2CA,EAAEG,cAE/ChD,EAAIiD,OAAO,KACXjD,EAAIkD,UAAU,eAAgB,aAC9BlD,EAAImD,KAAKL,EACV,EACDlD,QAAQwD,GACNR,aAAarB,GAEb,MAAMwB,EAAQM,EAAkBD,IAC1BE,KAAEA,EAAIN,QAAEA,GAAYD,GACpBQ,SAAEA,GAAahE,EAErBA,EAAQgE,SAAWA,GAAYD,EAE/B1D,IAAU,CAAEL,UAASwD,UACrB1B,EAAOmC,KAAKC,EAAMC,IAAI,uBAAuBJ,MAG3C,CAACK,EAAYC,cAAeD,EAAYE,cAAeF,EAAYG,cAAcC,SAC/ET,GAGFjC,EAAOmC,KAAKC,EAAMO,IAAIhB,IAKxB3B,EAAO0B,MAAMK,EACd,IAKL7B,EAAa0C,YAAW,KACtB1E,EAAQgE,SAAWI,EAAYE,cAC/B3B,GAAO,GACNpC,GAGHC,EAAImE,GAAG,SAAS,KACd3E,EAAQgE,SAAWI,EAAYG,aAC/B5B,GAAO,GAEX"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sources":["../../src/node/server.ts"],"sourcesContent":["import http from 'node:http';\nimport https from 'node:https';\nimport type { Server } from 'node:net';\nimport path from 'path';\nimport compression from 'compression';\nimport type { Express } from 'express';\nimport express from 'express';\nimport printServerInfo from '@helpers/print-server-info';\nimport type { IRequestContext } from '@node/render';\nimport PrepareServer from '@services/prepare-server';\nimport ServerApi from '@services/server-api';\nimport type ServerConfig from '@services/server-config';\n\nexport interface ICreateServerOut {\n run: (options?: { version?: string; isPrintInfo?: boolean }) => Server;\n app: Express;\n}\n\n/**\n * Create SSR server\n */\nasync function createServer(config: ServerConfig): Promise<ICreateServerOut> {\n const app = express().disable('x-powered-by');\n const serverApi = new ServerApi();\n\n config.setApp(app);\n\n const prepareServer = PrepareServer.init(config, serverApi);\n\n if (!config.isProd) {\n // Create Vite server in middleware mode and configure the app type as\n // 'custom', disabling Vite's own HTML serving logic so parent server\n // can take control\n const vite = await (\n await import('vite')\n ).createServer({\n server: {\n middlewareMode: true,\n watch: {\n // During tests, we edit the files too fast and sometimes chokidar\n // misses change events, so enforce polling for consistency\n usePolling: true,\n interval: 100,\n },\n },\n appType: 'custom',\n mode: config.mode,\n });\n\n // Use vite's connect instance as middleware\n app.use(vite.middlewares);\n\n config.setVite(vite);\n }\n\n const { isSPA } = config.getParams();\n\n if (!isSPA) {\n await prepareServer.onAppCreated();\n }\n\n if (config.isProd) {\n const { root, publicDir } = config.getParams();\n const { compression: compressionConfig, expressStatic } = prepareServer.getMiddlewaresConfig();\n\n if (compressionConfig) {\n app.use(compression(compressionConfig));\n }\n\n if (!isSPA) {\n // ignore index.html file in SSR mode\n app.use((req, _, next) => {\n if (req.url === '/index.html' && !serverApi.hasAccessIndexHtml()) {\n req.url = '/index-not-found.html';\n }\n\n next();\n });\n }\n\n if (expressStatic) {\n const { basename, ...expressStaticOpts } = expressStatic;\n\n app.use(\n basename!,\n express.static(path.resolve(`${root}/${publicDir}`), {\n ...expressStaticOpts,\n index: isSPA ? undefined : false,\n }),\n );\n }\n }\n\n // SSR mode\n if (!isSPA) {\n app.use('*', (req, res, next) => {\n void (async () => {\n try {\n const [{ render, onRequest, ...renderParams }, clientHtml] = await Promise.all([\n prepareServer.loadEntrypoint(),\n prepareServer.loadHtml(req),\n ]);\n const { appProps, hasEarlyHints, shouldSkip } = (await onRequest?.(req, res)) ?? {};\n const [header, footer] = clientHtml;\n\n if (shouldSkip) {\n return next();\n }\n\n const context: IRequestContext = {\n req,\n res,\n hasEarlyHints,\n appProps: appProps ?? {},\n html: { header, footer },\n };\n\n await render(config, context, renderParams);\n } catch (e) {\n config\n .getLogger()\n .error(`Failed to handle request: ${(e as Error)?.message}`, { error: e as Error });\n next();\n }\n })();\n });\n } else {\n // SPA mode, redirect any request to index.html\n app.use('*', (req, res, next) => {\n void (async () => {\n try {\n const html = (await prepareServer.loadHtml(req)).join('');\n\n res.send(html);\n } catch (e) {\n config\n .getLogger()\n .error(`Failed to handle request: ${(e as Error)?.message}`, { error: e as Error });\n next();\n }\n })();\n });\n }\n\n return {\n run: ({ version, isPrintInfo = true } = {}): Server => {\n const { port, host } = config.getParams();\n const isHTTPS = Boolean(config.getVite()?.config?.server?.https);\n\n // update resolved host for print network link\n if (config.isHost && !config.isProd) {\n config.getVite()!.config.server.host = host;\n }\n\n const server = (\n isHTTPS\n ? https.createServer(config.getVite()!.config.server.https!, app)\n : http.createServer(app)\n ).listen(port, host, () => {\n void prepareServer.onServerStarted?.(app, serverApi, server);\n\n if (!isPrintInfo) {\n return;\n }\n\n void printServerInfo(config, { version, server });\n });\n\n return server;\n },\n app,\n };\n}\n\nexport default createServer;\n"],"names":["async","createServer","config","app","express","disable","serverApi","ServerApi","setApp","prepareServer","PrepareServer","init","isProd","vite","import","server","middlewareMode","watch","usePolling","interval","appType","mode","use","middlewares","setVite","isSPA","getParams","onAppCreated","root","publicDir","compression","compressionConfig","expressStatic","getMiddlewaresConfig","req","_","next","url","hasAccessIndexHtml","basename","expressStaticOpts","static","path","resolve","index","undefined","res","html","loadHtml","join","send","e","getLogger","error","message","render","onRequest","renderParams","clientHtml","Promise","all","loadEntrypoint","appProps","hasEarlyHints","shouldSkip","header","footer","context","run","version","isPrintInfo","port","host","isHTTPS","Boolean","getVite","https","isHost","http","listen","onServerStarted","printServerInfo"],"mappings":"8PAqBAA,eAAeC,EAAaC,GAC1B,MAAMC,EAAMC,IAAUC,QAAQ,gBACxBC,EAAY,IAAIC,EAEtBL,EAAOM,OAAOL,GAEd,MAAMM,EAAgBC,EAAcC,KAAKT,EAAQI,GAEjD,IAAKJ,EAAOU,OAAQ,CAIlB,MAAMC,cACEC,OAAO,SACbb,aAAa,CACbc,OAAQ,CACNC,gBAAgB,EAChBC,MAAO,CAGLC,YAAY,EACZC,SAAU,MAGdC,QAAS,SACTC,KAAMnB,EAAOmB,OAIflB,EAAImB,IAAIT,EAAKU,aAEbrB,EAAOsB,QAAQX,EAChB,CAED,MAAMY,MAAEA,GAAUvB,EAAOwB,YAMzB,GAJKD,SACGhB,EAAckB,eAGlBzB,EAAOU,OAAQ,CACjB,MAAMgB,KAAEA,EAAIC,UAAEA,GAAc3B,EAAOwB,aAC3BI,YAAaC,EAAiBC,cAAEA,GAAkBvB,EAAcwB,uBAiBxE,GAfIF,GACF5B,EAAImB,IAAIQ,EAAYC,IAGjBN,GAEHtB,EAAImB,KAAI,CAACY,EAAKC,EAAGC,KACC,gBAAZF,EAAIG,KAA0B/B,EAAUgC,uBAC1CJ,EAAIG,IAAM,yBAGZD,GAAM,IAINJ,EAAe,CACjB,MAAMO,SAAEA,KAAaC,GAAsBR,EAE3C7B,EAAImB,IACFiB,EACAnC,EAAQqC,OAAOC,EAAKC,QAAQ,GAAGf,KAAQC,KAAc,IAChDW,EACHI,QAAOnB,QAAQoB,IAGpB,CACF,CAqDD,OAlDKpB,EAkCHtB,EAAImB,IAAI,KAAK,CAACY,EAAKY,EAAKV,KACjB,WACH,IACE,MAAMW,SAActC,EAAcuC,SAASd,IAAMe,KAAK,IAEtDH,EAAII,KAAKH,EACV,CAAC,MAAOI,GACPjD,EACGkD,YACAC,MAAM,6BAA8BF,GAAaG,UAAW,CAAED,MAAOF,IACxEf,GACD,CACF,EAXI,EAWD,IA7CNjC,EAAImB,IAAI,KAAK,CAACY,EAAKY,EAAKV,KACjB,WACH,IACE,OAAOmB,OAAEA,EAAMC,UAAEA,KAAcC,GAAgBC,SAAoBC,QAAQC,IAAI,CAC7EnD,EAAcoD,iBACdpD,EAAcuC,SAASd,MAEnB4B,SAAEA,EAAQC,cAAEA,EAAaC,WAAEA,SAAsBR,IAAYtB,EAAKY,KAAS,IAC1EmB,EAAQC,GAAUR,EAEzB,GAAIM,EACF,OAAO5B,IAGT,MAAM+B,EAA2B,CAC/BjC,MACAY,MACAiB,gBACAD,SAAUA,GAAY,CAAE,EACxBf,KAAM,CAAEkB,SAAQC,iBAGZX,EAAOrD,EAAQiE,EAASV,EAC/B,CAAC,MAAON,GACPjD,EACGkD,YACAC,MAAM,6BAA8BF,GAAaG,UAAW,CAAED,MAAOF,IACxEf,GACD,CACF,EA5BI,EA4BD,IAoBD,CACLgC,IAAK,EAAGC,UAASC,eAAc,GAAS,CAAA,KACtC,MAAMC,KAAEA,EAAIC,KAAEA,GAAStE,EAAOwB,YACxB+C,EAAUC,QAAQxE,EAAOyE,WAAWzE,QAAQa,QAAQ6D,OAGtD1E,EAAO2E,SAAW3E,EAAOU,SAC3BV,EAAOyE,UAAWzE,OAAOa,OAAOyD,KAAOA,GAGzC,MAAMzD,GACJ0D,EACIG,EAAM3E,aAAaC,EAAOyE,UAAWzE,OAAOa,OAAO6D,MAAQzE,GAC3D2E,EAAK7E,aAAaE,IACtB4E,OAAOR,EAAMC,GAAM,KACd/D,EAAcuE,kBAAkB7E,EAAKG,EAAWS,GAEhDuD,GAIAW,EAAgB/E,EAAQ,CAAEmE,UAAStD,UAAS,IAGnD,OAAOA,CAAM,EAEfZ,MAEJ"}
1
+ {"version":3,"file":"server.js","sources":["../../src/node/server.ts"],"sourcesContent":["import http from 'node:http';\nimport https from 'node:https';\nimport type { Server } from 'node:net';\nimport path from 'path';\nimport compression from 'compression';\nimport type { Express } from 'express';\nimport express from 'express';\nimport printServerInfo from '@helpers/print-server-info';\nimport type { IRequestContext } from '@node/render';\nimport PrepareServer from '@services/prepare-server';\nimport ServerApi from '@services/server-api';\nimport type ServerConfig from '@services/server-config';\n\nexport interface ICreateServerOut {\n run: (options?: { version?: string; isPrintInfo?: boolean }) => Server;\n app: Express;\n}\n\n/**\n * Create SSR server\n */\nasync function createServer(config: ServerConfig): Promise<ICreateServerOut> {\n const app = express().disable('x-powered-by');\n const serverApi = new ServerApi();\n\n config.setApp(app);\n\n const prepareServer = PrepareServer.init(config, serverApi);\n\n if (!config.isProd) {\n // Create Vite server in middleware mode and configure the app type as\n // 'custom', disabling Vite's own HTML serving logic so parent server\n // can take control\n const vite = await (\n await import('vite')\n ).createServer({\n server: {\n middlewareMode: true,\n watch: {\n // During tests, we edit the files too fast and sometimes chokidar\n // misses change events, so enforce polling for consistency\n usePolling: true,\n interval: 100,\n },\n },\n appType: 'custom',\n mode: config.mode,\n });\n\n // Use vite's connect instance as middleware\n app.use(vite.middlewares);\n\n config.setVite(vite);\n }\n\n const { isSPA } = config.getParams();\n\n if (!isSPA) {\n await prepareServer.onAppCreated();\n }\n\n if (config.isProd) {\n const { root, publicDir } = config.getParams();\n const { compression: compressionConfig, expressStatic } = prepareServer.getMiddlewaresConfig();\n\n if (compressionConfig) {\n app.use(compression(compressionConfig));\n }\n\n if (!isSPA) {\n // ignore index.html file in SSR mode\n app.use((req, _, next) => {\n if (req.url === '/index.html' && !serverApi.hasAccessIndexHtml()) {\n req.url = '/index-not-found.html';\n }\n\n next();\n });\n }\n\n if (expressStatic) {\n const { basename, ...expressStaticOpts } = expressStatic;\n\n app.use(\n basename!,\n express.static(path.resolve(`${root}/${publicDir}`), {\n ...expressStaticOpts,\n index: isSPA ? undefined : false,\n }),\n );\n }\n }\n\n // SSR mode\n if (!isSPA) {\n app.use('*', (req, res, next) => {\n void (async () => {\n try {\n const [{ render, onRequest, ...renderParams }, clientHtml] = await Promise.all([\n prepareServer.loadEntrypoint(),\n prepareServer.loadHtml(req),\n ]);\n const { appProps, hasEarlyHints, shouldSkip } = (await onRequest?.(req, res)) ?? {};\n const [header, footer] = clientHtml;\n\n if (shouldSkip) {\n return next();\n }\n\n const context: IRequestContext = {\n req,\n res,\n hasEarlyHints,\n appProps: appProps ?? {},\n html: { header, footer },\n };\n\n await render(config, context, renderParams);\n } catch (e) {\n config\n .getLogger()\n .error(`Failed to handle request: ${(e as Error)?.message}`, { error: e as Error });\n next();\n }\n })();\n });\n } else {\n // SPA mode, redirect any request to index.html\n app.use('*', (req, res, next) => {\n void (async () => {\n try {\n const html = (await prepareServer.loadHtml(req)).join('');\n\n res.send(html);\n } catch (e) {\n config\n .getLogger()\n .error(`Failed to handle request: ${(e as Error)?.message}`, { error: e as Error });\n next();\n }\n })();\n });\n }\n\n return {\n run: ({ version, isPrintInfo = true } = {}): Server => {\n const { port, host } = config.getParams();\n const isHTTPS = Boolean(config.getVite()?.config?.server?.https);\n\n // update resolved host for print network link\n if (config.isHost && !config.isProd) {\n config.getVite()!.config.server.host = host;\n }\n\n const server = (\n isHTTPS\n ? https.createServer(config.getVite()!.config.server.https!, app)\n : http.createServer(app)\n ).listen(port, host, () => {\n void prepareServer.onServerStarted?.(app, serverApi, server);\n\n if (!isPrintInfo) {\n return;\n }\n\n void printServerInfo(config, { version, server });\n });\n\n return server;\n },\n app,\n };\n}\n\nexport default createServer;\n"],"names":["async","createServer","config","app","express","disable","serverApi","ServerApi","setApp","prepareServer","PrepareServer","init","isProd","vite","import","server","middlewareMode","watch","usePolling","interval","appType","mode","use","middlewares","setVite","isSPA","getParams","onAppCreated","root","publicDir","compression","compressionConfig","expressStatic","getMiddlewaresConfig","req","_","next","url","hasAccessIndexHtml","basename","expressStaticOpts","static","path","resolve","index","undefined","res","html","loadHtml","join","send","e","getLogger","error","message","render","onRequest","renderParams","clientHtml","Promise","all","loadEntrypoint","appProps","hasEarlyHints","shouldSkip","header","footer","context","run","version","isPrintInfo","port","host","isHTTPS","Boolean","getVite","https","isHost","http","listen","onServerStarted","printServerInfo"],"mappings":"8PAqBAA,eAAeC,EAAaC,GAC1B,MAAMC,EAAMC,IAAUC,QAAQ,gBACxBC,EAAY,IAAIC,EAEtBL,EAAOM,OAAOL,GAEd,MAAMM,EAAgBC,EAAcC,KAAKT,EAAQI,GAEjD,IAAKJ,EAAOU,OAAQ,CAIlB,MAAMC,cACEC,OAAO,SACbb,aAAa,CACbc,OAAQ,CACNC,gBAAgB,EAChBC,MAAO,CAGLC,YAAY,EACZC,SAAU,MAGdC,QAAS,SACTC,KAAMnB,EAAOmB,OAIflB,EAAImB,IAAIT,EAAKU,aAEbrB,EAAOsB,QAAQX,GAGjB,MAAMY,MAAEA,GAAUvB,EAAOwB,YAMzB,GAJKD,SACGhB,EAAckB,eAGlBzB,EAAOU,OAAQ,CACjB,MAAMgB,KAAEA,EAAIC,UAAEA,GAAc3B,EAAOwB,aAC3BI,YAAaC,EAAiBC,cAAEA,GAAkBvB,EAAcwB,uBAiBxE,GAfIF,GACF5B,EAAImB,IAAIQ,EAAYC,IAGjBN,GAEHtB,EAAImB,KAAI,CAACY,EAAKC,EAAGC,KACC,gBAAZF,EAAIG,KAA0B/B,EAAUgC,uBAC1CJ,EAAIG,IAAM,yBAGZD,GAAM,IAINJ,EAAe,CACjB,MAAMO,SAAEA,KAAaC,GAAsBR,EAE3C7B,EAAImB,IACFiB,EACAnC,EAAQqC,OAAOC,EAAKC,QAAQ,GAAGf,KAAQC,KAAc,IAChDW,EACHI,QAAOnB,QAAQoB,MAyDvB,OAlDKpB,EAkCHtB,EAAImB,IAAI,KAAK,CAACY,EAAKY,EAAKV,KACjB,WACH,IACE,MAAMW,SAActC,EAAcuC,SAASd,IAAMe,KAAK,IAEtDH,EAAII,KAAKH,GACT,MAAOI,GACPjD,EACGkD,YACAC,MAAM,6BAA8BF,GAAaG,UAAW,CAAED,MAAOF,IACxEf,IAEH,EAXI,EAWD,IA7CNjC,EAAImB,IAAI,KAAK,CAACY,EAAKY,EAAKV,KACjB,WACH,IACE,OAAOmB,OAAEA,EAAMC,UAAEA,KAAcC,GAAgBC,SAAoBC,QAAQC,IAAI,CAC7EnD,EAAcoD,iBACdpD,EAAcuC,SAASd,MAEnB4B,SAAEA,EAAQC,cAAEA,EAAaC,WAAEA,SAAsBR,IAAYtB,EAAKY,KAAS,CAAE,GAC5EmB,EAAQC,GAAUR,EAEzB,GAAIM,EACF,OAAO5B,IAGT,MAAM+B,EAA2B,CAC/BjC,MACAY,MACAiB,gBACAD,SAAUA,GAAY,CAAE,EACxBf,KAAM,CAAEkB,SAAQC,iBAGZX,EAAOrD,EAAQiE,EAASV,GAC9B,MAAON,GACPjD,EACGkD,YACAC,MAAM,6BAA8BF,GAAaG,UAAW,CAAED,MAAOF,IACxEf,IAEH,EA5BI,EA4BD,IAoBD,CACLgC,IAAK,EAAGC,UAASC,eAAc,GAAS,CAAA,KACtC,MAAMC,KAAEA,EAAIC,KAAEA,GAAStE,EAAOwB,YACxB+C,EAAUC,QAAQxE,EAAOyE,WAAWzE,QAAQa,QAAQ6D,OAGtD1E,EAAO2E,SAAW3E,EAAOU,SAC3BV,EAAOyE,UAAWzE,OAAOa,OAAOyD,KAAOA,GAGzC,MAAMzD,GACJ0D,EACIG,EAAM3E,aAAaC,EAAOyE,UAAWzE,OAAOa,OAAO6D,MAAQzE,GAC3D2E,EAAK7E,aAAaE,IACtB4E,OAAOR,EAAMC,GAAM,KACd/D,EAAcuE,kBAAkB7E,EAAKG,EAAWS,GAEhDuD,GAIAW,EAAgB/E,EAAQ,CAAEmE,UAAStD,UAAS,IAGnD,OAAOA,CAAM,EAEfZ,MAEJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"write-response.js","sources":["../../src/node/write-response.ts"],"sourcesContent":["import type { Response as ExpressResponse } from 'express';\nimport type { PipeableStream } from 'react-dom/server';\nimport buildCustomState from '@helpers/build-custom-state';\nimport buildRouterState from '@helpers/build-router-state';\nimport handleResponse from '@helpers/handle-response';\nimport type { IRenderOptions, IRequestContext } from '@node/render';\n\ninterface IWriteResponseParams {\n pipe: PipeableStream['pipe'];\n onShellReady: IRenderOptions['onShellReady'];\n getState: IRenderOptions['getState'];\n statusCode?: number; // default status\n}\n\n/**\n * Send response to client\n */\nconst writeResponse = (context: IRequestContext, params: IWriteResponseParams): void => {\n const { res, didError, serverContext, routerContext, html } = context;\n const { pipe, onShellReady, getState } = params;\n let { statusCode } = params;\n\n // handle response from server components (navigate, status)\n statusCode = handleResponse(res, serverContext!.response, statusCode);\n\n if (!statusCode) {\n return;\n }\n\n // catch close connection from React and write footer\n if (didError) {\n const end = res.end.bind(res) as ExpressResponse['end'];\n\n res.end = (...args: unknown[]): ExpressResponse => {\n // send second part of app shell\n res.write(modifiedFooter || html.footer);\n\n // @ts-ignore\n return end(...args);\n };\n }\n\n res.status(statusCode);\n res.setHeader('content-type', 'text/html');\n\n const { header: modifiedHeader, footer: modifiedFooter } = onShellReady?.({ context }) ?? {};\n const routerState = buildRouterState(routerContext!);\n const customState = buildCustomState(getState?.({ context }));\n\n html.footer = routerState + customState + html.footer;\n\n // send first part of app shell\n res.write(modifiedHeader || html.header);\n // start streaming app\n pipe(res);\n\n if (!didError) {\n // send second part of app shell\n res.write(modifiedFooter || html.footer);\n }\n};\n\nexport default writeResponse;\n"],"names":["writeResponse","context","params","res","didError","serverContext","routerContext","html","pipe","onShellReady","getState","statusCode","handleResponse","response","end","bind","args","write","modifiedFooter","footer","status","setHeader","header","modifiedHeader","routerState","buildRouterState","customState","buildCustomState"],"mappings":"6IAiBA,MAAMA,EAAgB,CAACC,EAA0BC,KAC/C,MAAMC,IAAEA,EAAGC,SAAEA,EAAQC,cAAEA,EAAaC,cAAEA,EAAaC,KAAEA,GAASN,GACxDO,KAAEA,EAAIC,aAAEA,EAAYC,SAAEA,GAAaR,EACzC,IAAIS,WAAEA,GAAeT,EAKrB,GAFAS,EAAaC,EAAeT,EAAKE,EAAeQ,SAAUF,IAErDA,EACH,OAIF,GAAIP,EAAU,CACZ,MAAMU,EAAMX,EAAIW,IAAIC,KAAKZ,GAEzBA,EAAIW,IAAM,IAAIE,KAEZb,EAAIc,MAAMC,GAAkBX,EAAKY,QAG1BL,KAAOE,GAEjB,CAEDb,EAAIiB,OAAOT,GACXR,EAAIkB,UAAU,eAAgB,aAE9B,MAAQC,OAAQC,EAAgBJ,OAAQD,GAAmBT,IAAe,CAAER,aAAc,GACpFuB,EAAcC,EAAiBnB,GAC/BoB,EAAcC,EAAiBjB,IAAW,CAAET,aAElDM,EAAKY,OAASK,EAAcE,EAAcnB,EAAKY,OAG/ChB,EAAIc,MAAMM,GAAkBhB,EAAKe,QAEjCd,EAAKL,GAEAC,GAEHD,EAAIc,MAAMC,GAAkBX,EAAKY,OAClC"}
1
+ {"version":3,"file":"write-response.js","sources":["../../src/node/write-response.ts"],"sourcesContent":["import type { Response as ExpressResponse } from 'express';\nimport type { PipeableStream } from 'react-dom/server';\nimport buildCustomState from '@helpers/build-custom-state';\nimport buildRouterState from '@helpers/build-router-state';\nimport handleResponse from '@helpers/handle-response';\nimport type { IRenderOptions, IRequestContext } from '@node/render';\n\ninterface IWriteResponseParams {\n pipe: PipeableStream['pipe'];\n onShellReady: IRenderOptions['onShellReady'];\n getState: IRenderOptions['getState'];\n statusCode?: number; // default status\n}\n\n/**\n * Send response to client\n */\nconst writeResponse = (context: IRequestContext, params: IWriteResponseParams): void => {\n const { res, didError, serverContext, routerContext, html } = context;\n const { pipe, onShellReady, getState } = params;\n let { statusCode } = params;\n\n // handle response from server components (navigate, status)\n statusCode = handleResponse(res, serverContext!.response, statusCode);\n\n if (!statusCode) {\n return;\n }\n\n // catch close connection from React and write footer\n if (didError) {\n const end = res.end.bind(res) as ExpressResponse['end'];\n\n res.end = (...args: unknown[]): ExpressResponse => {\n // send second part of app shell\n res.write(modifiedFooter || html.footer);\n\n // @ts-ignore\n return end(...args);\n };\n }\n\n res.status(statusCode);\n res.setHeader('content-type', 'text/html');\n\n const { header: modifiedHeader, footer: modifiedFooter } = onShellReady?.({ context }) ?? {};\n const routerState = buildRouterState(routerContext!);\n const customState = buildCustomState(getState?.({ context }));\n\n html.footer = routerState + customState + html.footer;\n\n // send first part of app shell\n res.write(modifiedHeader || html.header);\n // start streaming app\n pipe(res);\n\n if (!didError) {\n // send second part of app shell\n res.write(modifiedFooter || html.footer);\n }\n};\n\nexport default writeResponse;\n"],"names":["writeResponse","context","params","res","didError","serverContext","routerContext","html","pipe","onShellReady","getState","statusCode","handleResponse","response","end","bind","args","write","modifiedFooter","footer","status","setHeader","header","modifiedHeader","routerState","buildRouterState","customState","buildCustomState"],"mappings":"6IAiBA,MAAMA,EAAgB,CAACC,EAA0BC,KAC/C,MAAMC,IAAEA,EAAGC,SAAEA,EAAQC,cAAEA,EAAaC,cAAEA,EAAaC,KAAEA,GAASN,GACxDO,KAAEA,EAAIC,aAAEA,EAAYC,SAAEA,GAAaR,EACzC,IAAIS,WAAEA,GAAeT,EAKrB,GAFAS,EAAaC,EAAeT,EAAKE,EAAeQ,SAAUF,IAErDA,EACH,OAIF,GAAIP,EAAU,CACZ,MAAMU,EAAMX,EAAIW,IAAIC,KAAKZ,GAEzBA,EAAIW,IAAM,IAAIE,KAEZb,EAAIc,MAAMC,GAAkBX,EAAKY,QAG1BL,KAAOE,IAIlBb,EAAIiB,OAAOT,GACXR,EAAIkB,UAAU,eAAgB,aAE9B,MAAQC,OAAQC,EAAgBJ,OAAQD,GAAmBT,IAAe,CAAER,aAAc,CAAE,EACtFuB,EAAcC,EAAiBnB,GAC/BoB,EAAcC,EAAiBjB,IAAW,CAAET,aAElDM,EAAKY,OAASK,EAAcE,EAAcnB,EAAKY,OAG/ChB,EAAIc,MAAMM,GAAkBhB,EAAKe,QAEjCd,EAAKL,GAEAC,GAEHD,EAAIc,MAAMC,GAAkBX,EAAKY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lomray/vite-ssr-boost",
3
- "version": "4.0.0-beta.1",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "Vite plugin for create awesome SSR or SPA applications on React.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -30,50 +30,51 @@
30
30
  "lint:check": "eslint \"src/**/*.{ts,tsx,*.ts,*tsx}\"",
31
31
  "lint:format": "eslint --fix \"src/**/*.{ts,tsx,*.ts,*tsx}\"",
32
32
  "ts:check": "tsc --project ./tsconfig.json --skipLibCheck --noemit",
33
- "test": "vitest run"
33
+ "test": "vitest run",
34
+ "test:coverage": "vitest run --coverage"
34
35
  },
35
36
  "dependencies": {
36
- "chalk": "^5.3.0",
37
+ "chalk": "^5.4.1",
37
38
  "commander": "^12.1.0",
38
39
  "compression": "^1.7.5",
39
- "express": "^4.21.1",
40
+ "express": "^4.21.2",
40
41
  "hoist-non-react-statics": "^3.3.2",
41
42
  "json5": "^2.2.3"
42
43
  },
43
44
  "devDependencies": {
44
- "@commitlint/cli": "^19.5.0",
45
- "@commitlint/config-conventional": "^19.5.0",
45
+ "@commitlint/cli": "^19.6.1",
46
+ "@commitlint/config-conventional": "^19.6.0",
46
47
  "@lomray/eslint-config-react": "^5.0.6",
47
48
  "@lomray/prettier-config": "^2.0.1",
48
49
  "@rollup/plugin-terser": "^0.4.4",
49
- "@testing-library/react": "^15.0.7",
50
+ "@testing-library/react": "^16.1.0",
50
51
  "@types/babel__generator": "^7.6.8",
51
52
  "@types/babel__traverse": "^7.20.6",
52
- "@types/chai": "^5.0.0",
53
+ "@types/chai": "^5.0.1",
53
54
  "@types/compression": "^1.7.5",
54
- "@types/hoist-non-react-statics": "^3.3.5",
55
+ "@types/hoist-non-react-statics": "^3.3.6",
55
56
  "@types/react-dom": "^18.3.0",
56
57
  "@types/sinon": "^17.0.3",
57
58
  "@types/sinon-chai": "^4.0.0",
58
- "@vitest/coverage-v8": "^2.1.6",
59
+ "@vitest/coverage-v8": "^2.1.8",
59
60
  "@zerollup/ts-transform-paths": "^1.7.18",
60
- "chai": "^5.1.1",
61
+ "chai": "^5.1.2",
61
62
  "eslint": "^8.57.0",
62
- "husky": "^9.1.6",
63
- "jsdom": "^24.0.0",
64
- "lint-staged": "^15.2.10",
65
- "prettier": "^3.3.3",
66
- "rollup": "^4.24.0",
63
+ "husky": "^9.1.7",
64
+ "jsdom": "^26.0.0",
65
+ "lint-staged": "^15.3.0",
66
+ "prettier": "^3.4.2",
67
+ "rollup": "^4.30.1",
67
68
  "rollup-plugin-copy": "^3.5.0",
68
69
  "rollup-plugin-folder-input": "^1.0.1",
69
70
  "rollup-plugin-peer-deps-external": "^2.2.4",
70
71
  "rollup-plugin-preserve-shebangs": "^0.2.0",
71
72
  "rollup-plugin-ts": "^3.4.5",
72
- "semantic-release": "^24.1.2",
73
+ "semantic-release": "^24.2.1",
73
74
  "sinon": "^19.0.2",
74
75
  "sinon-chai": "^4.0.0",
75
76
  "typescript": "^5.3.3",
76
- "vitest": "^2.1.6"
77
+ "vitest": "^2.1.8"
77
78
  },
78
79
  "peerDependencies": {
79
80
  "@babel/generator": ">=7.23.0",
package/plugin.d.ts CHANGED
@@ -8,7 +8,6 @@ interface IPluginOptions {
8
8
  serverFile?: string;
9
9
  clientFile?: string;
10
10
  routesPath?: string;
11
- routesParsing?: 'node' | 'babel';
12
11
  spaIndex?: boolean | ICreateSPAIndex;
13
12
  tsconfigAliases?: boolean | IMakeAliasesPluginOptions;
14
13
  customShortcuts?: {
package/plugin.js CHANGED
@@ -1,2 +1,2 @@
1
- import e from"node:path";import i from"node:process";import s from"./constants/cli-actions.js";import o from"./constants/plugin-name.js";import n from"./plugins/create-spa-index.js";import{getCurrentEntrypoint as t,ViteHandleCustomEntrypointPlugin as r}from"./plugins/handle-custom-entrypoint.js";import p from"./plugins/make-aliases.js";import a from"./plugins/normalize-route.js";const l={indexFile:"index.html",serverFile:"server.ts",clientFile:"client.ts",routesParsing:"babel",tsconfigAliases:!0,spaIndex:!1};function u(u={}){const m=new URL(import.meta.url),d=global.viteBoostAction||i.env.SSR_BOOST_ACTION,c={...l,...u},f=t(c.entrypoint??[]),S="1"===i.env.SSR_BOOST_IS_SSR||d===s.dev,g=d===s.build,h=[{name:o,enforce:"pre",pluginOptions:{...c,pluginPath:e.dirname(m.pathname),action:d,isDev:d===s.dev},config:(e,{isSsrBuild:i})=>(e.define={...e.define??{},__IS_SSR__:f?"ssr"===f.type:S},e.build={...e.build??{}},i?{...e,...g?{appType:"custom"}:{},publicDir:!1}:(S&&g&&(e.build.manifest=!0),e))}],{tsconfigAliases:b,routesPath:v,routesParsing:_,spaIndex:y}=c;return b&&h.push(p("boolean"==typeof b?void 0:b)),y&&h.push(n("boolean"==typeof y?void 0:y)),f&&h.push(r({entrypoint:f})),h.push(a({isSSR:S,isBuild:g,routesPath:v,isNodeParsing:"node"===_})),h}export{u as default};
1
+ import e from"node:path";import i from"node:process";import o from"./constants/cli-actions.js";import t from"./constants/plugin-name.js";import n from"./plugins/create-spa-index.js";import{getCurrentEntrypoint as s,ViteHandleCustomEntrypointPlugin as r}from"./plugins/handle-custom-entrypoint.js";import p from"./plugins/make-aliases.js";import a from"./plugins/normalize-route.js";const l={indexFile:"index.html",serverFile:"server.ts",clientFile:"client.ts",tsconfigAliases:!0,spaIndex:!1};function m(m={}){const u=new URL(import.meta.url),d=global.viteBoostAction||i.env.SSR_BOOST_ACTION,c={...l,...m},f=s(c.entrypoint??[]),S="1"===i.env.SSR_BOOST_IS_SSR||d===o.dev,g=d===o.build,h=[{name:t,enforce:"pre",pluginOptions:{...c,pluginPath:e.dirname(u.pathname),action:d,isDev:d===o.dev},config:(e,{isSsrBuild:i})=>(e.define={...e.define??{},__IS_SSR__:f?"ssr"===f.type:S},e.build={...e.build??{}},i?{...e,...g?{appType:"custom"}:{},publicDir:!1}:(S&&g&&(e.build.manifest=!0),e))}],{tsconfigAliases:v,routesPath:_,spaIndex:b}=c;return v&&h.push(p("boolean"==typeof v?void 0:v)),b&&h.push(n("boolean"==typeof b?void 0:b)),f&&h.push(r({entrypoint:f})),h.push(a({isSSR:S,isBuild:g,routesPath:_})),h}export{m as default};
2
2
  //# sourceMappingURL=plugin.js.map
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 // how parse routes\n // node - import routes file directly and walk through\n // babel - use babel travers to walk through and avoid import routes file\n // default: babel\n routesParsing?: 'node' | 'babel';\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 routesParsing: 'babel',\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, routesParsing, 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(\n ViteNormalizeRouterPlugin({\n isSSR,\n isBuild,\n routesPath,\n isNodeParsing: routesParsing === 'node',\n }),\n );\n\n return plugins;\n}\n\nexport default ViteSsrBoostPlugin;\n"],"names":["defaultOptions","indexFile","serverFile","clientFile","routesParsing","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","isNodeParsing"],"mappings":"8XA8CA,MAAMA,EAAiC,CACrCC,UAAW,aACXC,WAAY,YACZC,WAAY,YACZC,cAAe,QACfC,iBAAiB,EACjBC,UAAU,GAOZ,SAASC,EAAmBC,EAA0B,IACpD,MAAMC,EAAU,IAAIC,gBAAgBC,KAC9BC,EAAUC,OAAOC,iBAAmBC,EAAQC,IAAIC,iBAChDC,EAAgC,IAAKlB,KAAmBQ,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,EAAU1C,cAAEA,EAAaE,SAAEA,GAAaY,EAyBjE,OAvBIb,GACFuB,EAAQmB,KACNC,EAAiD,kBAApB3C,OAAgC4C,EAAY5C,IAIzEC,GACFsB,EAAQmB,KAAKG,EAA6C,kBAAb5C,OAAyB2C,EAAY3C,IAGhFa,GACFS,EAAQmB,KAAKI,EAAiC,CAAE9B,WAAYF,KAG9DS,EAAQmB,KACNK,EAA0B,CACxB9B,QACAI,UACAoB,aACAO,cAAiC,SAAlBjD,KAIZwB,CACT"}
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"}