@solcreek/adapter-creek 0.1.3 → 0.2.0
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.
- package/dist/build.js +326 -31
- package/dist/bundler.d.ts +3 -0
- package/dist/bundler.js +873 -27
- package/dist/cache-handler.d.ts +1 -1
- package/dist/cache-handler.js +3 -3
- package/dist/index.js +28 -5
- package/dist/manifest.d.ts +2 -9
- package/dist/manifest.js +7 -0
- package/dist/worker-entry.js +4045 -460
- package/package.json +3 -2
- package/src/shims/fs.js +57 -13
- package/src/shims/http.js +20 -1
package/dist/cache-handler.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "@solcreek/adapter-core/cache-handler";
|
|
1
|
+
export { default } from "@solcreek/adapter-next-core/cache-handler";
|
|
2
2
|
//# sourceMappingURL=cache-handler.d.ts.map
|
package/dist/cache-handler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Re-export the shared in-memory Next.js ISR cache handler from
|
|
2
|
-
// @solcreek/adapter-core. The implementation
|
|
3
|
-
// adapter-creek and adapter-creekd
|
|
2
|
+
// @solcreek/adapter-next-core. The implementation lives there so
|
|
3
|
+
// both adapter-creek and adapter-creekd share a single tested copy.
|
|
4
4
|
//
|
|
5
5
|
// This file exists for backwards compatibility: users who set
|
|
6
6
|
// `cacheHandler: require.resolve("@solcreek/adapter-creek/cache-handler")`
|
|
7
7
|
// in their next.config continue to work without changes. New users
|
|
8
8
|
// can wire either path; both resolve to the same module at runtime.
|
|
9
|
-
export { default } from "@solcreek/adapter-core/cache-handler";
|
|
9
|
+
export { default } from "@solcreek/adapter-next-core/cache-handler";
|
|
10
10
|
//# sourceMappingURL=cache-handler.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
import { applyBaseModifyConfig } from "@solcreek/adapter-core";
|
|
3
|
+
import { copyFileSync, existsSync } from "node:fs";
|
|
4
|
+
import { applyBaseModifyConfig } from "@solcreek/adapter-next-core";
|
|
5
5
|
import { handleBuild } from "./build.js";
|
|
6
|
-
// Dev-fallback path to the cache handler shipped by @solcreek/adapter-core.
|
|
6
|
+
// Dev-fallback path to the cache handler shipped by @solcreek/adapter-next-core.
|
|
7
7
|
// applyBaseModifyConfig prefers the node_modules-installed copy when one
|
|
8
8
|
// exists (the production path); this resolves the package's own bundled
|
|
9
9
|
// copy as a last resort for the rare case where the adapter is used
|
|
10
10
|
// without `npm install`ing it.
|
|
11
|
-
const coreEntryUrl = new URL("../node_modules/@solcreek/adapter-core/dist/cache-handler.js", import.meta.url);
|
|
11
|
+
const coreEntryUrl = new URL("../node_modules/@solcreek/adapter-next-core/dist/cache-handler.js", import.meta.url);
|
|
12
12
|
const fallbackCacheHandlerPath = existsSync(fileURLToPath(coreEntryUrl))
|
|
13
13
|
? fileURLToPath(coreEntryUrl)
|
|
14
|
-
: path.join(process.cwd(), "node_modules", "@solcreek", "adapter-core", "dist", "cache-handler.js");
|
|
14
|
+
: path.join(process.cwd(), "node_modules", "@solcreek", "adapter-next-core", "dist", "cache-handler.js");
|
|
15
|
+
function mirrorCacheHandlerIntoProject(cacheHandlerPath) {
|
|
16
|
+
if (!existsSync(cacheHandlerPath))
|
|
17
|
+
return cacheHandlerPath;
|
|
18
|
+
const localPath = path.join(process.cwd(), ".solcreek-cache-handler.mjs");
|
|
19
|
+
if (path.resolve(cacheHandlerPath) === path.resolve(localPath))
|
|
20
|
+
return localPath;
|
|
21
|
+
try {
|
|
22
|
+
copyFileSync(cacheHandlerPath, localPath);
|
|
23
|
+
return localPath;
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
console.warn(` [Creek Adapter] Failed to mirror cache-handler into project (${err instanceof Error ? err.message : String(err)}); falling back to ${cacheHandlerPath}`);
|
|
27
|
+
return cacheHandlerPath;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
15
30
|
const adapter = {
|
|
16
31
|
name: "adapter-creek",
|
|
17
32
|
modifyConfig(config, ctx) {
|
|
@@ -26,8 +41,16 @@ const adapter = {
|
|
|
26
41
|
// for other phases, so guarding here matches its behaviour.
|
|
27
42
|
if (ctx.phase !== "phase-production-build")
|
|
28
43
|
return baseConfig;
|
|
44
|
+
const cacheHandlerPath = typeof baseConfig.cacheHandler === "string"
|
|
45
|
+
? mirrorCacheHandlerIntoProject(baseConfig.cacheHandler)
|
|
46
|
+
: mirrorCacheHandlerIntoProject(fallbackCacheHandlerPath);
|
|
29
47
|
return {
|
|
30
48
|
...baseConfig,
|
|
49
|
+
// Next may dynamically import this cache handler on error/404 render
|
|
50
|
+
// paths. Keep it as a project-local sentinel path instead of a pnpm
|
|
51
|
+
// node_modules realpath; the Workers bundler redirects that sentinel
|
|
52
|
+
// to the inline CreekCacheHandler.
|
|
53
|
+
cacheHandler: cacheHandlerPath,
|
|
31
54
|
// Disable memory cache — CF Workers doesn't have persistent fs.
|
|
32
55
|
// The runtime cache handler is inlined in the worker entry (CreekCacheHandler).
|
|
33
56
|
cacheMaxMemorySize: 0,
|
package/dist/manifest.d.ts
CHANGED
|
@@ -4,15 +4,8 @@
|
|
|
4
4
|
* Written to .creek/adapter-output/manifest.json after build.
|
|
5
5
|
* Creek CLI reads this to know how to upload and deploy.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
version: 1;
|
|
10
|
-
/** Next.js build ID */
|
|
11
|
-
buildId: string;
|
|
12
|
-
/** Next.js version used */
|
|
13
|
-
nextVersion: string;
|
|
14
|
-
/** Framework identifier */
|
|
15
|
-
framework: "nextjs";
|
|
7
|
+
import type { DeployManifestBase } from "@solcreek/adapter-core";
|
|
8
|
+
export interface DeployManifest extends DeployManifestBase {
|
|
16
9
|
/** Main worker entry file name (relative to server/) */
|
|
17
10
|
entrypoint: string;
|
|
18
11
|
/** All files in server/ directory */
|
package/dist/manifest.js
CHANGED
|
@@ -6,12 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import * as fs from "node:fs/promises";
|
|
8
8
|
import * as path from "node:path";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const adapterPackage = require("../package.json");
|
|
9
12
|
export async function writeManifest(outputDir, opts) {
|
|
10
13
|
const manifest = {
|
|
11
14
|
version: 1,
|
|
12
15
|
buildId: opts.buildId,
|
|
13
16
|
nextVersion: opts.nextVersion,
|
|
14
17
|
framework: "nextjs",
|
|
18
|
+
adapter: {
|
|
19
|
+
name: adapterPackage.name ?? "@solcreek/adapter-creek",
|
|
20
|
+
version: adapterPackage.version ?? "0.0.0",
|
|
21
|
+
},
|
|
15
22
|
entrypoint: opts.entrypoint,
|
|
16
23
|
serverFiles: opts.serverFiles,
|
|
17
24
|
assetDir: "assets",
|