@modern-js/app-tools 2.49.3-alpha.13 → 2.49.3-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/cjs/plugins/deploy/index copy.js +216 -0
  2. package/dist/cjs/plugins/deploy/index.js +13 -169
  3. package/dist/cjs/plugins/deploy/platforms/netlify.js +112 -64
  4. package/dist/cjs/plugins/deploy/platforms/netlifyEntry.js +60 -0
  5. package/dist/cjs/plugins/deploy/platforms/node.js +41 -18
  6. package/dist/cjs/plugins/deploy/platforms/vercel.js +103 -16
  7. package/dist/cjs/plugins/deploy/utils.js +10 -8
  8. package/dist/esm/plugins/deploy/index copy.js +367 -0
  9. package/dist/esm/plugins/deploy/index.js +17 -314
  10. package/dist/esm/plugins/deploy/platforms/netlify.js +203 -36
  11. package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +202 -0
  12. package/dist/esm/plugins/deploy/platforms/node.js +100 -43
  13. package/dist/esm/plugins/deploy/platforms/vercel.js +203 -40
  14. package/dist/esm/plugins/deploy/utils.js +9 -3
  15. package/dist/esm-node/plugins/deploy/index copy.js +186 -0
  16. package/dist/esm-node/plugins/deploy/index.js +11 -157
  17. package/dist/esm-node/plugins/deploy/platforms/netlify.js +103 -65
  18. package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +68 -0
  19. package/dist/esm-node/plugins/deploy/platforms/node.js +42 -19
  20. package/dist/esm-node/plugins/deploy/platforms/vercel.js +104 -17
  21. package/dist/esm-node/plugins/deploy/utils.js +9 -7
  22. package/dist/types/plugins/deploy/index copy.d.ts +4 -0
  23. package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -5
  24. package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +2 -0
  25. package/dist/types/plugins/deploy/platforms/node.d.ts +2 -8
  26. package/dist/types/plugins/deploy/platforms/platform.d.ts +8 -4
  27. package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -8
  28. package/dist/types/plugins/deploy/utils.d.ts +7 -1
  29. package/package.json +8 -8
