@modern-js/app-tools 2.49.3-alpha.2 → 2.49.3-alpha.20
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.
- package/dist/cjs/analyze/getServerRoutes.js +4 -3
- package/dist/cjs/plugins/deploy/dependencies.js +1 -12
- package/dist/cjs/plugins/deploy/index.js +25 -147
- package/dist/cjs/plugins/deploy/platforms/netlify.js +120 -0
- package/dist/cjs/plugins/deploy/platforms/netlifyEntry.js +60 -0
- package/dist/cjs/plugins/deploy/platforms/node.js +90 -0
- package/dist/cjs/plugins/deploy/platforms/nodeEntry.js +41 -0
- package/dist/cjs/plugins/deploy/platforms/platform.js +16 -0
- package/dist/cjs/plugins/deploy/platforms/vercel.js +145 -0
- package/dist/cjs/plugins/deploy/platforms/vercelEntry.js +60 -0
- package/dist/cjs/plugins/deploy/utils.js +22 -8
- package/dist/cjs/utils/routes.js +7 -2
- package/dist/esm/analyze/getServerRoutes.js +5 -4
- package/dist/esm/plugins/deploy/dependencies.js +1 -47
- package/dist/esm/plugins/deploy/index.js +66 -245
- package/dist/esm/plugins/deploy/platforms/netlify.js +182 -0
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +202 -0
- package/dist/esm/plugins/deploy/platforms/node.js +122 -0
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +104 -0
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +220 -0
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +202 -0
- package/dist/esm/plugins/deploy/utils.js +55 -3
- package/dist/esm/utils/routes.js +6 -2
- package/dist/esm-node/analyze/getServerRoutes.js +5 -4
- package/dist/esm-node/plugins/deploy/dependencies.js +1 -12
- package/dist/esm-node/plugins/deploy/index.js +24 -136
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +86 -0
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +68 -0
- package/dist/esm-node/plugins/deploy/platforms/node.js +56 -0
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +40 -0
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +111 -0
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +68 -0
- package/dist/esm-node/plugins/deploy/utils.js +20 -7
- package/dist/esm-node/utils/routes.js +6 -2
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/nodeEntry.d.ts +1 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +10 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +2 -0
- package/dist/types/plugins/deploy/utils.d.ts +8 -1
- package/dist/types/utils/routes.d.ts +3 -3
- package/package.json +21 -21
- package/dist/cjs/plugins/deploy/entrys/netlify.js +0 -95
- package/dist/cjs/plugins/deploy/entrys/node.js +0 -88
- package/dist/cjs/plugins/deploy/entrys/vercel.js +0 -97
- package/dist/esm/plugins/deploy/entrys/netlify.js +0 -41
- package/dist/esm/plugins/deploy/entrys/node.js +0 -39
- package/dist/esm/plugins/deploy/entrys/vercel.js +0 -43
- package/dist/esm-node/plugins/deploy/entrys/netlify.js +0 -71
- package/dist/esm-node/plugins/deploy/entrys/node.js +0 -64
- package/dist/esm-node/plugins/deploy/entrys/vercel.js +0 -73
- package/dist/types/plugins/deploy/entrys/netlify.d.ts +0 -5
- package/dist/types/plugins/deploy/entrys/node.d.ts +0 -5
- package/dist/types/plugins/deploy/entrys/vercel.d.ts +0 -6
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            import path from "node:path";
         | 
| 2 | 
            +
            import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins, chalk } from "@modern-js/utils";
         | 
| 3 | 
            +
            import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
         | 
| 4 | 
            +
            import { handleDependencies } from "../dependencies";
         | 
| 5 | 
            +
            const createNodePreset = (appContext, config, needModernServer) => {
         | 
| 6 | 
            +
              const { appDirectory, distDirectory, serverInternalPlugins } = appContext;
         | 
| 7 | 
            +
              const plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
         | 
| 8 | 
            +
              const outputDirectory = path.join(appDirectory, ".output");
         | 
| 9 | 
            +
              const staticDirectory = path.join(outputDirectory, "static");
         | 
| 10 | 
            +
              const entryFilePath = path.join(outputDirectory, "index.js");
         | 
| 11 | 
            +
              return {
         | 
| 12 | 
            +
                async prepare() {
         | 
| 13 | 
            +
                  await fse.remove(outputDirectory);
         | 
| 14 | 
            +
                },
         | 
| 15 | 
            +
                async writeOutput() {
         | 
| 16 | 
            +
                  await fse.copy(distDirectory, outputDirectory);
         | 
| 17 | 
            +
                },
         | 
| 18 | 
            +
                async genEntry() {
         | 
| 19 | 
            +
                  var _config_bff;
         | 
| 20 | 
            +
                  if (!needModernServer) {
         | 
| 21 | 
            +
                    return;
         | 
| 22 | 
            +
                  }
         | 
| 23 | 
            +
                  const serverConfig = {
         | 
| 24 | 
            +
                    server: {
         | 
| 25 | 
            +
                      port: 8080
         | 
| 26 | 
            +
                    },
         | 
| 27 | 
            +
                    bff: {
         | 
| 28 | 
            +
                      prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
         | 
| 29 | 
            +
                    },
         | 
| 30 | 
            +
                    output: {
         | 
| 31 | 
            +
                      path: "."
         | 
| 32 | 
            +
                    }
         | 
| 33 | 
            +
                  };
         | 
| 34 | 
            +
                  const pluginImportCode = genPluginImportsCode(plugins || []);
         | 
| 35 | 
            +
                  const dynamicProdOptions = {
         | 
| 36 | 
            +
                    config: serverConfig,
         | 
| 37 | 
            +
                    serverConfigFile: DEFAULT_SERVER_CONFIG,
         | 
| 38 | 
            +
                    plugins
         | 
| 39 | 
            +
                  };
         | 
| 40 | 
            +
                  let entryCode = (await fse.readFile(path.join(__dirname, "./nodeEntry.js"))).toString();
         | 
| 41 | 
            +
                  const serverAppContext = serverAppContenxtTemplate(appContext);
         | 
| 42 | 
            +
                  entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
         | 
| 43 | 
            +
                  await fse.writeFile(entryFilePath, entryCode);
         | 
| 44 | 
            +
                  await handleDependencies(appDirectory, outputDirectory, [
         | 
| 45 | 
            +
                    "@modern-js/prod-server"
         | 
| 46 | 
            +
                  ]);
         | 
| 47 | 
            +
                },
         | 
| 48 | 
            +
                async end() {
         | 
| 49 | 
            +
                  console.log("Static directory:", chalk.blue(path.relative(appDirectory, staticDirectory)));
         | 
| 50 | 
            +
                  console.log(`You can preview this build by`, chalk.blue(`node .output/index`));
         | 
| 51 | 
            +
                }
         | 
| 52 | 
            +
              };
         | 
| 53 | 
            +
            };
         | 
