@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,145 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
            var __create = Object.create;
         | 
| 3 | 
            +
            var __defProp = Object.defineProperty;
         | 
| 4 | 
            +
            var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
         | 
| 5 | 
            +
            var __getOwnPropNames = Object.getOwnPropertyNames;
         | 
| 6 | 
            +
            var __getProtoOf = Object.getPrototypeOf;
         | 
| 7 | 
            +
            var __hasOwnProp = Object.prototype.hasOwnProperty;
         | 
| 8 | 
            +
            var __export = (target, all) => {
         | 
| 9 | 
            +
              for (var name in all)
         | 
| 10 | 
            +
                __defProp(target, name, { get: all[name], enumerable: true });
         | 
| 11 | 
            +
            };
         | 
| 12 | 
            +
            var __copyProps = (to, from, except, desc) => {
         | 
| 13 | 
            +
              if (from && typeof from === "object" || typeof from === "function") {
         | 
| 14 | 
            +
                for (let key of __getOwnPropNames(from))
         | 
| 15 | 
            +
                  if (!__hasOwnProp.call(to, key) && key !== except)
         | 
| 16 | 
            +
                    __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
         | 
| 17 | 
            +
              }
         | 
| 18 | 
            +
              return to;
         | 
| 19 | 
            +
            };
         | 
| 20 | 
            +
            var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
         | 
| 21 | 
            +
              // If the importer is in node compatibility mode or this is not an ESM
         | 
| 22 | 
            +
              // file that has been converted to a CommonJS file using a Babel-
         | 
| 23 | 
            +
              // compatible transform (i.e. "__esModule" has not been set), then set
         | 
| 24 | 
            +
              // "default" to the CommonJS "module.exports" for node compatibility.
         | 
| 25 | 
            +
              isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
         | 
| 26 | 
            +
              mod
         | 
| 27 | 
            +
            ));
         | 
| 28 | 
            +
            var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
         | 
| 29 | 
            +
            var vercel_exports = {};
         | 
| 30 | 
            +
            __export(vercel_exports, {
         | 
| 31 | 
            +
              createVercelPreset: () => createVercelPreset
         | 
| 32 | 
            +
            });
         | 
| 33 | 
            +
            module.exports = __toCommonJS(vercel_exports);
         | 
| 34 | 
            +
            var import_node_path = __toESM(require("node:path"));
         | 
| 35 | 
            +
            var import_utils = require("@modern-js/utils");
         | 
| 36 | 
            +
            var import_routes = require("../../../utils/routes");
         | 
| 37 | 
            +
            var import_utils2 = require("../utils");
         | 
| 38 | 
            +
            var import_dependencies = require("../dependencies");
         | 