@@ -0,0 +1,202 @@
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_netlifyEntry = __commonJS({
6
+ "src/plugins/deploy/platforms/netlifyEntry.js"(exports, module) {
7
+ var _async_to_generator = require("@swc/helpers/_/_async_to_generator");
8
+ var _object_spread = require("@swc/helpers/_/_object_spread");
9
+ var _ts_generator = require("@swc/helpers/_/_ts_generator");
10
+ var fs = require("node:fs/promises");
11
+ var path = require("node:path");
12
+ var createNetlifyFunction = require("@modern-js/prod-server/netlify").createNetlifyFunction;
13
+ p_genPluginImportsCode;
14
+ if (!process.env.NODE_ENV) {
15
+ process.env.NODE_ENV = "production";
16
+ }
17
+ var requestHandler = null;
18
+ var handlerCreationPromise = null;
19
+ function loadRoutes(routeFilepath) {
20
+ return _loadRoutes.apply(this, arguments);
21
+ }
22
+ function _loadRoutes() {
23
+ _loadRoutes = _async_to_generator._(function(routeFilepath) {
24
+ var content, routeSpec, error;
25
+ return _ts_generator._(this, function(_state) {
26
+ switch (_state.label) {
27
+ case 0:
28
+ _state.trys.push([
29
+ 0,
30
+ 3,
31
+ ,
32
+ 4
33
+ ]);
34
+ return [
35
+ 4,
36
+ fs.access(routeFilepath)
37
+ ];
38
+ case 1:
39
+ _state.sent();
40
+ return [
41
+ 4,
42
+ fs.readFile(routeFilepath, "utf-8")
43
+ ];
44
+ case 2:
45
+ content = _state.sent();
46
+ routeSpec = JSON.parse(content);
47
+ return [
48
+ 2,
49
+ routeSpec.routes || []
50
+ ];
51
+ case 3:
52
+ error = _state.sent();
53
+ console.warn("route.json not found or invalid, continuing with empty routes.");
54
+ return [
55
+ 2,
56
+ []
57
+ ];
58
+ case 4:
59
+ return [
60
+ 2
61
+ ];
62
+ }
63
+ });
64
+ });
65
+ return _loadRoutes.apply(this, arguments);
66
+ }
67
+ function initServer() {
68
+ return _initServer.apply(this, arguments);
69
+ }
70
+ function _initServer() {
71
+ _initServer = _async_to_generator._(function() {
72
+ var routeFilepath, routes, dynamicProdOptions, prodServerOptions, app;
73
+ return _ts_generator._(this, function(_state) {
74
+ switch (_state.label) {
75
+ case 0:
76
+ routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
77
+ return [
78
+ 4,
79
+ loadRoutes(routeFilepath)
80
+ ];
81
+ case 1:
82
+ routes = _state.sent();
83
+ dynamicProdOptions = p_dynamicProdOptions;
84
+ prodServerOptions = _object_spread._({
85
+ pwd: __dirname,
86
+ routes,
87
+ disableCustomHook: true,
88
+ appContext: {
89
+ sharedDirectory: p_sharedDirectory,
90
+ apiDirectory: p_apiDirectory,
91
+ lambdaDirectory: p_lambdaDirectory
92
+ }
93
+ }, dynamicProdOptions);
94
+ return [
95
+ 4,
96
+ createNetlifyFunction(prodServerOptions)
97
+ ];
98
+ case 2:
99
+ app = _state.sent();
100
+ return [
101
+ 2,
102
+ app.getRequestListener()
103
+ ];
104
+ }
105
+ });
106
+ });
107
+ return _initServer.apply(this, arguments);
108
+ }
109
+ function createHandler() {
110
+ return _createHandler.apply(this, arguments);
111
+ }
112
+ function _createHandler() {
113
+ _createHandler = _async_to_generator._(function() {
114
+ return _ts_generator._(this, function(_state) {
115
+ switch (_state.label) {
116
+ case 0:
117
+ if (!handlerCreationPromise) {
118
+ handlerCreationPromise = _async_to_generator._(function() {
119
+ var error;
120
+ return _ts_generator._(this, function(_state2) {
121
+ switch (_state2.label) {
122
+ case 0:
123
+ _state2.trys.push([
124
+ 0,
125
+ 2,
126
+ ,
127
+ 3
128
+ ]);
129
+ return [
130
+ 4,
131
+ initServer()
132
+ ];
133
+ case 1:
134
+ requestHandler = _state2.sent();
135
+ return [
136
+ 3,
137
+ 3
138
+ ];
139
+ case 2:
140
+ error = _state2.sent();
141
+ console.error("Error creating server:", error);
142
+ process.exit(1);
143
+ return [
144
+ 3,
145
+ 3
146
+ ];
147
+ case 3:
148
+ return [
149
+ 2
150
+ ];
151
+ }
152
+ });
153
+ })();
154
+ }
155
+ return [
156
+ 4,
157
+ handlerCreationPromise
158
+ ];
159
+ case 1:
160
+ _state.sent();
161
+ return [
162
+ 2,
163
+ requestHandler
164
+ ];
165
+ }
166
+ });
167
+ });
168
+ return _createHandler.apply(this, arguments);
169
+ }
170
+ createHandler();
171
+ module.exports = function() {
172
+ var _ref = _async_to_generator._(function(request, context) {
173
+ return _ts_generator._(this, function(_state) {
174
+ switch (_state.label) {
175
+ case 0:
176
+ if (!!requestHandler)
177
+ return [
178
+ 3,
179
+ 2
180
+ ];
181
+ return [
182
+ 4,
183
+ createHandler()
184
+ ];
185
+ case 1:
186
+ _state.sent();
187
+ _state.label = 2;
188
+ case 2:
189
+ return [
190
+ 2,
191
+ requestHandler(request, context)
192
+ ];
193
+ }
194
+ });
195
+ });
196
+ return function(request, context) {
197
+ return _ref.apply(this, arguments);
198
+ };
199
+ }();
200
+ }
201
+ });
202
+ export default require_netlifyEntry();
@@ -1,48 +1,105 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "node:path";
4
- import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
5
- import { genPluginImportsCode } from "../utils";
6
- function genNodeEntry(_) {
7
- return _genNodeEntry.apply(this, arguments);
8
- }
9
- function _genNodeEntry() {
10
- _genNodeEntry = _async_to_generator(function(param) {
11
- var config, plugins, appContext, defaultConfig, pluginImportCode, dynamicProdOptions, entryCode;
12
- return _ts_generator(this, function(_state) {
13
- switch (_state.label) {
14
- case 0:
15
- config = param.config, plugins = param.plugins, appContext = param.appContext;
16
- defaultConfig = {
17
- server: {
18
- port: 8080
19
- },
20
- output: {
21
- path: "."
22
- }
23
- };
24
- pluginImportCode = genPluginImportsCode(plugins || []);
25
- dynamicProdOptions = {
26
- config: config || defaultConfig,
27
- serverConfigFile: DEFAULT_SERVER_CONFIG,
28
- plugins
29
- };
30
- return [
31
- 4,
32
- fse.readFile(path.join(__dirname, "./nodeEntry.js"))
33
- ];
34
- case 1:
35
- entryCode = _state.sent().toString();
36
- entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
37
- return [
38
- 2,
39
- entryCode
40
- ];
41
- }
42
- });
43
- });
44
- return _genNodeEntry.apply(this, arguments);
45
- }
4
+ import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
5
+ import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
6
+ import { handleDependencies } from "../dependencies";
7
+ var createNodePreset = function(appContext, config) {
8
+ var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
9
+ var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
10
+ var outputDirectory = path.join(appDirectory, ".output");
11
+ var entryFilePath = path.join(outputDirectory, "index.js");
12
+ return {
13
+ prepare: function prepare() {
14
+ return _async_to_generator(function() {
15
+ return _ts_generator(this, function(_state) {
16
+ switch (_state.label) {
17
+ case 0:
18
+ return [
19
+ 4,
20
+ fse.remove(outputDirectory)
21
+ ];
22
+ case 1:
23
+ _state.sent();
24
+ return [
25
+ 2
26
+ ];
27
+ }
28
+ });
29
+ })();
30
+ },
31
+ writeOutput: function writeOutput() {
32
+ return _async_to_generator(function() {
33
+ return _ts_generator(this, function(_state) {
34
+ switch (_state.label) {
35
+ case 0:
36
+ return [
37
+ 4,
38
+ fse.copy(distDirectory, outputDirectory)
39
+ ];
40
+ case 1:
41
+ _state.sent();
42
+ return [
43
+ 2
44
+ ];
45
+ }
46
+ });
47
+ })();
48
+ },
49
+ genEntry: function genEntry() {
50
+ return _async_to_generator(function() {
51
+ var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, entryCode, serverAppContext;
52
+ return _ts_generator(this, function(_state) {
53
+ switch (_state.label) {
54
+ case 0:
55
+ serverConfig = {
56
+ server: {
57
+ port: 8080
58
+ },
59
+ bff: {
60
+ prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
61
+ },
62
+ output: {
63
+ path: "."
64
+ }
65
+ };
66
+ pluginImportCode = genPluginImportsCode(plugins || []);
67
+ dynamicProdOptions = {
68
+ config: serverConfig,
69
+ serverConfigFile: DEFAULT_SERVER_CONFIG,
70
+ plugins
71
+ };
72
+ return [
73
+ 4,
74
+ fse.readFile(path.join(__dirname, "./nodeEntry.js"))
75
+ ];
76
+ case 1:
77
+ entryCode = _state.sent().toString();
78
+ serverAppContext = serverAppContenxtTemplate(appContext);
79
+ entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
80
+ return [
81
+ 4,
82
+ fse.writeFile(entryFilePath, entryCode)
83
+ ];
84
+ case 2:
85
+ _state.sent();
86
+ return [
87
+ 4,
88
+ handleDependencies(appDirectory, outputDirectory, [
89
+ "@modern-js/prod-server"
90
+ ])
91
+ ];
92
+ case 3:
93
+ _state.sent();
94
+ return [
95
+ 2
96
+ ];
97
+ }
98
+ });
99
+ })();
100
+ }
101
+ };
102
+ };
46
103
  export {
47
- genNodeEntry
104
+ createNodePreset
48
105
  };