| 54 | 
            +
            export {
         | 
| 55 | 
            +
              createNodePreset
         | 
| 56 | 
            +
            };
         | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            const fs = require("node:fs/promises");
         | 
| 2 | 
            +
            const path = require("node:path");
         | 
| 3 | 
            +
            const { createProdServer } = require("@modern-js/prod-server");
         | 
| 4 | 
            +
            p_genPluginImportsCode;
         | 
| 5 | 
            +
            if (!process.env.NODE_ENV) {
         | 
| 6 | 
            +
              process.env.NODE_ENV = "production";
         | 
| 7 | 
            +
            }
         | 
| 8 | 
            +
            async function loadRoutes(routeFilepath) {
         | 
| 9 | 
            +
              try {
         | 
| 10 | 
            +
                await fs.access(routeFilepath);
         | 
| 11 | 
            +
                const content = await fs.readFile(routeFilepath, "utf-8");
         | 
| 12 | 
            +
                const routeSpec = JSON.parse(content);
         | 
| 13 | 
            +
                return routeSpec.routes || [];
         | 
| 14 | 
            +
              } catch (error) {
         | 
| 15 | 
            +
                console.warn("route.json not found or invalid, continuing with empty routes.");
         | 
| 16 | 
            +
                return [];
         | 
| 17 | 
            +
              }
         | 
| 18 | 
            +
            }
         | 
| 19 | 
            +
            async function main() {
         | 
| 20 | 
            +
              const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
         | 
| 21 | 
            +
              const routes = await loadRoutes(routeFilepath);
         | 
| 22 | 
            +
              const dynamicProdOptions = p_dynamicProdOptions;
         | 
| 23 | 
            +
              const prodServerOptions = {
         | 
| 24 | 
            +
                pwd: __dirname,
         | 
| 25 | 
            +
                routes,
         | 
| 26 | 
            +
                disableCustomHook: true,
         | 
| 27 | 
            +
                appContext: {
         | 
| 28 | 
            +
                  sharedDirectory: p_sharedDirectory,
         | 
| 29 | 
            +
                  apiDirectory: p_apiDirectory,
         | 
| 30 | 
            +
                  lambdaDirectory: p_lambdaDirectory
         | 
| 31 | 
            +
                },
         | 
| 32 | 
            +
                ...dynamicProdOptions
         | 
| 33 | 
            +
              };
         | 
| 34 | 
            +
              const app = await createProdServer(prodServerOptions);
         | 
| 35 | 
            +
              const port = process.env.PORT || 8080;
         | 
| 36 | 
            +
              app.listen(port, () => {
         | 
| 37 | 
            +
                console.log("\x1B[32mServer is listening on port", port, "\x1B[0m");
         | 
| 38 | 
            +
              });
         | 
| 39 | 
            +
            }
         | 
| 40 | 
            +
            main();
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,111 @@ | |
| 1 | 
            +
            import path from "node:path";
         | 
| 2 | 
            +
            import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
         | 
| 3 | 
            +
            import { isMainEntry } from "../../../utils/routes";
         | 
| 4 | 
            +
            import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
         | 
| 5 | 
            +
            import { handleDependencies } from "../dependencies";
         | 