| 39 | 
            +
            const createVercelPreset = (appContext, modernConfig, needModernServer) => {
         | 
| 40 | 
            +
              const { appDirectory, distDirectory, serverInternalPlugins, entrypoints } = appContext;
         | 
| 41 | 
            +
              const plugins = (0, import_utils.getInternalPlugins)(appDirectory, serverInternalPlugins);
         | 
| 42 | 
            +
              const vercelOutput = import_node_path.default.join(appDirectory, ".vercel");
         | 
| 43 | 
            +
              const outputDirectory = import_node_path.default.join(vercelOutput, "output");
         | 
| 44 | 
            +
              const funcsDirectory = import_node_path.default.join(outputDirectory, "functions", "index.func");
         | 
| 45 | 
            +
              const entryFilePath = import_node_path.default.join(funcsDirectory, "index.js");
         | 
| 46 | 
            +
              return {
         | 
| 47 | 
            +
                async prepare() {
         | 
| 48 | 
            +
                  await import_utils.fs.remove(vercelOutput);
         | 
| 49 | 
            +
                },
         | 
| 50 | 
            +
                async writeOutput() {
         | 
| 51 | 
            +
                  const config = {
         | 
| 52 | 
            +
                    version: 3,
         | 
| 53 | 
            +
                    routes: [
         | 
| 54 | 
            +
                      {
         | 
| 55 | 
            +
                        src: "/static/(.*)",
         | 
| 56 | 
            +
                        headers: {
         | 
| 57 | 
            +
                          "cache-control": "s-maxage=31536000, immutable"
         | 
| 58 | 
            +
                        },
         | 
| 59 | 
            +
                        continue: true
         | 
| 60 | 
            +
                      },
         | 
| 61 | 
            +
                      {
         | 
| 62 | 
            +
                        handle: "filesystem"
         | 
| 63 | 
            +
                      }
         | 
| 64 | 
            +
                    ]
         | 
| 65 | 
            +
                  };
         | 
| 66 | 
            +
                  if (!needModernServer) {
         | 
| 67 | 
            +
                    const { source: { mainEntryName } } = modernConfig;
         | 
| 68 | 
            +
                    entrypoints.forEach((entry) => {
         | 
| 69 | 
            +
                      const isMain = (0, import_routes.isMainEntry)(entry.entryName, mainEntryName);
         | 
| 70 | 
            +
                      config.routes.push({
         | 
| 71 | 
            +
                        src: `/${isMain ? "" : entry.entryName}(?:/.*)?`,
         | 
| 72 | 
            +
                        headers: {
         | 
| 73 | 
            +
                          "cache-control": "s-maxage=0"
         | 
| 74 | 
            +
                        },
         | 
| 75 | 
            +
                        dest: `/html/${entry.entryName}/index.html`
         | 
| 76 | 
            +
                      });
         | 
| 77 | 
            +
                    });
         | 
| 78 | 
            +
                  } else {
         | 
| 79 | 
            +
                    config.routes.push({
         | 
| 80 | 
            +
                      src: "/(.*)",
         | 
| 81 | 
            +
                      dest: `/index`
         | 
| 82 | 
            +
                    });
         | 
| 83 | 
            +
                  }
         | 
| 84 | 
            +
                  await import_utils.fs.ensureDir(outputDirectory);
         | 
| 85 | 
            +
                  await import_utils.fs.writeJSON(import_node_path.default.join(outputDirectory, "config.json"), config, {
         | 
| 86 | 
            +
                    spaces: 2
         | 
| 87 | 
            +
                  });
         | 
| 88 | 
            +
                  const staticDirectory = import_node_path.default.join(outputDirectory, "static/static");
         | 
| 89 | 
            +
                  await import_utils.fs.copy(import_node_path.default.join(distDirectory, "static"), staticDirectory);
         | 
| 90 | 
            +
                  if (!needModernServer) {
         | 
| 91 | 
            +
                    const destHtmlDirectory = import_node_path.default.join(distDirectory, "html");
         | 
| 92 | 
            +
                    const outputHtmlDirectory = import_node_path.default.join(import_node_path.default.join(outputDirectory, "static"), "html");
         | 
| 93 | 
            +
                    await import_utils.fs.copy(destHtmlDirectory, outputHtmlDirectory);
         | 
| 94 | 
            +
                  } else {
         | 
| 95 | 
            +
                    await import_utils.fs.ensureDir(funcsDirectory);
         | 
| 96 | 
            +
                    await import_utils.fs.copy(distDirectory, funcsDirectory, {
         | 
| 97 | 
            +
                      filter: (src) => {
         | 
| 98 | 
            +
                        const distStaticDirectory = import_node_path.default.join(distDirectory, "static");
         | 
| 99 | 
            +
                        return !src.includes(distStaticDirectory);
         | 
| 100 | 
            +
                      }
         | 
| 101 | 
            +
                    });
         | 
| 102 | 
            +
                    await import_utils.fs.writeJSON(import_node_path.default.join(funcsDirectory, ".vc-config.json"), {
         | 
| 103 | 
            +
                      runtime: "nodejs16.x",
         | 
| 104 | 
            +
                      handler: "index.js",
         | 
| 105 | 
            +
                      launcherType: "Nodejs",
         | 
| 106 | 
            +
                      shouldAddHelpers: false,
         | 
| 107 | 
            +
                      supportsResponseStreaming: true
         | 
| 108 | 
            +
                    });
         | 
| 109 | 
            +
                  }
         | 
| 110 | 
            +
                },
         | 
| 111 | 
            +
                async genEntry() {
         | 
| 112 | 
            +
                  var _modernConfig_bff;
         | 
| 113 | 
            +
                  if (!needModernServer) {
         | 
| 114 | 
            +
                    return;
         | 
| 115 | 
            +
                  }
         | 
| 116 | 
            +
                  const serverConfig = {
         | 
| 117 | 
            +
                    bff: {
         | 
| 118 | 
            +
                      prefix: modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_bff = modernConfig.bff) === null || _modernConfig_bff === void 0 ? void 0 : _modernConfig_bff.prefix
         | 
| 119 | 
            +
                    },
         | 
| 120 | 
            +
                    output: {
         | 
| 121 | 
            +
                      path: "."
         | 
| 122 | 
            +
                    }
         | 
| 123 | 
            +
                  };
         | 
| 124 | 
            +
                  const pluginImportCode = (0, import_utils2.genPluginImportsCode)(plugins || []);
         | 
| 125 | 
            +
                  const dynamicProdOptions = {
         | 
| 126 | 
            +
                    config: serverConfig,
         | 
| 127 | 
            +
                    serverConfigFile: import_utils.DEFAULT_SERVER_CONFIG,
         | 
| 128 | 
            +
                    plugins
         | 
| 129 | 
            +
                  };
         | 
| 130 | 
            +
                  const serverAppContext = (0, import_utils2.serverAppContenxtTemplate)(appContext);
         | 
| 131 | 
            +
                  let entryCode = (await import_utils.fs.readFile(import_node_path.default.join(__dirname, "./vercelEntry.js"))).toString();
         | 
| 132 | 
            +
                  entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", `"${import_utils.ROUTE_SPEC_FILE}"`).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
         | 
| 133 | 
            +
                  await import_utils.fs.writeFile(entryFilePath, entryCode);
         | 
| 134 | 
            +
                },
         | 
| 135 | 
            +
                async end() {
         | 
| 136 | 
            +
                  await (0, import_dependencies.handleDependencies)(appDirectory, funcsDirectory, [
         | 
| 137 | 
            +
                    "@modern-js/prod-server"
         | 
| 138 | 
            +
                  ]);
         | 
| 139 | 
            +
                }
         | 
| 140 | 
            +
              };
         | 