@@ -1,45 +1,208 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "node:path";
4
- import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
5
- import { genPluginImportsCode } from "../utils";
6
- function genVercelEntry(_) {
7
- return _genVercelEntry.apply(this, arguments);
8
- }
9
- function _genVercelEntry() {
10
- _genVercelEntry = _async_to_generator(function(param) {
11
- var config, plugins, appContext, defaultConfig, pluginImportCode, dynamicProdOptions, entryCode;
12
- return _ts_generator(this, function(_state) {
13
- switch (_state.label) {
14
- case 0:
15
- config = param.config, plugins = param.plugins, appContext = param.appContext;
16
- defaultConfig = {
17
- output: {
18
- path: "."
19
- }
20
- };
21
- pluginImportCode = genPluginImportsCode(plugins || []);
22
- dynamicProdOptions = {
23
- config: config || defaultConfig,
24
- serverConfigFile: DEFAULT_SERVER_CONFIG,
25
- plugins
26
- };
27
- return [
28
- 4,
29
- fse.readFile(path.join(__dirname, "./vercelEntry.js"))
30
- ];
31
- case 1:
32
- entryCode = _state.sent().toString();
33
- entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", appContext.sharedDirectory).replace("p_apiDirectory", appContext.apiDirectory).replace("p_lambdaDirectory", appContext.lambdaDirectory);
34
- return [
35
- 2,
36
- entryCode
37
- ];
38
- }
39
- });
40
- });
41
- return _genVercelEntry.apply(this, arguments);
42
- }
4
+ import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, getInternalPlugins } from "@modern-js/utils";
5
+ import { isMainEntry } from "../../../utils/routes";
6
+ import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
7
+ import { handleDependencies } from "../dependencies";
8
+ var createVercelPreset = function(appContext, config, needModernServer) {
9
+ var appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
10
+ var plugins = getInternalPlugins(appDirectory, serverInternalPlugins);
11
+ var vercelOutput = path.join(appDirectory, ".vercel");
12
+ var outputDirectory = path.join(vercelOutput, "output");
13
+ var funcsDirectory = path.join(outputDirectory, "functions", "index.func");
14
+ var entryFilePath = path.join(funcsDirectory, "index.js");
15
+ return {
16
+ prepare: function prepare() {
17
+ return _async_to_generator(function() {
18
+ return _ts_generator(this, function(_state) {
19
+ switch (_state.label) {
20
+ case 0:
21
+ return [
22
+ 4,
23
+ fse.remove(vercelOutput)
24
+ ];
25
+ case 1:
26
+ _state.sent();
27
+ return [
28
+ 2
29
+ ];
30
+ }
31
+ });
32
+ })();
33
+ },
34
+ writeOutput: function writeOutput() {
35
+ return _async_to_generator(function() {
36
+ var config2, mainEntryName, staticDirectory, destHtmlDirectory, outputHtmlDirectory;
37
+ return _ts_generator(this, function(_state) {
38
+ switch (_state.label) {
39
+ case 0:
40
+ config2 = {
41
+ version: 3,
42
+ routes: [
43
+ {
44
+ src: "/static/(.*)",
45
+ headers: {
46
+ "cache-control": "s-maxage=31536000, immutable"
47
+ },
48
+ continue: true
49
+ },
50
+ {
51
+ handle: "filesystem"
52
+ }
53
+ ]
54
+ };
55
+ if (!needModernServer) {
56
+ mainEntryName = config2.source.mainEntryName;
57
+ entrypoints.forEach(function(entry) {
58
+ var isMain = isMainEntry(entry.entryName, mainEntryName);
59
+ config2.routes.push({
60
+ src: "/".concat(isMain ? "" : entry.entryName, "(?:/.*)?"),
61
+ headers: {
62
+ "cache-control": "s-maxage=0"
63
+ },
64
+ dest: "/html/".concat(entry.entryName, "/index.html")
65
+ });
66
+ });
67
+ } else {
68
+ config2.routes.push({
69
+ src: "/(.*)",
70
+ dest: "/index"
71
+ });
72
+ }
73
+ return [
74
+ 4,
75
+ fse.ensureDir(outputDirectory)
76
+ ];
77
+ case 1:
78
+ _state.sent();
79
+ return [
80
+ 4,
81
+ fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
82
+ spaces: 2
83
+ })
84
+ ];
85
+ case 2:
86
+ _state.sent();
87
+ staticDirectory = path.join(outputDirectory, "static/static");
88
+ return [
89
+ 4,
90
+ fse.copy(path.join(distDirectory, "static"), staticDirectory)
91
+ ];
92
+ case 3:
93
+ _state.sent();
94
+ if (!!needModernServer)
95
+ return [
96
+ 3,
97
+ 5
98
+ ];
99
+ destHtmlDirectory = path.join(distDirectory, "html");
100
+ outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
101
+ return [
102
+ 4,
103
+ fse.copy(destHtmlDirectory, outputHtmlDirectory)
104
+ ];
105
+ case 4:
106
+ _state.sent();
107
+ return [
108
+ 3,
109
+ 9
110
+ ];
111
+ case 5:
112
+ return [
113
+ 4,
114
+ fse.ensureDir(funcsDirectory)
115
+ ];
116
+ case 6:
117
+ _state.sent();
118
+ return [
119
+ 4,
120
+ fse.copy(distDirectory, funcsDirectory, {
121
+ filter: function(src) {
122
+ var distStaticDirectory = path.join(distDirectory, "static");
123
+ return !src.includes(distStaticDirectory);
124
+ }
125
+ })
126
+ ];
127
+ case 7:
128
+ _state.sent();
129
+ return [
130
+ 4,
131
+ fse.writeJSON(path.join(funcsDirectory, ".vc-config.json"), {
132
+ runtime: "nodejs16.x",
133
+ handler: "index.js",
134
+ launcherType: "Nodejs",
135
+ shouldAddHelpers: false,
136
+ supportsResponseStreaming: true
137
+ })
138
+ ];
139
+ case 8:
140
+ _state.sent();
141
+ _state.label = 9;
142
+ case 9:
143
+ return [
144
+ 2
145
+ ];
146
+ }
147
+ });
148
+ })();
149
+ },
150
+ genEntry: function genEntry() {
151
+ return _async_to_generator(function() {
152
+ var _config_bff, serverConfig, pluginImportCode, dynamicProdOptions, serverAppContext, entryCode;
153
+ return _ts_generator(this, function(_state) {
154
+ switch (_state.label) {
155
+ case 0:
156
+ if (!needModernServer) {
157
+ return [
158
+ 2
159
+ ];
160
+ }
161
+ serverConfig = {
162
+ bff: {
163
+ prefix: config === null || config === void 0 ? void 0 : (_config_bff = config.bff) === null || _config_bff === void 0 ? void 0 : _config_bff.prefix
164
+ },
165
+ output: {
166
+ path: "."
167
+ }
168
+ };
169
+ pluginImportCode = genPluginImportsCode(plugins || []);
170
+ dynamicProdOptions = {
171
+ config: serverConfig,
172
+ serverConfigFile: DEFAULT_SERVER_CONFIG,
173
+ plugins
174
+ };
175
+ serverAppContext = serverAppContenxtTemplate(appContext);
176
+ return [
177
+ 4,
178
+ fse.readFile(path.join(__dirname, "./vercelEntry.js"))
179
+ ];
180
+ case 1:
181
+ entryCode = _state.sent().toString();
182
+ entryCode = entryCode.replace("p_genPluginImportsCode", pluginImportCode).replace("p_ROUTE_SPEC_FILE", '"'.concat(ROUTE_SPEC_FILE, '"')).replace("p_dynamicProdOptions", JSON.stringify(dynamicProdOptions)).replace("p_sharedDirectory", serverAppContext.sharedDirectory).replace("p_apiDirectory", serverAppContext.apiDirectory).replace("p_lambdaDirectory", serverAppContext.lambdaDirectory);
183
+ return [
184
+ 4,
185
+ fse.writeFile(entryFilePath, entryCode)
186
+ ];
187
+ case 2:
188
+ _state.sent();
189
+ return [
190
+ 4,
191
+ handleDependencies(appDirectory, funcsDirectory, [
192
+ "@modern-js/prod-server"
193
+ ])
194
+ ];
195
+ case 3:
196
+ _state.sent();
197
+ return [
198
+ 2
199
+ ];
200
+ }
201
+ });
202
+ })();
203
+ }
204
+ };
205
+ };
43
206
  export {
44
- genVercelEntry
207
+ createVercelPreset
45
208
  };