| 6 | 
            +
            const createVercelPreset = (appContext, modernConfig, needModernServer) => {
         | 
| 7 | 
            +
              const { appDirectory, distDirectory, serverInternalPlugins, entrypoints } = appContext;
         | 
| 8 | 
            +
              const plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
         | 
| 9 | 
            +
              const vercelOutput = path.join(appDirectory, ".vercel");
         | 
| 10 | 
            +
              const outputDirectory = path.join(vercelOutput, "output");
         | 
| 11 | 
            +
              const funcsDirectory = path.join(outputDirectory, "functions", "index.func");
         | 
| 12 | 
            +
              const entryFilePath = path.join(funcsDirectory, "index.js");
         | 
| 13 | 
            +
              return {
         | 
| 14 | 
            +
                async prepare() {
         | 
| 15 | 
            +
                  await fse.remove(vercelOutput);
         | 
| 16 | 
            +
                },
         | 
| 17 | 
            +
                async writeOutput() {
         | 
| 18 | 
            +
                  const config = {
         | 
| 19 | 
            +
                    version: 3,
         | 
| 20 | 
            +
                    routes: [
         | 
| 21 | 
            +
                      {
         | 
| 22 | 
            +
                        src: "/static/(.*)",
         | 
| 23 | 
            +
                        headers: {
         | 
| 24 | 
            +
                          "cache-control": "s-maxage=31536000, immutable"
         | 
| 25 | 
            +
                        },
         | 
| 26 | 
            +
                        continue: true
         | 
| 27 | 
            +
                      },
         | 
| 28 | 
            +
                      {
         | 
| 29 | 
            +
                        handle: "filesystem"
         | 
| 30 | 
            +
                      }
         | 
| 31 | 
            +
                    ]
         | 
| 32 | 
            +
                  };
         | 
| 33 | 
            +
                  if (!needModernServer) {
         | 
| 34 | 
            +
                    const { source: { mainEntryName } } = modernConfig;
         | 
| 35 | 
            +
                    entrypoints.forEach((entry) => {
         | 
| 36 | 
            +
                      const isMain = isMainEntry(entry.entryName, mainEntryName);
         | 
| 37 | 
            +
                      config.routes.push({
         | 
| 38 | 
            +
                        src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
         | 
| 39 | 
            +
                        headers: {
         | 
| 40 | 
            +
                          "cache-control": "s-maxage=0"
         | 
| 41 | 
            +
                        },
         | 
| 42 | 
            +
                        dest: `/html/${entry.entryName}/index.html`
         | 
| 43 | 
            +
                      });
         | 
| 44 | 
            +
                    });
         | 
| 45 | 
            +
                  } else {
         | 
| 46 | 
            +
                    config.routes.push({
         | 
| 47 | 
            +
                      src: "/(.*)",
         | 
| 48 | 
            +
                      dest: `/index`
         | 
| 49 | 
            +
                    });
         | 
| 50 | 
            +
                  }
         | 
| 51 | 
            +
                  await fse.ensureDir(outputDirectory);
         | 
| 52 | 
            +
                  await fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
         | 
| 53 | 
            +
                    spaces: 2
         | 
| 54 | 
            +
                  });
         | 
| 55 | 
            +
                  const staticDirectory = path.join(outputDirectory, "static/static");
         | 
| 56 | 
            +
                  await fse.copy(path.join(distDirectory, "static"), staticDirectory);
         | 
| 57 | 
            +
                  if (!needModernServer) {
         | 
| 58 | 
            +
                    const destHtmlDirectory = path.join(distDirectory, "html");
         | 
| 59 | 
            +
                    const outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
         | 
| 60 | 
            +
                    await fse.copy(destHtmlDirectory, outputHtmlDirectory);
         | 
| 61 | 
            +
                  } else {
         | 
| 62 | 
            +
                    await fse.ensureDir(funcsDirectory);
         | 
| 63 | 
            +
                    await fse.copy(distDirectory, funcsDirectory, {
         | 
| 64 | 
            +
                      filter: (src) => {
         | 
| 65 | 
            +
                        const distStaticDirectory = path.join(distDirectory, "static");
         | 
| 66 | 
            +
                        return !src.includes(distStaticDirectory);
         | 
| 67 | 
            +
                      }
         | 
| 68 | 
            +
                    });
         | 
| 69 | 
            +
                    await fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
         | 
| 70 | 
            +
                      runtime: "nodejs16.x",
         | 
| 71 | 
            +
                      handler: "index.js",
         | 
| 72 | 
            +
                      launcherType: "Nodejs",
         | 
| 73 | 
            +
                      shouldAddHelpers: false,
         | 
| 74 | 
            +
                      supportsResponseStreaming: true
         | 
| 75 | 
            +
                    });
         | 
| 76 | 
            +
                  }
         | 
| 77 | 
            +
                },
         | 
| 78 | 
            +
                async genEntry() {
         | 
| 79 | 
            +
                  var _modernConfig_bff;
         | 
| 80 | 
            +
                  if (!needModernServer) {
         | 
| 81 | 
            +
                    return;
         | 
| 82 | 
            +
                  }
         | 
| 83 | 
            +
                  const serverConfig = {
         | 
| 84 | 
            +
                    bff: {
         | 
| 85 | 
            +
                      prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
         | 
| 86 | 
            +
                    },
         | 
| 87 | 
            +
                    output: {
         | 
| 88 | 
            +
                      path: "."
         | 
| 89 | 
            +
                    }
         | 
| 90 | 
            +
                  };
         | 
| 91 | 
            +
                  const pluginImportCode = genPluginImportsCode(plugins || []);
         | 
| 92 | 
            +
                  const dynamicProdOptions = {
         | 
| 93 | 
            +
                    config: serverConfig,
         | 
| 94 | 
            +
                    serverConfigFile: DEFAULT_SERVER_CONFIG,
         | 
| 95 | 
            +
                    plugins
         | 
| 96 | 
            +
                  };
         | 
| 97 | 
            +
                  const serverAppContext = serverAppContenxtTemplate(appContext);
         | 
| 98 | 
            +
                  let entryCode = (await fse.readFile(path.join(__dirname, "./vercelEntry.js"))).toString();
         | 
| 99 | 
            +
                  entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
         | 
| 100 | 
            +
                  await fse.writeFile(entryFilePath, entryCode);
         | 
| 101 | 
            +
                },
         | 
| 102 | 
            +
                async end() {
         | 
| 103 | 
            +
                  await handleDependencies(appDirectory, funcsDirectory, [
         | 
| 104 | 
            +
                    "@modern-js/prod-server"
         | 
| 105 | 
            +
                  ]);
         | 
| 106 | 
            +
                }
         | 
| 107 | 
            +
              };
         | 
| 108 | 
            +
            };
         | 
| 109 | 
            +
            export {
         | 
| 110 | 
            +
              createVercelPreset
         | 
| 111 | 
            +
            };
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            var __getOwnPropNames = Object.getOwnPropertyNames;
         | 
| 2 | 
            +
            var __commonJS = (cb, mod) => function __require() {
         | 
| 3 | 
            +
              return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
         | 
| 4 | 
            +
            };
         | 