| 141 | 
            +
            };
         | 
| 142 | 
            +
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 143 | 
            +
            0 && (module.exports = {
         | 
| 144 | 
            +
              createVercelPreset
         | 
| 145 | 
            +
            });
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            "use strict";
         | 
| 2 | 
            +
            const fs = require("node:fs/promises");
         | 
| 3 | 
            +
            const path = require("node:path");
         | 
| 4 | 
            +
            const { createProdServer } = require("@modern-js/prod-server");
         | 
| 5 | 
            +
            p_genPluginImportsCode;
         | 
| 6 | 
            +
            if (!process.env.NODE_ENV) {
         | 
| 7 | 
            +
              process.env.NODE_ENV = "production";
         | 
| 8 | 
            +
            }
         | 
| 9 | 
            +
            let requestHandler = null;
         | 
| 10 | 
            +
            let handlerCreationPromise = null;
         | 
| 11 | 
            +
            async function loadRoutes(routeFilepath) {
         | 
| 12 | 
            +
              try {
         | 
| 13 | 
            +
                await fs.access(routeFilepath);
         | 
| 14 | 
            +
                const content = await fs.readFile(routeFilepath, "utf-8");
         | 
| 15 | 
            +
                const routeSpec = JSON.parse(content);
         | 
| 16 | 
            +
                return routeSpec.routes || [];
         | 
| 17 | 
            +
              } catch (error) {
         | 
| 18 | 
            +
                console.warn("route.json not found or invalid, continuing with empty routes.");
         | 
| 19 | 
            +
                return [];
         | 
| 20 | 
            +
              }
         | 
| 21 | 
            +
            }
         | 
| 22 | 
            +
            async function initServer() {
         | 
| 23 | 
            +
              const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
         | 
| 24 | 
            +
              const routes = await loadRoutes(routeFilepath);
         | 
| 25 | 
            +
              const dynamicProdOptions = p_dynamicProdOptions;
         | 
| 26 | 
            +
              const prodServerOptions = {
         | 
| 27 | 
            +
                pwd: __dirname,
         | 
| 28 | 
            +
                routes,
         | 
| 29 | 
            +
                disableCustomHook: true,
         | 
| 30 | 
            +
                appContext: {
         | 
| 31 | 
            +
                  sharedDirectory: p_sharedDirectory,
         | 
| 32 | 
            +
                  apiDirectory: p_apiDirectory,
         | 
| 33 | 
            +
                  lambdaDirectory: p_lambdaDirectory
         | 
| 34 | 
            +
                },
         | 
| 35 | 
            +
                ...dynamicProdOptions
         | 
| 36 | 
            +
              };
         | 
| 37 | 
            +
              const app = await createProdServer(prodServerOptions);
         | 
| 38 | 
            +
              return app.getRequestListener();
         | 
| 39 | 
            +
            }
         | 
