@modern-js/server-core 2.65.2 → 2.65.4

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.
@@ -128,7 +128,7 @@ function createStaticMiddleware(options) {
128
128
  }
129
129
  const stat = await import_utils.fs.lstat(filepath);
130
130
  const { size } = stat;
131
- const chunk = await import_fileReader.fileReader.readFile(filepath, "buffer");
131
+ const chunk = await import_fileReader.fileReader.readFileFromSystem(filepath, "buffer");
132
132
  c.header("Content-Length", String(size));
133
133
  return c.body(chunk, 200);
134
134
  } else {
@@ -173,7 +173,7 @@ function createStaticMiddleware(options) {
173
173
  size = stat.size;
174
174
  return [
175
175
  4,
176
- fileReader.readFile(filepath, "buffer")
176
+ fileReader.readFileFromSystem(filepath, "buffer")
177
177
  ];
178
178
  case 3:
179
179
  chunk = _state.sent();
@@ -93,7 +93,7 @@ function createStaticMiddleware(options) {
93
93
  }
94
94
  const stat = await fs.lstat(filepath);
95
95
  const { size } = stat;
96
- const chunk = await fileReader.readFile(filepath, "buffer");
96
+ const chunk = await fileReader.readFileFromSystem(filepath, "buffer");
97
97
  c.header("Content-Length", String(size));
98
98
  return c.body(chunk, 200);
99
99
  } else {
@@ -12,4 +12,13 @@ export interface ServerStaticOptions {
12
12
  html: HtmlNormalizedConfig;
13
13
  routes?: ServerRoute[];
14
14
  }
15
+ /**
16
+ * This middleware is used to serve static assets
17
+ * TODO: In next major version, only serve static assets in the `static` and `upload` directory.
18
+ *
19
+ * 1. In dev mode, the static assets generated by bundler will be served by the rsbuildDevMiddleware, and other file in `static` directory will be served by this middleware.
20
+ * 2. In prod mode, all the static assets in `static` and `upload` directory will be served by this middleware.
21
+ * 3. So some file not in `static` can be access in dev mode, but not in prod mode. Cause we can not serve all files in prod mode, as we should not expose server code in prod mode.
22
+ * 4. Through Modern.js not serve this file in prod mode, you can upload the files to a CDN.
23
+ */
15
24
  export declare function createStaticMiddleware(options: ServerStaticOptions): Middleware;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.65.2",
18
+ "version": "2.65.4",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -53,9 +53,9 @@
53
53
  "flatted": "^3.2.9",
54
54
  "hono": "^3.12.2",
55
55
  "ts-deepmerge": "7.0.2",
56
- "@modern-js/plugin": "2.65.2",
57
- "@modern-js/runtime-utils": "2.65.2",
58
- "@modern-js/utils": "2.65.2"
56
+ "@modern-js/plugin": "2.65.4",
57
+ "@modern-js/runtime-utils": "2.65.4",
58
+ "@modern-js/utils": "2.65.4"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/jest": "^29",
@@ -65,9 +65,9 @@
65
65
  "jest": "^29",
66
66
  "ts-jest": "^29.1.0",
67
67
  "typescript": "^5",
68
- "@modern-js/types": "2.65.2",
69
- "@scripts/jest-config": "2.65.2",
70
- "@scripts/build": "2.65.2"
68
+ "@modern-js/types": "2.65.4",
69
+ "@scripts/build": "2.65.4",
70
+ "@scripts/jest-config": "2.65.4"
71
71
  },
72
72
  "sideEffects": false,
73
73
  "publishConfig": {