@modern-js/app-tools 2.49.1-alpha.13 → 2.49.1-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.
@@ -46,7 +46,7 @@ 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
50
  const { useSSR, useAPI, useWebServer } = (0, import_utils2.getProjectUsage)(appDirectory, distDirectory);
51
51
  const needModernServer = useSSR || useAPI || useWebServer;
52
52
  const configContext = api.useResolvedConfigContext();
@@ -73,18 +73,29 @@ var deploy_default = () => ({
73
73
  },
74
74
  {
75
75
  handle: "filesystem"
76
- },
77
- {
78
- src: "/(.*)",
79
- headers: {
80
- "cache-control": "s-maxage=0"
81
- },
82
- dest: "/html/main/index.html"
83
76
  }
84
77
  ]
85
78
  };
79
+ if (!needModernServer) {
80
+ entrypoints.forEach((entry) => {
81
+ config2.routes.push({
82
+ src: `/${entry.entryName}(?:/.*)?`,
83
+ headers: {
84
+ "cache-control": "s-maxage=0"
85
+ },
86
+ dest: `/html/${entry.entryName}/index.html`
87
+ });
88
+ });
89
+ } else {
90
+ config2.routes.push({
91
+ src: "/(.*)",
92
+ dest: `/index`
93
+ });
94
+ }
86
95
  await import_utils.fs.ensureDir(outputDirectory);
87
- await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2);
96
+ await import_utils.fs.writeJSON(import_path.default.join(outputDirectory, "config.json"), config2, {
97
+ spaces: 2
98
+ });
88
99
  staticDirectory = import_path.default.join(outputDirectory, "static/static");
89
100
  await import_utils.fs.copy(import_path.default.join(distDirectory, "static"), staticDirectory);
90
101
  if (!needModernServer) {
@@ -16,12 +16,12 @@ 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
25
  _getProjectUsage = getProjectUsage(appDirectory, distDirectory), useSSR = _getProjectUsage.useSSR, useAPI = _getProjectUsage.useAPI, useWebServer = _getProjectUsage.useWebServer;
26
26
  needModernServer = useSSR || useAPI || useWebServer;
27
27
  configContext = api.useResolvedConfigContext();
@@ -72,16 +72,25 @@ function deploy_default() {
72
72
  },
73
73
  {
74
74
  handle: "filesystem"
75
- },
76
- {
77
- src: "/(.*)",
78
- headers: {
79
- "cache-control": "s-maxage=0"
80
- },
81
- dest: "/html/main/index.html"
82
75
  }
83
76
  ]
84
77
  };
78
+ if (!needModernServer) {
79
+ entrypoints.forEach(function(entry) {
80
+ config.routes.push({
81
+ src: "/".concat(entry.entryName, "(?:/.*)?"),
82
+ headers: {
83
+ "cache-control": "s-maxage=0"
84
+ },
85
+ dest: "/html/".concat(entry.entryName, "/index.html")
86
+ });
87
+ });
88
+ } else {
89
+ config.routes.push({
90
+ src: "/(.*)",
91
+ dest: "/index"
92
+ });
93
+ }
85
94
  return [
86
95
  4,
87
96
  fse.ensureDir(outputDirectory)
@@ -90,7 +99,9 @@ function deploy_default() {
90
99
  _state.sent();
91
100
  return [
92
101
  4,
93
- fse.writeJSON(path.join(outputDirectory, "config.json"), config)
102
+ fse.writeJSON(path.join(outputDirectory, "config.json"), config, {
103
+ spaces: 2
104
+ })
94
105
  ];
95
106
  case 6:
96
107
  _state.sent();
@@ -13,7 +13,7 @@ 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
17
  const { useSSR, useAPI, useWebServer } = getProjectUsage(appDirectory, distDirectory);
18
18
  const needModernServer = useSSR || useAPI || useWebServer;
19
19
  const configContext = api.useResolvedConfigContext();
@@ -40,18 +40,29 @@ var deploy_default = () => ({
40
40
  },
41
41
  {
42
42
  handle: "filesystem"
43
- },
44
- {
45
- src: "/(.*)",
46
- headers: {
47
- "cache-control": "s-maxage=0"
48
- },
49
- dest: "/html/main/index.html"
50
43
  }
51
44
  ]
52
45
  };
46
+ if (!needModernServer) {
47
+ entrypoints.forEach((entry) => {
48
+ config2.routes.push({
49
+ src: `/${entry.entryName}(?:/.*)?`,
50
+ headers: {
51
+ "cache-control": "s-maxage=0"
52
+ },
53
+ dest: `/html/${entry.entryName}/index.html`
54
+ });
55
+ });
56
+ } else {
57
+ config2.routes.push({
58
+ src: "/(.*)",
59
+ dest: `/index`
60
+ });
61
+ }
53
62
  await fse.ensureDir(outputDirectory);
54
- await fse.writeJSON(path.join(outputDirectory, "config.json"), config2);
63
+ await fse.writeJSON(path.join(outputDirectory, "config.json"), config2, {
64
+ spaces: 2
65
+ });
55
66
  staticDirectory = path.join(outputDirectory, "static/static");
56
67
  await fse.copy(path.join(distDirectory, "static"), staticDirectory);
57
68
  if (!needModernServer) {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.49.1-alpha.13",
18
+ "version": "2.49.1-alpha.15",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -80,19 +80,19 @@
80
80
  "mlly": "^1.6.1",
81
81
  "pkg-types": "^1.1.0",
82
82
  "@modern-js/core": "2.49.0",
83
- "@modern-js/node-bundle-require": "2.49.0",
84
83
  "@modern-js/plugin": "2.49.0",
85
- "@modern-js/plugin-data-loader": "2.49.0",
86
84
  "@modern-js/plugin-i18n": "2.49.0",
87
- "@modern-js/prod-server": "2.49.0",
85
+ "@modern-js/plugin-data-loader": "2.49.0",
86
+ "@modern-js/node-bundle-require": "2.49.0",
88
87
  "@modern-js/plugin-lint": "2.49.0",
89
88
  "@modern-js/rsbuild-plugin-esbuild": "2.49.1",
90
- "@modern-js/server": "2.49.0",
91
89
  "@modern-js/server-core": "2.49.0",
92
- "@modern-js/types": "2.49.0",
93
- "@modern-js/server-utils": "2.49.0",
90
+ "@modern-js/prod-server": "2.49.0",
91
+ "@modern-js/server": "2.49.0",
94
92
  "@modern-js/uni-builder": "2.49.0",
95
- "@modern-js/utils": "2.49.0"
93
+ "@modern-js/server-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",