| 40 | 
            +
            async function createHandler() {
         | 
| 41 | 
            +
              if (!handlerCreationPromise) {
         | 
| 42 | 
            +
                handlerCreationPromise = (async () => {
         | 
| 43 | 
            +
                  try {
         | 
| 44 | 
            +
                    requestHandler = await initServer();
         | 
| 45 | 
            +
                  } catch (error) {
         | 
| 46 | 
            +
                    console.error("Error creating server:", error);
         | 
| 47 | 
            +
                    process.exit(1);
         | 
| 48 | 
            +
                  }
         | 
| 49 | 
            +
                })();
         | 
| 50 | 
            +
              }
         | 
| 51 | 
            +
              await handlerCreationPromise;
         | 
| 52 | 
            +
              return requestHandler;
         | 
| 53 | 
            +
            }
         | 
| 54 | 
            +
            createHandler();
         | 
| 55 | 
            +
            module.exports = async (req, res) => {
         | 
| 56 | 
            +
              if (!requestHandler) {
         | 
| 57 | 
            +
                await createHandler();
         | 
| 58 | 
            +
              }
         | 
| 59 | 
            +
              return requestHandler(req, res);
         | 
| 60 | 
            +
            };
         | 
| @@ -34,7 +34,8 @@ __export(utils_exports, { | |
| 34 34 | 
             
              getPluginsCode: () => getPluginsCode,
         | 
| 35 35 | 
             
              getProjectUsage: () => getProjectUsage,
         | 
| 36 36 | 
             
              linkPackage: () => linkPackage,
         | 
| 37 | 
            -
               | 
| 37 | 
            +
              readDirRecursive: () => readDirRecursive,
         | 
| 38 | 
            +
              serverAppContenxtTemplate: () => serverAppContenxtTemplate,
         | 
| 38 39 | 
             
              writePackage: () => writePackage
         | 
| 39 40 | 
             
            });
         | 
| 40 41 | 
             
            module.exports = __toCommonJS(utils_exports);
         | 
| @@ -42,12 +43,14 @@ var import_path = __toESM(require("path")); | |
| 42 43 | 
             
            var import_node_os = __toESM(require("node:os"));
         | 
| 43 44 | 
             
            var import_utils = require("@modern-js/utils");
         | 
| 44 45 | 
             
            var import_mlly = require("mlly");
         | 
| 45 | 
            -
            const  | 
| 46 | 
            -
               | 
| 47 | 
            -
             | 
| 48 | 
            -
                 | 
| 49 | 
            -
                 | 
| 50 | 
            -
             | 
| 46 | 
            +
            const serverAppContenxtTemplate = (appContext) => {
         | 
| 47 | 
            +
              const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
         | 
| 48 | 
            +
              return {
         | 
| 49 | 
            +
                sharedDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, sharedDirectory)}")`,
         | 
| 50 | 
            +
                apiDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, apiDirectory)}")`,
         | 
| 51 | 
            +
                lambdaDirectory: `path.join(__dirname, "${import_path.default.relative(appDirectory, lambdaDirectory)}")`,
         | 
| 52 | 
            +
                metaName
         | 
| 53 | 
            +
              };
         | 
| 51 54 | 
             
            };
         | 
| 52 55 | 
             
            const getPluginsCode = (plugins) => `[${plugins.map((_, index) => `plugin_${index}()`).join(",")}]`;
         | 
| 53 56 | 
             
            const genPluginImportsCode = (plugins) => {
         | 
| @@ -137,6 +140,16 @@ const linkPackage = async (from, to, projectRootDir) => { | |
| 137 140 | 
             
                console.error("Cannot link", from, "to", to, error);
         | 
| 138 141 | 
             
              });
         | 
| 139 142 | 
             
            };
         | 
| 143 | 
            +
            const readDirRecursive = async (dir) => {
         | 
| 144 | 
            +
              const files = await import_utils.fs.readdir(dir, {
         | 
| 145 | 
            +
                withFileTypes: true
         | 
| 146 | 
            +
              });
         | 
| 147 | 
            +
              const filesAndDirs = await Promise.all(files.map(async (file) => {
         | 
| 148 | 
            +
                const resPath = import_path.default.resolve(dir, file.name);
         | 
| 149 | 
            +
                return file.isDirectory() ? readDirRecursive(resPath) : resPath;
         | 
| 150 | 
            +
              }));
         | 
| 151 | 
            +
              return filesAndDirs.flat();
         | 
| 152 | 
            +
            };
         | 
