@modern-js/app-tools 2.49.3-alpha.0 → 2.49.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/cjs/index.js +2 -4
  2. package/dist/cjs/locale/en.js +1 -2
  3. package/dist/cjs/locale/zh.js +1 -2
  4. package/dist/esm/index.js +2 -4
  5. package/dist/esm/locale/en.js +1 -2
  6. package/dist/esm/locale/zh.js +1 -2
  7. package/dist/esm-node/index.js +2 -4
  8. package/dist/esm-node/locale/en.js +1 -2
  9. package/dist/esm-node/locale/zh.js +1 -2
  10. package/dist/types/locale/en.d.ts +0 -1
  11. package/dist/types/locale/index.d.ts +0 -2
  12. package/dist/types/locale/zh.d.ts +0 -1
  13. package/dist/types/utils/types.d.ts +0 -1
  14. package/package.json +22 -26
  15. package/dist/cjs/plugins/deploy/dependencies.js +0 -256
  16. package/dist/cjs/plugins/deploy/entrys/netlify.js +0 -95
  17. package/dist/cjs/plugins/deploy/entrys/node.js +0 -88
  18. package/dist/cjs/plugins/deploy/entrys/vercel.js +0 -94
  19. package/dist/cjs/plugins/deploy/index.js +0 -186
  20. package/dist/cjs/plugins/deploy/utils.js +0 -150
  21. package/dist/esm/plugins/deploy/dependencies.js +0 -725
  22. package/dist/esm/plugins/deploy/entrys/netlify.js +0 -41
  23. package/dist/esm/plugins/deploy/entrys/node.js +0 -39
  24. package/dist/esm/plugins/deploy/entrys/vercel.js +0 -40
  25. package/dist/esm/plugins/deploy/index.js +0 -297
  26. package/dist/esm/plugins/deploy/utils.js +0 -244
  27. package/dist/esm-node/plugins/deploy/dependencies.js +0 -222
  28. package/dist/esm-node/plugins/deploy/entrys/netlify.js +0 -71
  29. package/dist/esm-node/plugins/deploy/entrys/node.js +0 -64
  30. package/dist/esm-node/plugins/deploy/entrys/vercel.js +0 -70
  31. package/dist/esm-node/plugins/deploy/index.js +0 -156
  32. package/dist/esm-node/plugins/deploy/utils.js +0 -109
  33. package/dist/types/plugins/deploy/dependencies.d.ts +0 -1
  34. package/dist/types/plugins/deploy/entrys/netlify.d.ts +0 -5
  35. package/dist/types/plugins/deploy/entrys/node.d.ts +0 -5
  36. package/dist/types/plugins/deploy/entrys/vercel.d.ts +0 -5
  37. package/dist/types/plugins/deploy/index.d.ts +0 -4
  38. package/dist/types/plugins/deploy/utils.d.ts +0 -27
package/dist/cjs/index.js CHANGED
@@ -47,7 +47,6 @@ var import_initialize = __toESM(require("./initialize"));
47
47
  var import_hooks = require("./hooks");
48
48
  var import_locale = require("./locale");
49
49
  var import_serverBuild = __toESM(require("./plugins/serverBuild"));
50
- var import_deploy = __toESM(require("./plugins/deploy"));
51
50
  var import_restart = require("./utils/restart");
52
51
  var import_generateWatchFiles = require("./utils/generateWatchFiles");
53
52
  var import_core = require("@modern-js/core");
@@ -121,8 +120,7 @@ const appTools = (options = {
121
120
  bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
122
121
  }),
123
122
  (0, import_serverBuild.default)(),
124
- (0, import_plugin_lint.lintPlugin)(),
125
- (0, import_deploy.default)()
123
+ (0, import_plugin_lint.lintPlugin)()
126
124
  ],