| 5 | 
            +
            var require_vercelEntry = __commonJS({
         | 
| 6 | 
            +
              "src/plugins/deploy/platforms/vercelEntry.js"(exports, module) {
         | 
| 7 | 
            +
                const fs = require("node:fs/promises");
         | 
| 8 | 
            +
                const path = require("node:path");
         | 
| 9 | 
            +
                const { createProdServer } = require("@modern-js/prod-server");
         | 
| 10 | 
            +
                p_genPluginImportsCode;
         | 
| 11 | 
            +
                if (!process.env.NODE_ENV) {
         | 
| 12 | 
            +
                  process.env.NODE_ENV = "production";
         | 
| 13 | 
            +
                }
         | 
| 14 | 
            +
                let requestHandler = null;
         | 
| 15 | 
            +
                let handlerCreationPromise = null;
         | 
| 16 | 
            +
                async function loadRoutes(routeFilepath) {
         | 
| 17 | 
            +
                  try {
         | 
| 18 | 
            +
                    await fs.access(routeFilepath);
         | 
| 19 | 
            +
                    const content = await fs.readFile(routeFilepath, "utf-8");
         | 
| 20 | 
            +
                    const routeSpec = JSON.parse(content);
         | 
| 21 | 
            +
                    return routeSpec.routes || [];
         | 
| 22 | 
            +
                  } catch (error) {
         | 
| 23 | 
            +
                    console.warn("route.json not found or invalid, continuing with empty routes.");
         | 
| 24 | 
            +
                    return [];
         | 
| 25 | 
            +
                  }
         | 
| 26 | 
            +
                }
         | 
| 27 | 
            +
                async function initServer() {
         | 
| 28 | 
            +
                  const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
         | 
| 29 | 
            +
                  const routes = await loadRoutes(routeFilepath);
         | 
| 30 | 
            +
                  const dynamicProdOptions = p_dynamicProdOptions;
         | 
| 31 | 
            +
                  const prodServerOptions = {
         | 
| 32 | 
            +
                    pwd: __dirname,
         | 
| 33 | 
            +
                    routes,
         | 
| 34 | 
            +
                    disableCustomHook: true,
         | 
| 35 | 
            +
                    appContext: {
         | 
| 36 | 
            +
                      sharedDirectory: p_sharedDirectory,
         | 
| 37 | 
            +
                      apiDirectory: p_apiDirectory,
         | 
| 38 | 
            +
                      lambdaDirectory: p_lambdaDirectory
         | 
| 39 | 
            +
                    },
         | 
| 40 | 
            +
                    ...dynamicProdOptions
         | 
| 41 | 
            +
                  };
         | 
| 42 | 
            +
                  const app = await createProdServer(prodServerOptions);
         | 
| 43 | 
            +
                  return app.getRequestListener();
         | 
| 44 | 
            +
                }
         | 
| 45 | 
            +
                async function createHandler() {
         | 
| 46 | 
            +
                  if (!handlerCreationPromise) {
         | 
| 47 | 
            +
                    handlerCreationPromise = (async () => {
         | 
| 48 | 
            +
                      try {
         | 
| 49 | 
            +
                        requestHandler = await initServer();
         | 
| 50 | 
            +
                      } catch (error) {
         | 
| 51 | 
            +
                        console.error("Error creating server:", error);
         | 
| 52 | 
            +
                        process.exit(1);
         | 
| 53 | 
            +
                      }
         | 
| 54 | 
            +
                    })();
         | 
| 55 | 
            +
                  }
         | 
| 56 | 
            +
                  await handlerCreationPromise;
         | 
| 57 | 
            +
                  return requestHandler;
         | 
| 58 | 
            +
                }
         | 
| 59 | 
            +
                createHandler();
         | 
| 60 | 
            +
                module.exports = async (req, res) => {
         | 
| 61 | 
            +
                  if (!requestHandler) {
         | 
| 62 | 
            +
                    await createHandler();
         | 
| 63 | 
            +
                  }
         | 
| 64 | 
            +
                  return requestHandler(req, res);
         | 
| 65 | 
            +
                };
         | 
| 66 | 
            +
              }
         | 
| 67 | 
            +
            });
         | 
| 68 | 
            +
            export default require_vercelEntry();
         | 
| @@ -2,12 +2,14 @@ import path from "path"; | |
| 2 2 | 
             
            import os from "node:os";
         | 
| 3 3 | 
             
            import { ROUTE_SPEC_FILE, fs as fse, isDepExists } from "@modern-js/utils";
         | 
| 4 4 | 
             
            import { parseNodeModulePath } from "mlly";
         | 
| 5 | 
            -
            const  | 
| 6 | 
            -
               | 
| 7 | 
            -
             | 
| 8 | 
            -
                 | 
| 9 | 
            -
                 | 
| 10 | 
            -
             | 
| 5 | 
            +
            const serverAppContenxtTemplate = (appContext) => {
         | 
| 6 | 
            +
              const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
         | 
| 7 | 
            +
              return {
         | 
| 8 | 
            +
                sharedDirectory: `path.join(__dirname, "${path.relative(appDirectory, sharedDirectory)}")`,
         | 
| 9 | 
            +
                apiDirectory: `path.join(__dirname, "${path.relative(appDirectory, apiDirectory)}")`,
         | 
| 10 | 
            +
                lambdaDirectory: `path.join(__dirname, "${path.relative(appDirectory, lambdaDirectory)}")`,
         | 
| 11 | 
            +
                metaName
         | 
| 12 | 
            +
              };
         | 
| 11 13 | 
             
            };
         | 
| 12 14 | 
             
            const getPluginsCode = (plugins) => `[${plugins.map((_, index) => `plugin_${index}()`).join(",")}]`;
         | 
