|
1 | 1 | import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js"; |
2 | 2 | import { describe, expect, test } from "vitest"; |
3 | 3 |
|
4 | | -import { |
5 | | - buildIdRule, |
6 | | - createCacheHandlerRule, |
7 | | - createComposableCacheHandlersRule, |
8 | | - createMiddlewareManifestRule, |
9 | | -} from "./next-server.js"; |
| 4 | +import { buildIdRule, createCacheHandlerRule, createComposableCacheHandlersRule } from "./next-server.js"; |
10 | 5 |
|
11 | 6 | describe("Next Server", () => { |
12 | 7 | const nextServerCode = ` |
@@ -172,91 +167,6 @@ class NextNodeServer extends _baseserver.default { |
172 | 167 | `); |
173 | 168 | }); |
174 | 169 |
|
175 | | - test("middleware manifest", () => { |
176 | | - expect(patchCode(nextServerCode, createMiddlewareManifestRule("manifest"))).toMatchInlineSnapshot(` |
177 | | - "class NextNodeServer extends _baseserver.default { |
178 | | - constructor(options){ |
179 | | - // Initialize super class |
180 | | - super(options); |
181 | | - this.handleNextImageRequest = async (req, res, parsedUrl) => { /* ... */ }; |
182 | | - } |
183 | | - async handleUpgrade() { |
184 | | - // The web server does not support web sockets, it's only used for HMR in |
185 | | - // development. |
186 | | - } |
187 | | - loadEnvConfig({ dev, forceReload, silent }) { |
188 | | - (0, _env.loadEnvConfig)(this.dir, dev, silent ? { |
189 | | - info: ()=>{}, |
190 | | - error: ()=>{} |
191 | | - } : _log, forceReload); |
192 | | - } |
193 | | - async hasPage(pathname) { |
194 | | - var _this_nextConfig_i18n; |
195 | | - return !!(0, _require.getMaybePagePath)(pathname, this.distDir, (_this_nextConfig_i18n = this.nextConfig.i18n) == null ? void 0 : _this_nextConfig_i18n.locales, this.enabledDirectories.app); |
196 | | - } |
197 | | - getBuildId() { |
198 | | - const buildIdFile = (0, _path.join)(this.distDir, _constants.BUILD_ID_FILE); |
199 | | - try { |
200 | | - return _fs.default.readFileSync(buildIdFile, "utf8").trim(); |
201 | | - } catch (err) { |
202 | | - if (err.code === "ENOENT") { |
203 | | - throw new Error(\`Could not find a production build in the '\${this.distDir}' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id\`); |
204 | | - } |
205 | | - throw err; |
206 | | - } |
207 | | - } |
208 | | - getMiddlewareManifest() { |
209 | | - return "manifest"; |
210 | | - } |
211 | | - async loadCustomCacheHandlers() { |
212 | | - const { cacheHandlers } = this.nextConfig.experimental; |
213 | | - if (!cacheHandlers) return; |
214 | | - // If we've already initialized the cache handlers interface, don't do it |
215 | | - // again. |
216 | | - if (!(0, _handlers.initializeCacheHandlers)()) return; |
217 | | - for (const [kind, handler] of Object.entries(cacheHandlers)){ |
218 | | - if (!handler) continue; |
219 | | - (0, _handlers.setCacheHandler)(kind, (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault((0, _formatdynamicimportpath.formatDynamicImportPath)(this.distDir, handler)))); |
220 | | - } |
221 | | - } |
222 | | - async getIncrementalCache({ requestHeaders, requestProtocol }) { |
223 | | - const dev = !!this.renderOpts.dev; |
224 | | - let CacheHandler; |
225 | | - const { cacheHandler } = this.nextConfig; |
226 | | - if (cacheHandler) { |
227 | | - CacheHandler = (0, _interopdefault.interopDefault)(await dynamicImportEsmDefault((0, _formatdynamicimportpath.formatDynamicImportPath)(this.distDir, cacheHandler))); |
228 | | - } |
229 | | - await this.loadCustomCacheHandlers(); |
230 | | - // incremental-cache is request specific |
231 | | - // although can have shared caches in module scope |
232 | | - // per-cache handler |
233 | | - return new _incrementalcache.IncrementalCache({ |
234 | | - fs: this.getCacheFilesystem(), |
235 | | - dev, |
236 | | - requestHeaders, |
237 | | - requestProtocol, |
238 | | - allowedRevalidateHeaderKeys: this.nextConfig.experimental.allowedRevalidateHeaderKeys, |
239 | | - minimalMode: this.minimalMode, |
240 | | - serverDistDir: this.serverDistDir, |
241 | | - fetchCacheKeyPrefix: this.nextConfig.experimental.fetchCacheKeyPrefix, |
242 | | - maxMemoryCacheSize: this.nextConfig.cacheMaxMemorySize, |
243 | | - flushToDisk: !this.minimalMode && this.nextConfig.experimental.isrFlushToDisk, |
244 | | - getPrerenderManifest: ()=>this.getPrerenderManifest(), |
245 | | - CurCacheHandler: CacheHandler |
246 | | - }); |
247 | | - } |
248 | | - getEnabledDirectories(dev) { |
249 | | - const dir = dev ? this.dir : this.serverDistDir; |
250 | | - return { |
251 | | - app: (0, _findpagesdir.findDir)(dir, "app") ? true : false, |
252 | | - pages: (0, _findpagesdir.findDir)(dir, "pages") ? true : false |
253 | | - }; |
254 | | - } |
255 | | - // ... |
256 | | - }" |
257 | | - `); |
258 | | - }); |
259 | | - |
260 | 170 | test("cache handler", () => { |
261 | 171 | expect(patchCode(nextServerCode, createCacheHandlerRule("manifest"))).toMatchInlineSnapshot(` |
262 | 172 | "class NextNodeServer extends _baseserver.default { |
|
0 commit comments