127
125
  setup: (api) => {
128
126
  const appContext = api.useAppContext();
@@ -154,7 +152,7 @@ const appTools = (options = {
154
152
  const { start } = await Promise.resolve().then(() => __toESM(require("./commands/serve")));
155
153
  await start(api);
156
154
  });
157
- program.command("deploy").usage("[options]").option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-s --skip-build", import_locale.i18n.t(import_locale.localeKeys.command.shared.skipBuild)).option("-o --output <path>", import_locale.i18n.t(import_locale.localeKeys.command.deploy.output)).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action(async (options2) => {
155
+ program.command("deploy").usage("[options]").option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-s --skip-build", import_locale.i18n.t(import_locale.localeKeys.command.shared.skipBuild)).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action(async (options2) => {
158
156
  if (!options2.skipBuild) {
159
157
  const { build } = await Promise.resolve().then(() => __toESM(require("./commands/build")));
160
158
  await build(api);
@@ -44,8 +44,7 @@ const EN_LOCALE = {
44
44
  describe: "preview the production build locally"
45
45
  },
46
46
  deploy: {
47
- describe: "deploy the application",
48
- output: "output path"
47
+ describe: "deploy the application"
49
48
  },
50
49
  new: {
51
50
  describe: "enable optional features or add a new entry",
@@ -44,8 +44,7 @@ const ZH_LOCALE = {
44
44
  describe: "启动生产环境服务"
45
45
  },
46
46
  deploy: {
47
- describe: "部署应用",
48
- output: "输出路径"
47
+ describe: "部署应用"
49
48
  },
50
49
  new: {
51
50
  describe: "Web App 项目中执行生成器",
package/dist/esm/index.js CHANGED
@@ -12,7 +12,6 @@ import initializePlugin from "./initialize";
12
12
  import { hooks } from "./hooks";
13
13
  import { i18n, localeKeys } from "./locale";
14
14
  import serverBuildPlugin from "./plugins/serverBuild";
15
- import deployPlugin from "./plugins/deploy";
16
15
  import { restart } from "./utils/restart";
17
16
  import { generateWatchFiles } from "./utils/generateWatchFiles";
18
17
  import { mergeConfig } from "@modern-js/core";
@@ -296,8 +295,7 @@ var appTools = function() {
296
295
  bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
297
296
  }),
298
297
  serverBuildPlugin(),
299
- lintPlugin(),
300
- deployPlugin()
298
+ lintPlugin()
301
299
  ],
302
300
  setup: function(api) {
303
301
  var appContext = api.useAppContext();
@@ -368,7 +366,7 @@ var appTools = function() {
368
366
  }
369
367
  });
370
368
  }));