@@ -4,8 +4,14 @@ import path from "path";
4
4
  import os from "node:os";
5
5
  import { ROUTE_SPEC_FILE, fs as fse, isDepExists } from "@modern-js/utils";
6
6
  import { parseNodeModulePath } from "mlly";
7
- var severAppContextTemplate = function(serverAppContext) {
8
- return "{\n sharedDirectory: ".concat(serverAppContext.sharedDirectory, ",\n apiDirectory: ").concat(serverAppContext.apiDirectory, ",\n lambdaDirectory: ").concat(serverAppContext.lambdaDirectory, ",\n }");
7
+ var serverAppContenxtTemplate = function(appContext) {
8
+ var appDirectory = appContext.appDirectory, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName;
9
+ return {
10
+ sharedDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, sharedDirectory), '")'),
11
+ apiDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, apiDirectory), '")'),
12
+ lambdaDirectory: 'path.join(__dirname, "'.concat(path.relative(appDirectory, lambdaDirectory), '")'),
13
+ metaName
14
+ };
9
15
  };
10
16
  var getPluginsCode = function(plugins) {
11
17
  return "[".concat(plugins.map(function(_, index) {
@@ -239,6 +245,6 @@ export {
239
245
  getPluginsCode,
240
246
  getProjectUsage,
241
247
  linkPackage,
242
- severAppContextTemplate,
248
+ serverAppContenxtTemplate,
243
249
  writePackage
244
250
  };