| 140 153 | 
             
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 141 154 | 
             
            0 && (module.exports = {
         | 
| 142 155 | 
             
              applyProductionCondition,
         | 
| @@ -145,6 +158,7 @@ const linkPackage = async (from, to, projectRootDir) => { | |
| 145 158 | 
             
              getPluginsCode,
         | 
| 146 159 | 
             
              getProjectUsage,
         | 
| 147 160 | 
             
              linkPackage,
         | 
| 148 | 
            -
               | 
| 161 | 
            +
              readDirRecursive,
         | 
| 162 | 
            +
              serverAppContenxtTemplate,
         | 
| 149 163 | 
             
              writePackage
         | 
| 150 164 | 
             
            });
         | 
    
        package/dist/cjs/utils/routes.js
    CHANGED
    
    | @@ -29,7 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru | |
| 29 29 | 
             
            var routes_exports = {};
         | 
| 30 30 | 
             
            __export(routes_exports, {
         | 
| 31 31 | 
             
              generateRoutes: () => generateRoutes,
         | 
| 32 | 
            -
              getPathWithoutExt: () => getPathWithoutExt
         | 
| 32 | 
            +
              getPathWithoutExt: () => getPathWithoutExt,
         | 
| 33 | 
            +
              isMainEntry: () => isMainEntry
         | 
| 33 34 | 
             
            });
         | 
| 34 35 | 
             
            module.exports = __toCommonJS(routes_exports);
         | 
| 35 36 | 
             
            var import_path = __toESM(require("path"));
         | 
| @@ -45,8 +46,12 @@ const getPathWithoutExt = (filename) => { | |
| 45 46 | 
             
              const extname = import_path.default.extname(filename);
         | 
| 46 47 | 
             
              return filename.slice(0, -extname.length);
         | 
| 47 48 | 
             
            };
         | 
| 49 | 
            +
            const isMainEntry = (entryName, mainEntryName) => {
         | 
| 50 | 
            +
              return entryName === (mainEntryName || import_utils.MAIN_ENTRY_NAME);
         | 
| 51 | 
            +
            };
         | 
| 48 52 | 
             
            // Annotate the CommonJS export names for ESM import in node:
         | 
| 49 53 | 
             
            0 && (module.exports = {
         | 
| 50 54 | 
             
              generateRoutes,
         | 
| 51 | 
            -
              getPathWithoutExt
         | 
| 55 | 
            +
              getPathWithoutExt,
         | 
| 56 | 
            +
              isMainEntry
         | 
| 52 57 | 
             
            });
         | 
| @@ -4,7 +4,8 @@ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_ | |
| 4 4 | 
             
            import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
         | 
| 5 5 | 
             
            import path from "path";
         | 
| 6 6 | 
             
            import fs from "fs";
         | 
| 7 | 
            -
            import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY,  | 
| 7 | 
            +
            import { urlJoin, isPlainObject, removeLeadingSlash, getEntryOptions, SERVER_BUNDLE_DIRECTORY, removeTailSlash, SERVER_WORKER_BUNDLE_DIRECTORY } from "@modern-js/utils";
         | 
| 8 | 
            +
            import { isMainEntry } from "../utils/routes";
         | 
| 8 9 | 
             
            import { walkDirectory } from "./utils";
         | 
| 9 10 | 
             
            var applyBaseUrl = function(baseUrl, routes) {
         | 
| 10 11 | 
             
              if (baseUrl) {
         | 
| @@ -75,14 +76,14 @@ var collectHtmlRoutes = function(entrypoints, appContext, config) { | |
| 75 76 | 
             
              var workerSSR = deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr;
         | 
| 76 77 | 
             
              var htmlRoutes = entrypoints.reduce(function(previous, param) {
         | 
| 77 78 | 
             
                var entryName = param.entryName;
         | 
| 78 | 
            -
                var  | 
| 79 | 
            -
                var entryOptions = getEntryOptions(entryName,  | 
| 79 | 
            +
                var isMain = isMainEntry(entryName, mainEntryName);
         | 
| 80 | 
            +
                var entryOptions = getEntryOptions(entryName, isMain, ssr, ssrByEntries, packageName);
         | 
| 80 81 | 
             
                var isSSR = Boolean(entryOptions);
         | 
| 81 82 | 
             
                var isWorker = Boolean(workerSSR);
         | 
| 82 83 | 
             
                var isStream = typeof entryOptions === "object" && (entryOptions.mode === "stream" || Boolean(entryOptions.preload));
         | 
| 83 84 | 
             
                var resHeaders = ((routes === null || routes === void 0 ? void 0 : routes[entryName]) || {}).resHeaders;
         | 
| 84 85 | 
             
                var route = {
         | 
| 85 | 
            -
                  urlPath: "/".concat( | 
| 86 | 
            +
                  urlPath: "/".concat(isMain ? "" : entryName),
         | 
| 86 87 | 
             
                  entryName,
         | 
| 87 88 | 
             
                  entryPath: removeLeadingSlash(path.posix.normalize("".concat(htmlPath, "/").concat(entryName).concat(disableHtmlFolder ? ".html" : "/index.html"))),
         | 
| 88 89 | 
             
                  isSPA: true,
         | 
| @@ -8,52 +8,7 @@ import { nodeFileTrace, resolve } from "@vercel/nft"; | |
| 8 8 | 
             
            import { fs as fse, pkgUp, semver } from "@modern-js/utils";
         | 
| 9 9 | 
             
            import { readPackageJSON } from "pkg-types";
         | 
| 10 10 | 
             
            import { parseNodeModulePath } from "mlly";
         | 
| 11 | 
            -
            import { linkPackage, writePackage } from "./utils";
         | 
| 12 | 
            -
            var readDirRecursive = function() {
         | 
| 13 | 
            -
              var _ref = _async_to_generator(function(dir) {
         | 
| 14 | 
            -
                var files, filesAndDirs;
         | 
| 15 | 
            -
                return _ts_generator(this, function(_state) {
         | 
| 16 | 
            -
                  switch (_state.label) {
         | 
| 17 | 
            -
                    case 0:
         | 
| 18 | 
            -
                      return [
         | 
| 19 | 
            -
                        4,
         | 
| 20 | 
            -
                        fse.readdir(dir, {
         | 
| 21 | 
            -
                          withFileTypes: true
         | 
| 22 | 
            -
                        })
         | 
| 23 | 
            -
                      ];
         | 
| 24 | 
            -
                    case 1:
         | 
| 25 | 
            -
                      files = _state.sent();
         | 
| 26 | 
            -
                      return [
         | 
| 27 | 
            -
                        4,
         | 
| 28 | 
            -
                        Promise.all(files.map(function() {
         | 
| 29 | 
            -
                          var _ref2 = _async_to_generator(function(file) {
         | 
| 30 | 
            -
                            var resPath;
         | 
| 31 | 
            -
                            return _ts_generator(this, function(_state2) {
         | 
| 32 | 
            -
                              resPath = path.resolve(dir, file.name);
         | 
| 33 | 
            -
                              return [
         | 
| 34 | 
            -
                                2,
         | 
| 35 | 
            -
                                file.isDirectory() ? readDirRecursive(resPath) : resPath
         | 
| 36 | 
            -
                              ];
         | 
| 37 | 
            -
                            });
         | 
| 38 | 
            -
                          });
         | 
| 39 | 
            -
                          return function(file) {
         | 
| 40 | 
            -
                            return _ref2.apply(this, arguments);
         | 
| 41 | 
            -
                          };
         | 
| 42 | 
            -
                        }()))
         | 
| 43 | 
            -
                      ];
         | 
| 44 | 
            -
                    case 2:
         | 
| 45 | 
            -
                      filesAndDirs = _state.sent();
         | 
| 46 | 
            -
                      return [
         | 
| 47 | 
            -
                        2,
         | 
| 48 | 
            -
                        filesAndDirs.flat()
         | 
| 49 | 
            -
                      ];
         | 
| 50 | 
            -
                  }
         | 
| 51 | 
            -
                });
         | 
| 52 | 
            -
              });
         | 
| 53 | 
            -
              return function readDirRecursive2(dir) {
         | 
| 54 | 
            -
                return _ref.apply(this, arguments);
         | 
| 55 | 
            -
              };
         | 
| 56 | 
            -
            }();
         | 
| 11 | 
            +
            import { linkPackage, readDirRecursive, writePackage } from "./utils";
         | 
| 57 12 | 
             
            function isFile(file) {
         | 
| 58 13 | 
             
              return _isFile.apply(this, arguments);
         | 
| 59 14 | 
             
            }
         | 
| @@ -477,7 +432,6 @@ var handleDependencies = function() { | |
| 477 432 | 
             
                      ];
         | 
| 478 433 | 
             
                    case 12:
         | 
| 479 434 | 
             
                      _state.sent();
         | 
| 480 | 
            -
                      console.log("multiVersionPkgs111111111", multiVersionPkgs);
         | 
| 481 435 | 
             
                      _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
         | 
| 482 436 | 
             
                      _state.label = 13;
         | 
| 483 437 | 
             
                    case 13:
         |