| 13 15 | 
             
            const genPluginImportsCode = (plugins) => {
         | 
| @@ -97,6 +99,16 @@ const linkPackage = async (from, to, projectRootDir) => { | |
| 97 99 | 
             
                console.error("Cannot link", from, "to", to, error);
         | 
| 98 100 | 
             
              });
         | 
| 99 101 | 
             
            };
         | 
| 102 | 
            +
            const readDirRecursive = async (dir) => {
         | 
| 103 | 
            +
              const files = await fse.readdir(dir, {
         | 
| 104 | 
            +
                withFileTypes: true
         | 
| 105 | 
            +
              });
         | 
| 106 | 
            +
              const filesAndDirs = await Promise.all(files.map(async (file) => {
         | 
| 107 | 
            +
                const resPath = path.resolve(dir, file.name);
         | 
| 108 | 
            +
                return file.isDirectory() ? readDirRecursive(resPath) : resPath;
         | 
| 109 | 
            +
              }));
         | 
| 110 | 
            +
              return filesAndDirs.flat();
         | 
| 111 | 
            +
            };
         | 
| 100 112 | 
             
            export {
         | 
| 101 113 | 
             
              applyProductionCondition,
         | 
| 102 114 | 
             
              applyPublicCondition,
         | 
| @@ -104,6 +116,7 @@ export { | |
| 104 116 | 
             
              getPluginsCode,
         | 
| 105 117 | 
             
              getProjectUsage,
         | 
| 106 118 | 
             
              linkPackage,
         | 
| 107 | 
            -
               | 
| 119 | 
            +
              readDirRecursive,
         | 
| 120 | 
            +
              serverAppContenxtTemplate,
         | 
| 108 121 | 
             
              writePackage
         | 
| 109 122 | 
             
            };
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            import path from "path";
         | 
| 2 | 
            -
            import { fs, ROUTE_SPEC_FILE } from "@modern-js/utils";
         | 
| 2 | 
            +
            import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
         | 
| 3 3 | 
             
            const generateRoutes = async (appContext) => {
         | 
| 4 4 | 
             
              const { serverRoutes, distDirectory } = appContext;
         | 
| 5 5 | 
             
              const output = JSON.stringify({
         | 
| @@ -11,7 +11,11 @@ const getPathWithoutExt = (filename) => { | |
| 11 11 | 
             
              const extname = path.extname(filename);
         | 
| 12 12 | 
             
              return filename.slice(0, -extname.length);
         | 
| 13 13 | 
             
            };
         | 
| 14 | 
            +
            const isMainEntry = (entryName, mainEntryName) => {
         | 
| 15 | 
            +
              return entryName === (mainEntryName || MAIN_ENTRY_NAME);
         | 
| 16 | 
            +
            };
         | 
| 14 17 | 
             
            export {
         | 
| 15 18 | 
             
              generateRoutes,
         | 
| 16 | 
            -
              getPathWithoutExt
         | 
| 19 | 
            +
              getPathWithoutExt,
         | 
| 20 | 
            +
              isMainEntry
         | 
| 17 21 | 
             
            };
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            export {};
         | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            import { IAppContext, NormalizedConfig } from '@modern-js/core';
         | 
| 2 | 
            +
            import { AppTools } from '../../../types';
         | 
| 3 | 
            +
            export type CreatePreset = (appContext: IAppContext, config: NormalizedConfig<AppTools>, needModernServer?: boolean) => DeployPreset;
         | 
| 4 | 
            +
            type DeployPreset = {
         | 
| 5 | 
            +
                prepare?: () => Promise<void>;
         | 
| 6 | 
            +
                writeOutput?: () => Promise<void>;
         | 
| 7 | 
            +
                genEntry?: () => Promise<void>;
         | 
| 8 | 
            +
                end?: () => Promise<void>;
         | 
| 9 | 
            +
            };
         | 
| 10 | 
            +
            export {};
         | 
| @@ -1,11 +1,17 @@ | |
| 1 1 | 
             
            import type { PackageJson } from 'pkg-types';
         | 
| 2 | 
            +
            import { IAppContext } from '@modern-js/core';
         | 
| 2 3 | 
             
            export type ServerAppContext = {
         | 
| 3 4 | 
             
                sharedDirectory: string;
         | 
| 4 5 | 
             
                apiDirectory: string;
         | 
| 5 6 | 
             
                lambdaDirectory: string;
         | 
| 6 7 | 
             
                metaName: string;
         | 
| 7 8 | 
             
            };
         | 
| 8 | 
            -
            export declare const  | 
| 9 | 
            +
            export declare const serverAppContenxtTemplate: (appContext: IAppContext) => {
         | 
| 10 | 
            +
                sharedDirectory: string;
         | 
| 11 | 
            +
                apiDirectory: string;
         | 
| 12 | 
            +
                lambdaDirectory: string;
         | 
| 13 | 
            +
                metaName: string;
         | 
| 14 | 
            +
            };
         | 
| 9 15 | 
             
            export declare const getPluginsCode: (plugins: string[]) => string;
         | 
| 10 16 | 
             
            export declare const genPluginImportsCode: (plugins: string[]) => string;
         | 
| 11 17 | 
             
            export declare const getProjectUsage: (appDirectory: string, distDirectory: string) => {
         | 
| @@ -25,3 +31,4 @@ export type TracedPackage = { | |
| 25 31 | 
             
            };
         | 
| 26 32 | 
             
            export declare const writePackage: (pkg: TracedPackage, version: string, projectDir: string, _pkgPath?: string) => Promise<void>;
         | 
| 27 33 | 
             
            export declare const linkPackage: (from: string, to: string, projectRootDir: string) => Promise<void>;
         | 
| 34 | 
            +
            export declare const readDirRecursive: (dir: string) => Promise<string[]>;
         | 
| @@ -1,4 +1,4 @@ | |
| 1 1 | 
             
            import type { IAppContext } from '@modern-js/core';
         | 
| 2 | 
            -
            declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
         | 
| 3 | 
            -
            declare const getPathWithoutExt: (filename: string) => string;
         | 
| 4 | 
            -
            export  | 
| 2 | 
            +
            export declare const generateRoutes: (appContext: IAppContext) => Promise<void>;
         | 
| 3 | 
            +
            export declare const getPathWithoutExt: (filename: string) => string;
         | 
| 4 | 
            +
            export declare const isMainEntry: (entryName: string, mainEntryName?: string) => boolean;
         | 
    
        package/package.json
    CHANGED
    
    | @@ -15,7 +15,7 @@ | |
| 15 15 | 
             
                "modern",
         | 
| 16 16 | 
             
                "modern.js"
         | 
| 17 17 | 
             
              ],
         | 
| 18 | 
            -
              "version": "2.49.3-alpha. | 
| 18 | 
            +
              "version": "2.49.3-alpha.20",
         | 
| 19 19 | 
             
              "jsnext:source": "./src/index.ts",
         | 
| 20 20 | 
             
              "types": "./dist/types/index.d.ts",
         | 
| 21 21 | 
             
              "main": "./dist/cjs/index.js",
         | 
| @@ -69,9 +69,9 @@ | |
| 69 69 | 
             
                "@babel/parser": "^7.22.15",
         | 
| 70 70 | 
             
                "@babel/traverse": "^7.23.2",
         | 
| 71 71 | 
             
                "@babel/types": "^7.23.0",
         | 
| 72 | 
            -
                "@rsbuild/plugin-node-polyfill": "0.6. | 
| 73 | 
            -
                "@rsbuild/shared": "0.6. | 
| 74 | 
            -
                "@rsbuild/core": "0.6. | 
| 72 | 
            +
                "@rsbuild/plugin-node-polyfill": "0.6.15",
         | 
| 73 | 
            +
                "@rsbuild/shared": "0.6.15",
         | 
| 74 | 
            +
                "@rsbuild/core": "0.6.15",
         | 
| 75 75 | 
             
                "@swc/helpers": "0.5.3",
         | 
| 76 76 | 
             
                "@vercel/nft": "^0.26.4",
         | 
| 77 77 | 
             
                "es-module-lexer": "^1.1.0",
         | 
| @@ -80,23 +80,23 @@ | |
| 80 80 | 
             
                "mlly": "^1.6.1",
         | 
| 81 81 | 
             
                "pkg-types": "^1.1.0",
         | 
| 82 82 | 
             
                "std-env": "^3.7.0",
         | 
| 83 | 
            -
                "@modern-js/ | 
| 84 | 
            -
                "@modern-js/plugin": "2.49. | 
| 85 | 
            -
                "@modern-js/ | 
| 86 | 
            -
                "@modern-js/ | 
| 87 | 
            -
                "@modern-js/ | 
| 88 | 
            -
                "@modern-js/ | 
| 89 | 
            -
                "@modern-js/plugin- | 
| 90 | 
            -
                "@modern-js/ | 
| 91 | 
            -
                "@modern-js/types": "2.49. | 
| 92 | 
            -
                "@modern-js/ | 
| 93 | 
            -
                "@modern-js/ | 
| 94 | 
            -
                "@modern-js/utils": "2.49. | 
| 95 | 
            -
                "@modern-js/ | 
| 96 | 
            -
                "@modern-js/server": "2.49. | 
| 83 | 
            +
                "@modern-js/plugin": "2.49.3",
         | 
| 84 | 
            +
                "@modern-js/plugin-i18n": "2.49.3",
         | 
| 85 | 
            +
                "@modern-js/core": "2.49.3",
         | 
| 86 | 
            +
                "@modern-js/plugin-lint": "2.49.3",
         | 
| 87 | 
            +
                "@modern-js/prod-server": "2.49.4-alpha.1",
         | 
| 88 | 
            +
                "@modern-js/server-core": "2.49.3",
         | 
| 89 | 
            +
                "@modern-js/rsbuild-plugin-esbuild": "2.49.3",
         | 
| 90 | 
            +
                "@modern-js/node-bundle-require": "2.49.3",
         | 
| 91 | 
            +
                "@modern-js/types": "2.49.3",
         | 
| 92 | 
            +
                "@modern-js/server-utils": "2.49.3",
         | 
| 93 | 
            +
                "@modern-js/uni-builder": "2.49.3",
         | 
| 94 | 
            +
                "@modern-js/utils": "2.49.3",
         | 
| 95 | 
            +
                "@modern-js/plugin-data-loader": "2.49.3",
         | 
| 96 | 
            +
                "@modern-js/server": "2.49.3"
         | 
| 97 97 | 
             
              },
         | 
| 98 98 | 
             
              "devDependencies": {
         | 
| 99 | 
            -
                "@rsbuild/plugin-swc": "0.6. | 
| 99 | 
            +
                "@rsbuild/plugin-swc": "0.6.15",
         | 
| 100 100 | 
             
                "@types/babel__traverse": "7.18.5",
         | 
| 101 101 | 
             
                "@types/jest": "^29",
         | 
| 102 102 | 
             
                "@types/node": "^14",
         | 
| @@ -105,8 +105,8 @@ | |
| 105 105 | 
             
                "tsconfig-paths": "^4.2.0",
         | 
| 106 106 | 
             
                "typescript": "^5",
         | 
| 107 107 | 
             
                "webpack": "^5.91.0",
         | 
| 108 | 
            -
                "@scripts/build": "2.49. | 
| 109 | 
            -
                "@scripts/jest-config": "2.49. | 
| 108 | 
            +
                "@scripts/build": "2.49.3",
         | 
| 109 | 
            +
                "@scripts/jest-config": "2.49.3"
         | 
| 110 110 | 
             
              },
         | 
| 111 111 | 
             
              "sideEffects": false,
         | 
| 112 112 | 
             
              "publishConfig": {
         | 
| @@ -1,95 +0,0 @@ | |
| 1 | 
            -
            "use strict";
         | 
| 2 | 
            -
            var __defProp = Object.defineProperty;
         | 
| 3 | 
            -
            var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
         | 
| 4 | 
            -
            var __getOwnPropNames = Object.getOwnPropertyNames;
         | 
| 5 | 
            -
            var __hasOwnProp = Object.prototype.hasOwnProperty;
         | 
| 6 | 
            -
            var __export = (target, all) => {
         | 
| 7 | 
            -
              for (var name in all)
         | 
| 8 | 
            -
                __defProp(target, name, { get: all[name], enumerable: true });
         | 
| 9 | 
            -
            };
         | 
| 10 | 
            -
            var __copyProps = (to, from, except, desc) => {
         | 
| 11 | 
            -
              if (from && typeof from === "object" || typeof from === "function") {
         | 
| 12 | 
            -
                for (let key of __getOwnPropNames(from))
         | 
| 13 | 
            -
                  if (!__hasOwnProp.call(to, key) && key !== except)
         | 
| 14 | 
            -
                    __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
         | 
| 15 | 
            -
              }
         | 
| 16 | 
            -
              return to;
         | 
| 17 | 
            -
            };
         | 
| 18 | 
            -
            var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
         | 
| 19 | 
            -
            var netlify_exports = {};
         | 
| 20 | 
            -
            __export(netlify_exports, {
         | 
| 21 | 
            -
              genNetlifyEntry: () => genNetlifyEntry
         | 
| 22 | 
            -
            });
         | 
| 23 | 
            -
            module.exports = __toCommonJS(netlify_exports);
         | 
| 24 | 
            -
            var import_utils = require("@modern-js/utils");
         | 
| 25 | 
            -
            var import_utils2 = require("../utils");
         | 
| 26 | 
            -
            function genNetlifyEntry({ config, plugins, appContext } = {}) {
         | 
| 27 | 
            -
              const defaultConfig = {
         | 
| 28 | 
            -
                server: {
         | 
| 29 | 
            -
                  port: 8080
         | 
| 30 | 
            -
                },
         | 
| 31 | 
            -
                output: {
         | 
| 32 | 
            -
                  path: "."
         | 
| 33 | 
            -
                }
         | 
| 34 | 
            -
              };
         | 
| 35 | 
            -
              return `
         | 
| 36 | 
            -
             | 
| 37 | 
            -
              const fs = require('node:fs/promises');
         | 
| 38 | 
            -
              const path = require('node:path');
         | 
| 39 | 
            -
              const { createNetlifyFunction } = require('@modern-js/prod-server/netlify');
         | 
| 40 | 
            -
              ${(0, import_utils2.genPluginImportsCode)(plugins || [])}
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              let requestHandler = null;
         | 
| 43 | 
            -
             | 
| 44 | 
            -
              if(!process.env.NODE_ENV){
         | 
| 45 | 
            -
                process.env.NODE_ENV = 'production';
         | 
| 46 | 
            -
              }
         | 
| 47 | 
            -
             | 
| 48 | 
            -
              async function createHandler() {
         | 
| 49 | 
            -
                try {
         | 
| 50 | 
            -
                  let routes = [];
         | 
| 51 | 
            -
                  const routeFilepath = path.join(__dirname, "${import_utils.ROUTE_SPEC_FILE}");
         | 
| 52 | 
            -
                  try {
         | 
| 53 | 
            -
                    await fs.access(routeFilepath);
         | 
| 54 | 
            -
                    const content = await fs.readFile(routeFilepath, "utf-8");
         | 
| 55 | 
            -
                    const routeSpec = JSON.parse(content);
         | 
| 56 | 
            -
                    routes = routeSpec.routes;
         | 
| 57 | 
            -
                  } catch (error) {
         | 
| 58 | 
            -
                    console.warn('route.json not found, continuing with empty routes.');
         | 
| 59 | 
            -
                  }
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  const prodServerOptions = {
         | 
| 62 | 
            -
                    pwd: __dirname,
         | 
| 63 | 
            -
                    routes,
         | 
| 64 | 
            -
                    config: ${JSON.stringify(config || defaultConfig)},
         | 
| 65 | 
            -
                    serverConfigFile: '${import_utils.DEFAULT_SERVER_CONFIG}',
         | 
| 66 | 
            -
                    plugins: ${(0, import_utils2.getPluginsCode)(plugins || [])},
         | 
| 67 | 
            -
                    appContext: ${appContext ? (0, import_utils2.severAppContextTemplate)(appContext) : "undefined"},
         | 
| 68 | 
            -
                    disableCustomHook: true
         | 
| 69 | 
            -
                  }
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  requestHandler = await createNetlifyFunction(prodServerOptions)
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  return requestHandler
         | 
| 74 | 
            -
                } catch(error) {
         | 
| 75 | 
            -
                  console.error(error);
         | 
| 76 | 
            -
                  process.exit(1);
         | 
| 77 | 
            -
                }
         | 
| 78 | 
            -
              }
         | 
| 79 | 
            -
             | 
| 80 | 
            -
              createHandler();
         | 
| 81 | 
            -
             | 
| 82 | 
            -
              const handleRequest = async(request, context) => {
         | 
| 83 | 
            -
                if(typeof requestHandler !== 'function'){
         | 
| 84 | 
            -
                  await createHandler();
         | 
| 85 | 
            -
                }
         | 
| 86 | 
            -
                return requestHandler(request, context);
         | 
| 87 | 
            -
              }
         | 
| 88 | 
            -
             | 
| 89 | 
            -
              export default handleRequest;
         | 
| 90 | 
            -
              `;
         | 
| 91 | 
            -
            }
         | 
| 92 | 
            -
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 93 | 
            -
            0 && (module.exports = {
         | 
| 94 | 
            -
              genNetlifyEntry
         | 
| 95 | 
            -
            });
         | 
| @@ -1,88 +0,0 @@ | |
| 1 | 
            -
            "use strict";
         | 
| 2 | 
            -
            var __defProp = Object.defineProperty;
         | 
| 3 | 
            -
            var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
         | 
| 4 | 
            -
            var __getOwnPropNames = Object.getOwnPropertyNames;
         | 
| 5 | 
            -
            var __hasOwnProp = Object.prototype.hasOwnProperty;
         | 
| 6 | 
            -
            var __export = (target, all) => {
         | 
| 7 | 
            -
              for (var name in all)
         | 
| 8 | 
            -
                __defProp(target, name, { get: all[name], enumerable: true });
         | 
| 9 | 
            -
            };
         | 
| 10 | 
            -
            var __copyProps = (to, from, except, desc) => {
         | 
| 11 | 
            -
              if (from && typeof from === "object" || typeof from === "function") {
         | 
| 12 | 
            -
                for (let key of __getOwnPropNames(from))
         | 
| 13 | 
            -
                  if (!__hasOwnProp.call(to, key) && key !== except)
         | 
| 14 | 
            -
                    __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
         | 
| 15 | 
            -
              }
         | 
| 16 | 
            -
              return to;
         | 
| 17 | 
            -
            };
         | 
| 18 | 
            -
            var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
         | 
| 19 | 
            -
            var node_exports = {};
         | 
| 20 | 
            -
            __export(node_exports, {
         | 
| 21 | 
            -
              genNodeEntry: () => genNodeEntry
         | 
| 22 | 
            -
            });
         | 
| 23 | 
            -
            module.exports = __toCommonJS(node_exports);
         | 
| 24 | 
            -
            var import_utils = require("@modern-js/utils");
         | 
| 25 | 
            -
            var import_utils2 = require("../utils");
         | 
| 26 | 
            -
            function genNodeEntry({ config, plugins, appContext } = {}) {
         | 
| 27 | 
            -
              const defaultConfig = {
         | 
| 28 | 
            -
                server: {
         | 
| 29 | 
            -
                  port: 8080
         | 
| 30 | 
            -
                },
         | 
| 31 | 
            -
                output: {
         | 
| 32 | 
            -
                  path: "."
         | 
| 33 | 
            -
                }
         | 
| 34 | 
            -
              };
         | 
| 35 | 
            -
              return `
         | 
| 36 | 
            -
             | 
| 37 | 
            -
              const fs = require('node:fs/promises');
         | 
| 38 | 
            -
              const path = require('node:path');
         | 
| 39 | 
            -
              const { createProdServer } = require('@modern-js/prod-server');
         | 
| 40 | 
            -
              ${(0, import_utils2.genPluginImportsCode)(plugins || [])}
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              if(!process.env.NODE_ENV){
         | 
| 43 | 
            -
                process.env.NODE_ENV = 'production';
         | 
| 44 | 
            -
              }
         | 
| 45 | 
            -
             | 
| 46 | 
            -
              async function main() {
         | 
| 47 | 
            -
                try {
         | 
| 48 | 
            -
                  let routes = [];
         | 
| 49 | 
            -
                  const routeFilepath = path.join(__dirname, "${import_utils.ROUTE_SPEC_FILE}");
         | 
| 50 | 
            -
                  try {
         | 
| 51 | 
            -
                    await fs.access(routeFilepath);
         | 
| 52 | 
            -
                    const content = await fs.readFile(routeFilepath, "utf-8");
         | 
| 53 | 
            -
                    const routeSpec = JSON.parse(content);
         | 
| 54 | 
            -
                    routes = routeSpec.routes;
         | 
| 55 | 
            -
                  } catch (error) {
         | 
| 56 | 
            -
                    console.warn('route.json not found, continuing with empty routes.');
         | 
| 57 | 
            -
                  }
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                  const prodServerOptions = {
         | 
| 60 | 
            -
                    pwd: __dirname,
         | 
| 61 | 
            -
                    routes,
         | 
| 62 | 
            -
                    config: ${JSON.stringify(config || defaultConfig)},
         | 
| 63 | 
            -
                    serverConfigFile: '${import_utils.DEFAULT_SERVER_CONFIG}',
         | 
| 64 | 
            -
                    plugins: ${(0, import_utils2.getPluginsCode)(plugins || [])},
         | 
| 65 | 
            -
                    appContext: ${appContext ? (0, import_utils2.severAppContextTemplate)(appContext) : "undefined"},
         | 
| 66 | 
            -
                    disableCustomHook: true
         | 
| 67 | 
            -
                  }
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                  const app = await createProdServer(prodServerOptions)
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  const port = process.env.PORT || 3000;
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                  app.listen(port, () => {
         | 
| 74 | 
            -
                    console.log('\\x1b[32mServer is listening on port', port, '\\x1b[0m');
         | 
| 75 | 
            -
                  });
         | 
| 76 | 
            -
                } catch(error) {
         | 
| 77 | 
            -
                  console.error(error);
         | 
| 78 | 
            -
                  process.exit(1);
         | 
| 79 | 
            -
                }
         | 
| 80 | 
            -
              }
         | 
| 81 | 
            -
             | 
| 82 | 
            -
              main();
         | 
| 83 | 
            -
              `;
         | 
| 84 | 
            -
            }
         | 
| 85 | 
            -
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 86 | 
            -
            0 && (module.exports = {
         | 
| 87 | 
            -
              genNodeEntry
         | 
| 88 | 
            -
            });
         |