@modern-js/app-tools 2.49.1-alpha.12 → 2.49.1-alpha.14

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.
@@ -46,7 +46,8 @@ var deploy_default = () => ({
46
46
  return {
47
47
  async beforeDeploy() {
48
48
  const appContext = api.useAppContext();
49
- const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
49
+ const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
50
+ console.log(appContext.entrypoints);
50
51
  const { useSSR, useAPI, useWebServer } = (0, import_utils2.getProjectUsage)(appDirectory, distDirectory);
51
52
  const needModernServer = useSSR || useAPI || useWebServer;
52
53
  const configContext = api.useResolvedConfigContext();
@@ -73,23 +74,29 @@ var deploy_default = () => ({
73
74
  },
74
75
  {
75
76
  handle: "filesystem"
76
- },
77
- {
78
- src: "/(.*)",
79
- headers: {
80
- "cache-control": "s-maxage=0"
81
- },
82
- dest: "/html/main/index.html"
83
77
  }
84
78
  ]
85
79
  };
80
+ if (!needModernServer) {
81
+ entrypoints.forEach((entry) => {
82
+ config2.routes.push({
83
+ src: `/${entry.entryName}(?:/.*)?`,
84
+ headers: {
85
+ "cache-control": "s-maxage=0"
86
+ },
87
+ dest: `/html/${entry.entryName}/index.html`
88
+ });
89
+ });
90
+ }
86
91
  await import_utils.fs.ensureDir(outputDirectory);
87
- await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2);
92
+ await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2, {
93
+ spaces: 2
94
+ });
88
95
  staticDirectory = import_path.default.join(outputDirectory, "static/static");
89
96
  await import_utils.fs.copy(import_path.default.join(distDirectory, "static"), staticDirectory);
90
97
  if (!needModernServer) {
91
98
  const destHtmlDirectory = import_path.default.join(distDirectory, "html");
92
- const outputHtmlDirectory = import_path.default.join(staticDirectory, "html");
99
+ const outputHtmlDirectory = import_path.default.join(import_path.default.join(outputDirectory, "static"), "html");
93
100
  await import_utils.fs.copy(destHtmlDirectory, outputHtmlDirectory);
94
101
  } else {
95
102
  funcsDirectory = import_path.default.join(outputDirectory, "functions", "index.func");
@@ -16,12 +16,13 @@ function deploy_default() {
16
16
  return {
17
17
  beforeDeploy: function beforeDeploy() {
18
18
  return _async_to_generator(function() {
19
- var appContext, appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, _getProjectUsage, useSSR, useAPI, useWebServer, needModernServer, configContext, outputDirectory, funcsDirectory, staticDirectory, vercelOutput, config, destHtmlDirectory, outputHtmlDirectory, bff, config1, plugins, serverAppContext, code, genNodeEntry, genVercelEntry, genNetlifyEntry, entryFilePath;
19
+ 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
20
  return _ts_generator(this, function(_state) {
21
21
  switch (_state.label) {
22
22
  case 0:
23
23
  appContext = api.useAppContext();
24
- appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName;
24
+ appDirectory = appContext.appDirectory, distDirectory = appContext.distDirectory, serverInternalPlugins = appContext.serverInternalPlugins, sharedDirectory = appContext.sharedDirectory, apiDirectory = appContext.apiDirectory, lambdaDirectory = appContext.lambdaDirectory, metaName = appContext.metaName, entrypoints = appContext.entrypoints;
25
+ console.log(appContext.entrypoints);
25
26
  _getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
26
27
  needModernServer = useSSR || useAPI || useWebServer;
27
28
  configContext = api.useResolvedConfigContext();
@@ -72,16 +73,20 @@ function deploy_default() {
72
73
  },
73
74
  {
74
75
  handle: "filesystem"
75
- },
76
- {
77
- src: "/(.*)",
78
- headers: {
79
- "cache-control": "s-maxage=0"
80
- },
81
- dest: "/html/main/index.html"
82
76
  }
83
77
  ]
84
78
  };
79
+ if (!needModernServer) {
80
+ entrypoints.forEach(function(entry) {
81
+ config.routes.push({
82
+ src: "/".concat(entry.entryName, "(?:/.*)?"),
83
+ headers: {
84
+ "cache-control": "s-maxage=0"
85
+ },
86
+ dest: "/html/".concat(entry.entryName, "/index.html")
87
+ });
88
+ });
89
+ }
85
90
  return [
86
91
  4,
87
92
  fse.ensureDir(outputDirectory)
@@ -90,7 +95,9 @@ function deploy_default() {
90
95
  _state.sent();
91
96
  return [
92
97
  4,
93
- fse.writeJSON(path.join(outputDirectory, "config.json"), config)
98
+ fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
99
+ spaces: 2
100
+ })
94
101
  ];
95
102
  case 6:
96
103
  _state.sent();
@@ -107,7 +114,7 @@ function deploy_default() {
107
114
  9
108
115
  ];
109
116
  destHtmlDirectory = path.join(distDirectory, "html");
110
- outputHtmlDirectory = path.join(staticDirectory, "html");
117
+ outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
111
118
  return [
112
119
  4,
113
120
  fse.copy(destHtmlDirectory, outputHtmlDirectory)
@@ -13,7 +13,8 @@ var deploy_default = () => ({
13
13
  return {
14
14
  async beforeDeploy() {
15
15
  const appContext = api.useAppContext();
16
- const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
16
+ const { appDirectory, distDirectory, serverInternalPlugins, sharedDirectory, apiDirectory, lambdaDirectory, metaName, entrypoints } = appContext;
17
+ console.log(appContext.entrypoints);
17
18
  const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
18
19
  const needModernServer = useSSR || useAPI || useWebServer;
19
20
  const configContext = api.useResolvedConfigContext();
@@ -40,23 +41,29 @@ var deploy_default = () => ({
40
41
  },
41
42
  {
42
43
  handle: "filesystem"
43
- },
44
- {
45
- src: "/(.*)",
46
- headers: {
47
- "cache-control": "s-maxage=0"
48
- },
49
- dest: "/html/main/index.html"
50
44
  }
51
45
  ]
52
46
  };
47
+ if (!needModernServer) {
48
+ entrypoints.forEach((entry) => {
49
+ config2.routes.push({
50
+ src: `/${entry.entryName}(?:/.*)?`,
51
+ headers: {
52
+ "cache-control": "s-maxage=0"
53
+ },
54
+ dest: `/html/${entry.entryName}/index.html`
55
+ });
56
+ });
57
+ }
53
58
  await fse.ensureDir(outputDirectory);
54
- await fse.writeJSON(path.join(outputDirectory, "config.json"), config2);
59
+ await fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
60
+ spaces: 2
61
+ });
55
62
  staticDirectory = path.join(outputDirectory, "static/static");
56
63
  await fse.copy(path.join(distDirectory, "static"), staticDirectory);
57
64
  if (!needModernServer) {
58
65
  const destHtmlDirectory = path.join(distDirectory, "html");
59
- const outputHtmlDirectory = path.join(staticDirectory, "html");
66
+ const outputHtmlDirectory = path.join(path.join(outputDirectory, "static"), "html");
60
67
  await fse.copy(destHtmlDirectory, outputHtmlDirectory);
61
68
  } else {
62
69
  funcsDirectory = path.join(outputDirectory, "functions", "index.func");
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.1-alpha.12",
18
+ "version": "2.49.1-alpha.14",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -79,20 +79,20 @@
79
79
  "esbuild-register": "^3.5.0",
80
80
  "mlly": "^1.6.1",
81
81
  "pkg-types": "^1.1.0",
82
- "@modern-js/core": "2.49.0",
83
82
  "@modern-js/node-bundle-require": "2.49.0",
84
- "@modern-js/plugin": "2.49.0",
85
83
  "@modern-js/plugin-data-loader": "2.49.0",
84
+ "@modern-js/core": "2.49.0",
85
+ "@modern-js/plugin": "2.49.0",
86
86
  "@modern-js/plugin-i18n": "2.49.0",
87
87
  "@modern-js/plugin-lint": "2.49.0",
88
88
  "@modern-js/prod-server": "2.49.0",
89
89
  "@modern-js/rsbuild-plugin-esbuild": "2.49.1",
90
- "@modern-js/server": "2.49.0",
91
- "@modern-js/server-core": "2.49.0",
92
- "@modern-js/types": "2.49.0",
93
90
  "@modern-js/server-utils": "2.49.0",
91
+ "@modern-js/server-core": "2.49.0",
92
+ "@modern-js/server": "2.49.0",
94
93
  "@modern-js/uni-builder": "2.49.0",
95
- "@modern-js/utils": "2.49.0"
94
+ "@modern-js/utils": "2.49.0",
95
+ "@modern-js/types": "2.49.0"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@rsbuild/plugin-swc": "0.6.4",