371
- program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).option("-o --output <path>", i18n.t(localeKeys.command.deploy.output)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
369
+ program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(function() {
372
370
  var _ref = _async_to_generator(function(options2) {
373
371
  var build, deploy;
374
372
  return _ts_generator(this, function(_state2) {
@@ -21,8 +21,7 @@ var EN_LOCALE = {
21
21
  describe: "preview the production build locally"
22
22
  },
23
23
  deploy: {
24
- describe: "deploy the application",
25
- output: "output path"
24
+ describe: "deploy the application"
26
25
  },
27
26
  new: {
28
27
  describe: "enable optional features or add a new entry",
@@ -21,8 +21,7 @@ var ZH_LOCALE = {
21
21
  describe: "启动生产环境服务"
22
22
  },
23
23
  deploy: {
24
- describe: "部署应用",
25
- output: "输出路径"
24
+ describe: "部署应用"
26
25
  },
27
26
  new: {
28
27
  describe: "Web App 项目中执行生成器",
@@ -8,7 +8,6 @@ import initializePlugin from "./initialize";
8
8
  import { hooks } from "./hooks";
9
9
  import { i18n, localeKeys } from "./locale";
10
10
  import serverBuildPlugin from "./plugins/serverBuild";
11
- import deployPlugin from "./plugins/deploy";
12
11
  import { restart } from "./utils/restart";
13
12
  import { generateWatchFiles } from "./utils/generateWatchFiles";
14
13
  import { mergeConfig } from "@modern-js/core";
@@ -82,8 +81,7 @@ const appTools = (options = {
82
81
  bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
83
82
  }),
84
83
  serverBuildPlugin(),
85
- lintPlugin(),
86
- deployPlugin()
84
+ lintPlugin()
87
85
  ],
88
86
  setup: (api) => {
89
87
  const appContext = api.useAppContext();
@@ -115,7 +113,7 @@ const appTools = (options = {
115
113
  const { start } = await import("./commands/serve");
116
114
  await start(api);
117
115
  });
118
- program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).option("-o --output <path>", i18n.t(localeKeys.command.deploy.output)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
116
+ program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
119
117
  if (!options2.skipBuild) {
120
118
  const { build } = await import("./commands/build");
121
119
  await build(api);
@@ -21,8 +21,7 @@ const EN_LOCALE = {
21
21
  describe: "preview the production build locally"
22
22
  },
23
23
  deploy: {
24
- describe: "deploy the application",
25
- output: "output path"
24
+ describe: "deploy the application"
26
25
  },
27
26
  new: {
28
27
  describe: "enable optional features or add a new entry",
@@ -21,8 +21,7 @@ const ZH_LOCALE = {
21
21
  describe: "启动生产环境服务"
22
22
  },
23
23
  deploy: {
24
- describe: "部署应用",
25
- output: "输出路径"
24
+ describe: "部署应用"
26
25
  },
27
26
  new: {
28
27
  describe: "Web App 项目中执行生成器",
@@ -22,7 +22,6 @@ export declare const EN_LOCALE: {
22
22
  };
23
23
  deploy: {
24
24
  describe: string;
25
- output: string;
26
25
  };
27
26
  new: {
28
27
  describe: string;
@@ -24,7 +24,6 @@ declare const localeKeys: {
24
24
  };
25
25
  deploy: {
26
26
  describe: string;
27
- output: string;
28
27
  };
29
28
  new: {
30
29
  describe: string;
@@ -64,7 +63,6 @@ declare const localeKeys: {
64
63
  };
65
64
  deploy: {
66
65
  describe: string;
67
- output: string;
68
66
  };
69
67
  new: {
70
68
  describe: string;
@@ -22,7 +22,6 @@ export declare const ZH_LOCALE: {
22
22
  };
23
23
  deploy: {
24
24
  describe: string;
25
- output: string;
26
25
  };
27
26
  new: {
28
27
  describe: string;
@@ -10,7 +10,6 @@ export type BuildOptions = {
10
10
  };
11
11
  export type DeployOptions = {
12
12
  config?: string;
13
- output?: string;
14
13
  skipBuild?: boolean;
15
14
  };
16
15
  export type StartOptions = {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.3-alpha.0",
18
+ "version": "2.49.3",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -69,34 +69,30 @@
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.10",
73
- "@rsbuild/shared": "0.6.10",
74
- "@rsbuild/core": "0.6.10",
75
- "@swc/helpers": "0.5.3",
76
- "@vercel/nft": "^0.26.4",
72
+ "@rsbuild/plugin-node-polyfill": "0.6.11",
73
+ "@rsbuild/shared": "0.6.11",
74
+ "@rsbuild/core": "0.6.11",
77
75
  "es-module-lexer": "^1.1.0",
78
76
  "esbuild": "0.17.19",
77
+ "@swc/helpers": "0.5.3",
79
78
  "esbuild-register": "^3.5.0",
80
- "mlly": "^1.6.1",
81
- "pkg-types": "^1.1.0",
82
- "std-env": "^3.7.0",
83
- "@modern-js/node-bundle-require": "2.49.2",
84
- "@modern-js/plugin": "2.49.2",
85
- "@modern-js/plugin-data-loader": "2.49.2",
86
- "@modern-js/plugin-i18n": "2.49.2",
87
- "@modern-js/rsbuild-plugin-esbuild": "2.49.2",
88
- "@modern-js/plugin-lint": "2.49.2",
89
- "@modern-js/server-utils": "2.49.2",
90
- "@modern-js/server": "2.49.2",
91
- "@modern-js/types": "2.49.2",
92
- "@modern-js/core": "2.49.2",
93
- "@modern-js/server-core": "2.49.2",
94
- "@modern-js/utils": "2.49.2",
95
- "@modern-js/uni-builder": "2.49.2",
96
- "@modern-js/prod-server": "2.49.2"
79
+ "@modern-js/node-bundle-require": "2.49.3",
80
+ "@modern-js/core": "2.49.3",
81
+ "@modern-js/plugin": "2.49.3",
82
+ "@modern-js/plugin-data-loader": "2.49.3",
83
+ "@modern-js/plugin-i18n": "2.49.3",
84
+ "@modern-js/plugin-lint": "2.49.3",
85
+ "@modern-js/prod-server": "2.49.3",
86
+ "@modern-js/server": "2.49.3",
87
+ "@modern-js/server-core": "2.49.3",
88
+ "@modern-js/types": "2.49.3",
89
+ "@modern-js/server-utils": "2.49.3",
90
+ "@modern-js/uni-builder": "2.49.3",
91
+ "@modern-js/utils": "2.49.3",
92
+ "@modern-js/rsbuild-plugin-esbuild": "2.49.3"
97
93
  },
98
94
  "devDependencies": {
99
- "@rsbuild/plugin-swc": "0.6.10",
95
+ "@rsbuild/plugin-swc": "0.6.11",
100
96
  "@types/babel__traverse": "7.18.5",
101
97
  "@types/jest": "^29",
102
98
  "@types/node": "^14",
@@ -105,8 +101,8 @@
105
101
  "tsconfig-paths": "^4.2.0",
106
102
  "typescript": "^5",
107
103
  "webpack": "^5.91.0",
108
- "@scripts/build": "2.49.2",
109
- "@scripts/jest-config": "2.49.2"
104
+ "@scripts/build": "2.49.3",
105
+ "@scripts/jest-config": "2.49.3"
110
106
  },
111
107
  "sideEffects": false,
112
108
  "publishConfig": {
@@ -1,256 +0,0 @@
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 dependencies_exports = {};
30
- __export(dependencies_exports, {
31
- handleDependencies: () => handleDependencies
32
- });
33
- module.exports = __toCommonJS(dependencies_exports);
34
- var import_node_path = __toESM(require("node:path"));
35
- var import_nft = require("@vercel/nft");
36
- var import_utils = require("@modern-js/utils");
37
- var import_pkg_types = require("pkg-types");
38
- var import_mlly = require("mlly");
39
- var import_utils2 = require("./utils");
40
- const readDirRecursive = async (dir) => {
41
- const files = await import_utils.fs.readdir(dir, {
42
- withFileTypes: true
43
- });
44
- const filesAndDirs = await Promise.all(files.map(async (file) => {
45
- const resPath = import_node_path.default.resolve(dir, file.name);
46
- return file.isDirectory() ? readDirRecursive(resPath) : resPath;
47
- }));
48
- return filesAndDirs.flat();
49
- };
50
- async function isFile(file) {
51
- try {
52
- const stat = await import_utils.fs.stat(file);
53
- return stat.isFile();
54
- } catch (error) {
55
- if (error.code === "ENOENT") {
56
- return false;
57
- }
58
- throw error;
59
- }
60
- }
61
- const findEntryFiles = async (rootDir) => {
62
- const files = await readDirRecursive(rootDir);
63
- return files;
64
- };
65
- const handleDependencies = async (appDir, serverRootDir, include) => {
66
- const base = "/";
67
- const entryFiles = await findEntryFiles(serverRootDir);
68
- const includeEntries = include.map((item) => {
69
- if ((0, import_node_path.isAbsolute)(item)) {
70
- return item;
71
- }
72
- try {
73
- return require.resolve(item);
74
- } catch (error) {
75
- }
76
- return item;
77
- });
78
- const _fileTrace = await (0, import_nft.nodeFileTrace)(entryFiles.concat(includeEntries), {
79
- base,
80
- processCwd: serverRootDir,
81
- resolve: async (id, parent, job, isCjs) => {
82
- if (id.startsWith("@modern-js/prod-server")) {
83
- return require.resolve(id, {
84
- paths: [
85
- require.resolve("@modern-js/app-tools")
86
- ]
87
- });
88
- } else {
89
- return (0, import_nft.resolve)(id, parent, job, isCjs);
90
- }
91
- }
92
- });
93
- const currentProjectModules = import_node_path.default.join(appDir, "node_modules");
94
- const _resolveTracedPath = (p) => import_utils.fs.realpath(import_node_path.default.resolve(base, p));
95
- const tracedFiles = Object.fromEntries(await Promise.all([
96
- ..._fileTrace.reasons.entries()
97
- ].map(async ([_path, reasons]) => {
98
- if (reasons.ignored) {
99
- return;
100
- }
101
- const filePath = await _resolveTracedPath(_path);
102
- if (filePath.startsWith(serverRootDir) || filePath.startsWith(appDir) && !filePath.startsWith(currentProjectModules)) {
103
- return;
104
- }
105
- if (!await isFile(filePath)) {
106
- return;
107
- }
108
- let baseDir;
109
- let pkgName;
110
- let subpath;
111
- let pkgPath;
112
- if (filePath.includes("node_modules")) {
113
- const parsed = (0, import_mlly.parseNodeModulePath)(filePath);
114
- baseDir = parsed.dir;
115
- pkgName = parsed.name;
116
- subpath = parsed.subpath;
117
- pkgPath = import_node_path.default.join(baseDir, pkgName);
118
- } else {
119
- const MODERN_UTILS_PATH = "packages/toolkit/utils";
120
- const MODERN_UTILS_PATH_REGEX = new RegExp(`(.*${MODERN_UTILS_PATH})`);
121
- const match = filePath.match(MODERN_UTILS_PATH_REGEX);
122
- const packageJsonPath = match ? import_node_path.default.join(match[0], "package.json") : await (0, import_utils.pkgUp)({
123
- cwd: import_node_path.default.dirname(filePath)
124
- });
125
- if (packageJsonPath) {
126
- const packageJson = await import_utils.fs.readJSON(packageJsonPath);
127
- pkgPath = baseDir = import_node_path.default.dirname(packageJsonPath);
128
- subpath = import_node_path.default.relative(baseDir, filePath);
129
- pkgName = packageJson.name;
130
- }
131
- }
132
- if (!baseDir) {
133
- return;
134
- }
135
- const parents = await Promise.all([
136
- ...reasons.parents
137
- ].map((p) => _resolveTracedPath(p)));
138
- const tracedFile = {
139
- path: filePath,
140
- parents,
141
- subpath,
142
- pkgName,
143
- pkgPath
144
- };
145
- return [
146
- filePath,
147
- tracedFile
148
- ];
149
- })).then((r) => r.filter(Boolean)));
150
- const tracedPackages = {};
151
- for (const tracedFile of Object.values(tracedFiles)) {
152
- const { pkgName } = tracedFile;
153
- let tracedPackage = tracedPackages[pkgName];
154
- let pkgJSON = await (0, import_pkg_types.readPackageJSON)(tracedFile.pkgPath, {
155
- cache: true
156
- }).catch(() => {
157
- });
158
- if (!pkgJSON) {
159
- pkgJSON = {
160
- name: pkgName,
161
- version: "0.0.0"
162
- };
163
- }
164
- if (!tracedPackage) {
165
- tracedPackage = {
166
- name: pkgName,
167
- versions: {}
168
- };
169
- tracedPackages[pkgName] = tracedPackage;
170
- }
171
- let tracedPackageVersion = tracedPackage.versions[pkgJSON.version];
172
- if (!tracedPackageVersion) {
173
- tracedPackageVersion = {
174
- path: tracedFile.pkgPath,
175
- files: [],
176
- pkgJSON
177
- };
178
- tracedPackage.versions[pkgJSON.version] = tracedPackageVersion;
179
- }
180
- tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath && tracedPackageVersion.files.push(tracedFile.path);
181
- tracedFile.pkgName = pkgName;
182
- tracedFile.pkgVersion = pkgJSON.version;
183
- }
184
- const findPackageParents = (pkg, version) => {
185
- const versionFiles = pkg.versions[version].files.map((path2) => tracedFiles[path2]);
186
- const parentPkgs = [
187
- ...new Set(versionFiles.flatMap((file) => file.parents.map((parentPath) => {
188
- const parentFile = tracedFiles[parentPath];
189
- if (parentFile.pkgName === pkg.name) {
190
- return null;
191
- }
192
- return `${parentFile.pkgName}@${parentFile.pkgVersion}`;
193
- }).filter(Boolean)))
194
- ];
195
- return parentPkgs;
196
- };
197
- const multiVersionPkgs = {};
198
- const singleVersionPackages = [];
199
- for (const tracedPackage of Object.values(tracedPackages)) {
200
- const versions = Object.keys(tracedPackage.versions);
201
- if (versions.length === 1) {
202
- singleVersionPackages.push(tracedPackage.name);
203
- continue;
204
- }
205
- multiVersionPkgs[tracedPackage.name] = {};
206
- for (const version of versions) {
207
- multiVersionPkgs[tracedPackage.name][version] = findPackageParents(tracedPackage, version);
208
- }
209
- }
210
- await Promise.all(singleVersionPackages.map((pkgName) => {
211
- const pkg = tracedPackages[pkgName];
212
- const version = Object.keys(pkg.versions)[0];
213
- return (0, import_utils2.writePackage)(pkg, version, serverRootDir);
214
- }));
215
- console.log("multiVersionPkgs111111111", multiVersionPkgs);
216
- for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
217
- const versionEntires = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
218
- if (p1.length === 0) {
219
- return -1;
220
- }
221
- if (p2.length === 0) {
222
- return 1;
223
- }
224
- return import_utils.semver.lt(v1, v2, {
225
- loose: true
226
- }) ? 1 : -1;
227
- });
228
- for (const [version, parentPkgs] of versionEntires) {
229
- const pkg = tracedPackages[pkgName];
230
- const pkgDestPath = `.modernjs/${pkgName}@${version}/node_modules/${pkgName}`;
231
- await (0, import_utils2.writePackage)(pkg, version, serverRootDir, pkgDestPath);
232
- await (0, import_utils2.linkPackage)(pkgDestPath, `${pkgName}`, serverRootDir);
233
- for (const parentPkg of parentPkgs) {
234
- const parentPkgName = parentPkg.replace(/@[^@]+$/, "");
235
- await (multiVersionPkgs[parentPkgName] ? (0, import_utils2.linkPackage)(pkgDestPath, `.modernjs/${parentPkg}/node_modules/${pkgName}`, serverRootDir) : (0, import_utils2.linkPackage)(pkgDestPath, `${parentPkgName}/node_modules/${pkgName}`, serverRootDir));
236
- }
237
- }
238
- }
239
- const projectPkg = await (0, import_pkg_types.readPackageJSON)(serverRootDir).catch(() => ({}));
240
- const outputPkgPath = import_node_path.default.join(serverRootDir, "package.json");
241
- await import_utils.fs.writeJSON(outputPkgPath, {
242
- name: `${projectPkg.name || "modernjs-project"}-prod`,
243
- version: projectPkg.version || "0.0.0",
244
- private: true,
245
- dependencies: Object.fromEntries([
246
- ...Object.values(tracedPackages).map((pkg) => [
247
- pkg.name,
248
- Object.keys(pkg.versions)[0]
249
- ])
250
- ].sort(([a], [b]) => a.localeCompare(b)))
251
- });
252
- };
253
- // Annotate the CommonJS export names for ESM import in node:
254
- 0 && (module.exports = {
255
- handleDependencies
256
- });
@@ -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
- });