@modern-js/app-tools 2.49.3-alpha.3 → 2.49.3-alpha.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,10 +54,32 @@ var deploy_default = () => ({
54
54
  let outputDirectory = import_path.default.join(appDirectory, ".output");
55
55
  let funcsDirectory = outputDirectory;
56
56
  let staticDirectory = import_path.default.join(outputDirectory, "static");
57
- if (deployTarget === "node" || deployTarget === "netlify") {
57
+ if (deployTarget === "node") {
58
58
  await import_utils.fs.remove(outputDirectory);
59
59
  await import_utils.fs.copy(distDirectory, outputDirectory);
60
60
  }
61
+ if (deployTarget === "netlify") {
62
+ const netlifyOutput = import_path.default.join(appDirectory, ".netlify");
63
+ funcsDirectory = import_path.default.join(netlifyOutput, "functions");
64
+ const routes = [];
65
+ if (!needModernServer) {
66
+ entrypoints.forEach((entry) => {
67
+ routes.push({
68
+ src: `/${entry.entryName}(?:/.*)?`,
69
+ dest: `/html/${entry.entryName}/index.html`
70
+ });
71
+ });
72
+ } else {
73
+ }
74
+ await import_utils.fs.remove(outputDirectory);
75
+ await import_utils.fs.ensureDir(funcsDirectory);
76
+ await import_utils.fs.copy(distDirectory, funcsDirectory, {
77
+ filter: (src) => {
78
+ const distStaticDirectory = import_path.default.join(distDirectory, "static");
79
+ return !src.includes(distStaticDirectory);
80
+ }
81
+ });
82
+ }
61
83
  if (deployTarget === "vercel") {
62
84
  const vercelOutput = import_path.default.join(appDirectory, ".vercel");
63
85
  await import_utils.fs.remove(vercelOutput);
@@ -17,7 +17,7 @@ function deploy_default() {
17
17
  return {
18
18
  beforeDeploy: function beforeDeploy() {
19
19
  return _async_to_generator(function() {
20
- var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, configContext, outputDirectory, funcsDirectory, staticDirectory, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
20
+ var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, configContext, outputDirectory, funcsDirectory, staticDirectory, netlifyOutput, routes, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
21
21
  return _ts_generator(this, function(_state) {
22
22
  switch (_state.label) {
23
23
  case 0:
@@ -29,7 +29,7 @@ function deploy_default() {
29
29
  outputDirectory = path.join(appDirectory, ".output");
30
30
  funcsDirectory = outputDirectory;
31
31
  staticDirectory = path.join(outputDirectory, "static");
32
- if (!(deployTarget === "node" || deployTarget === "netlify"))
32
+ if (!(deployTarget === "node"))
33
33
  return [
34
34
  3,
35
35
  3
@@ -48,17 +48,59 @@ function deploy_default() {
48
48
  _state.sent();
49
49
  _state.label = 3;
50
50
  case 3:
51
+ if (!(deployTarget === "netlify"))
52
+ return [
53
+ 3,
54
+ 7
55
+ ];
56
+ netlifyOutput = path.join(appDirectory, ".netlify");
57
+ funcsDirectory = path.join(netlifyOutput, "functions");
58
+ routes = [];
59
+ if (!needModernServer) {
60
+ entrypoints.forEach(function(entry) {
61
+ routes.push({
62
+ src: "/".concat(entry.entryName, "(?:/.*)?"),
63
+ dest: "/html/".concat(entry.entryName, "/index.html")
64
+ });
65
+ });
66
+ } else {
67
+ }
68
+ return [
69
+ 4,
70
+ fse.remove(outputDirectory)
71
+ ];
72
+ case 4:
73
+ _state.sent();
74
+ return [
75
+ 4,
76
+ fse.ensureDir(funcsDirectory)
77
+ ];
78
+ case 5:
79
+ _state.sent();
80
+ return [
81
+ 4,
82
+ fse.copy(distDirectory, funcsDirectory, {
83
+ filter: function(src) {
84
+ var distStaticDirectory = path.join(distDirectory, "static");
85
+ return !src.includes(distStaticDirectory);
86
+ }
87
+ })
88
+ ];
89
+ case 6:
90
+ _state.sent();
91
+ _state.label = 7;
92
+ case 7:
51
93
  if (!(deployTarget === "vercel"))
52
94
  return [
53
95
  3,
54
- 13
96
+ 17
55
97
  ];
56
98
  vercelOutput = path.join(appDirectory, ".vercel");
57
99
  return [
58
100
  4,
59
101
  fse.remove(vercelOutput)
60
102
  ];
61
- case 4:
103
+ case 8:
62
104
  _state.sent();
63
105
  outputDirectory = path.join(vercelOutput, "output");
64
106
  config = {
@@ -96,7 +138,7 @@ function deploy_default() {
96
138
  4,
97
139
  fse.ensureDir(outputDirectory)
98
140
  ];
99
- case 5:
141
+ case 9:
100
142
  _state.sent();
101
143
  return [
102
144
  4,
@@ -104,19 +146,19 @@ function deploy_default() {
104
146
  spaces: 2
105
147
  })
106
148
  ];
107
- case 6:
149
+ case 10:
108
150
  _state.sent();
109
151
  staticDirectory = path.join(outputDirectory, "static/static");
110
152
  return [
111
153
  4,
112
154
  fse.copy(path.join(distDirectory, "static"), staticDirectory)
113
155
  ];
114
- case 7:
156
+ case 11:
115
157
  _state.sent();
116
158
  if (!!needModernServer)
117
159
  return [
118
160
  3,
119
- 9
161
+ 13
120
162
  ];
121
163
  destHtmlDirectory = path.join(distDirectory, "html");
122
164
  outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
@@ -124,19 +166,19 @@ function deploy_default() {
124
166
  4,
125
167
  fse.copy(destHtmlDirectory, outputHtmlDirectory)
126
168
  ];
127
- case 8:
169
+ case 12:
128
170
  _state.sent();
129
171
  return [
130
172
  3,
131
- 13
173
+ 17
132
174
  ];
133
- case 9:
175
+ case 13:
134
176
  funcsDirectory = path.join(outputDirectory, "functions", "index.func");
135
177
  return [
136
178
  4,
137
179
  fse.ensureDir(funcsDirectory)
138
180
  ];
139
- case 10:
181
+ case 14:
140
182
  _state.sent();
141
183
  return [
142
184
  4,
@@ -147,7 +189,7 @@ function deploy_default() {
147
189
  }
148
190
  })
149
191
  ];
150
- case 11:
192
+ case 15:
151
193
  _state.sent();
152
194
  return [
153
195
  4,
@@ -159,10 +201,10 @@ function deploy_default() {
159
201
  supportsResponseStreaming: true
160
202
  })
161
203
  ];
162
- case 12:
204
+ case 16:
163
205
  _state.sent();
164
- _state.label = 13;
165
- case 13:
206
+ _state.label = 17;
207
+ case 17:
166
208
  bff = configContext.bff;
167
209
  config1 = {
168
210
  output: {
@@ -183,29 +225,29 @@ function deploy_default() {
183
225
  case "node":
184
226
  return [
185
227
  3,
186
- 14
228
+ 18
187
229
  ];
188
230
  case "vercel":
189
231
  return [
190
232
  3,
191
- 16
233
+ 20
192
234
  ];
193
235
  case "netlify":
194
236
  return [
195
237
  3,
196
- 18
238
+ 22
197
239
  ];
198
240
  }
199
241
  return [
200
242
  3,
201
- 20
243
+ 24
202
244
  ];
203
- case 14:
245
+ case 18:
204
246
  return [
205
247
  4,
206
248
  import("./entrys/node")
207
249
  ];
208
- case 15:
250
+ case 19:
209
251
  genNodeEntry = _state.sent().genNodeEntry;
210
252
  code = genNodeEntry({
211
253
  plugins,
@@ -214,14 +256,14 @@ function deploy_default() {
214
256
  });
215
257
  return [
216
258
  3,
217
- 21
259
+ 25
218
260
  ];
219
- case 16:
261
+ case 20:
220
262
  return [
221
263
  4,
222
264
  import("./entrys/vercel")
223
265
  ];
224
- case 17:
266
+ case 21:
225
267
  genVercelEntry = _state.sent().genVercelEntry;
226
268
  code = genVercelEntry({
227
269
  plugins,
@@ -230,14 +272,14 @@ function deploy_default() {
230
272
  });
231
273
  return [
232
274
  3,
233
- 21
275
+ 25
234
276
  ];
235
- case 18:
277
+ case 22:
236
278
  return [
237
279
  4,
238
280
  import("./entrys/netlify")
239
281
  ];
240
- case 19:
282
+ case 23:
241
283
  genNetlifyEntry = _state.sent().genNetlifyEntry;
242
284
  code = genNetlifyEntry({
243
285
  plugins,
@@ -246,25 +288,25 @@ function deploy_default() {
246
288
  });
247
289
  return [
248
290
  3,
249
- 21
291
+ 25
250
292
  ];
251
- case 20:
293
+ case 24:
252
294
  {
253
295
  code = 'throw new Error("unknown deploy target, MODERNJS_DEPLOY should be set");';
254
296
  }
255
- _state.label = 21;
256
- case 21:
297
+ _state.label = 25;
298
+ case 25:
257
299
  entryFilePath = path.join(funcsDirectory, "index.js");
258
300
  if (!needModernServer)
259
301
  return [
260
302
  3,
261
- 24
303
+ 28
262
304
  ];
263
305
  return [
264
306
  4,
265
307
  fse.writeFile(entryFilePath, code)
266
308
  ];
267
- case 22:
309
+ case 26:
268
310
  _state.sent();
269
311
  return [
270
312
  4,
@@ -272,10 +314,10 @@ function deploy_default() {
272
314
  "@modern-js/prod-server"
273
315
  ])
274
316
  ];
275
- case 23:
317
+ case 27:
276
318
  _state.sent();
277
- _state.label = 24;
278
- case 24:
319
+ _state.label = 28;
320
+ case 28:
279
321
  return [
280
322
  2
281
323
  ];
@@ -21,10 +21,32 @@ var deploy_default = () => ({
21
21
  let outputDirectory = path.join(appDirectory, ".output");
22
22
  let funcsDirectory = outputDirectory;
23
23
  let staticDirectory = path.join(outputDirectory, "static");
24
- if (deployTarget === "node" || deployTarget === "netlify") {
24
+ if (deployTarget === "node") {
25
25
  await fse.remove(outputDirectory);
26
26
  await fse.copy(distDirectory, outputDirectory);
27
27
  }
28
+ if (deployTarget === "netlify") {
29
+ const netlifyOutput = path.join(appDirectory, ".netlify");
30
+ funcsDirectory = path.join(netlifyOutput, "functions");
31
+ const routes = [];
32
+ if (!needModernServer) {
33
+ entrypoints.forEach((entry) => {
34
+ routes.push({
35
+ src: `/${entry.entryName}(?:/.*)?`,
36
+ dest: `/html/${entry.entryName}/index.html`
37
+ });
38
+ });
39
+ } else {
40
+ }
41
+ await fse.remove(outputDirectory);
42
+ await fse.ensureDir(funcsDirectory);
43
+ await fse.copy(distDirectory, funcsDirectory, {
44
+ filter: (src) => {
45
+ const distStaticDirectory = path.join(distDirectory, "static");
46
+ return !src.includes(distStaticDirectory);
47
+ }
48
+ });
49
+ }
28
50
  if (deployTarget === "vercel") {
29
51
  const vercelOutput = path.join(appDirectory, ".vercel");
30
52
  await fse.remove(vercelOutput);
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.3-alpha.3",
18
+ "version": "2.49.3-alpha.5",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -80,20 +80,20 @@
80
80
  "mlly": "^1.6.1",
81
81
  "pkg-types": "^1.1.0",
82
82
  "std-env": "^3.7.0",
83
+ "@modern-js/node-bundle-require": "2.49.2",
83
84
  "@modern-js/core": "2.49.2",
84
85
  "@modern-js/plugin": "2.49.2",
85
- "@modern-js/node-bundle-require": "2.49.2",
86
+ "@modern-js/plugin-data-loader": "2.49.2",
86
87
  "@modern-js/plugin-i18n": "2.49.2",
87
88
  "@modern-js/prod-server": "2.49.2",
88
- "@modern-js/rsbuild-plugin-esbuild": "2.49.2",
89
89
  "@modern-js/plugin-lint": "2.49.2",
90
- "@modern-js/server": "2.49.2",
90
+ "@modern-js/rsbuild-plugin-esbuild": "2.49.2",
91
91
  "@modern-js/server-utils": "2.49.2",
92
+ "@modern-js/server": "2.49.2",
92
93
  "@modern-js/server-core": "2.49.2",
93
94
  "@modern-js/types": "2.49.2",
94
95
  "@modern-js/uni-builder": "2.49.2",
95
- "@modern-js/utils": "2.49.2",
96
- "@modern-js/plugin-data-loader": "2.49.2"
96
+ "@modern-js/utils": "2.49.2"
97
97
  },
98
98
  "devDependencies": {
99
99
  "@rsbuild/plugin-swc": "0.6.10",