@solcreek/adapter-creek 0.2.1 → 0.2.3

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 CHANGED
@@ -340,8 +340,19 @@ export async function handleBuild(ctx) {
340
340
  // exposes these per-output as `output.assets` (the result of file tracing).
341
341
  // We embed them in __USER_FILES so the fs shim can serve them in workerd.
342
342
  const userFiles = await collectUserFiles(ctx.outputs, ctx.distDir, ctx.projectDir);
343
- if (Object.keys(userFiles).length > 0) {
344
- console.log(` [Creek Adapter] ${Object.keys(userFiles).length} user data files embedded`);
343
+ const userFilePaths = Object.keys(userFiles).sort();
344
+ if (userFilePaths.length > 0) {
345
+ // List the paths: these are non-code files your routes read at runtime
346
+ // (file-traced from your code), embedded so the workerd fs shim can serve
347
+ // them. Listing them lets you spot anything unexpected (e.g. a stray .env).
348
+ console.log(` [Creek Adapter] ${userFilePaths.length} user data files embedded (files read at runtime via fs):`);
349
+ const SHOWN = 30;
350
+ for (const p of userFilePaths.slice(0, SHOWN)) {
351
+ console.log(` - ${p}`);
352
+ }
353
+ if (userFilePaths.length > SHOWN) {
354
+ console.log(` ... and ${userFilePaths.length - SHOWN} more`);
355
+ }
345
356
  }
346
357
  // Step 4: Generate worker entry
347
358
  console.log(" [Creek Adapter] Scanning external modules...");
package/dist/bundler.d.ts CHANGED
@@ -7,6 +7,21 @@
7
7
  * This works with both webpack and Turbopack output — wrangler handles
8
8
  * the custom chunk format that plain esbuild cannot follow.
9
9
  */
10
+ /**
11
+ * Resolve wrangler's CLI entry script through Node module resolution.
12
+ *
13
+ * Never guess `<adapterDir>/node_modules/.bin/wrangler`: npm hoists
14
+ * wrangler to the top of the install tree (under the Creek CLI's lazy
15
+ * install that's `.creek/node_modules/.bin`), so the nested path only
16
+ * exists when hoisting is defeated by a version conflict. Resolving
17
+ * `wrangler/package.json` and reading its `bin` field finds the real
18
+ * entry under npm hoisting, pnpm's virtual store, and link installs
19
+ * alike — and running it with process.execPath sidesteps `.bin` shell
20
+ * shims entirely (which also don't exist as POSIX scripts on Windows).
21
+ *
22
+ * Exported for tests.
23
+ */
24
+ export declare function resolveWranglerEntry(requireFn: Pick<NodeRequire, "resolve">): Promise<string>;
10
25
  export interface BundleOptions {
11
26
  workerSource: string;
12
27
  outputDir: string;
package/dist/bundler.js CHANGED
@@ -9,8 +9,32 @@
9
9
  */
10
10
  import * as fs from "node:fs/promises";
11
11
  import * as path from "node:path";
12
- import { execSync } from "node:child_process";
12
+ import { execFileSync } from "node:child_process";
13
13
  import { builtinModules, createRequire } from "node:module";
14
+ import { fileURLToPath } from "node:url";
15
+ /**
16
+ * Resolve wrangler's CLI entry script through Node module resolution.
17
+ *
18
+ * Never guess `<adapterDir>/node_modules/.bin/wrangler`: npm hoists
19
+ * wrangler to the top of the install tree (under the Creek CLI's lazy
20
+ * install that's `.creek/node_modules/.bin`), so the nested path only
21
+ * exists when hoisting is defeated by a version conflict. Resolving
22
+ * `wrangler/package.json` and reading its `bin` field finds the real
23
+ * entry under npm hoisting, pnpm's virtual store, and link installs
24
+ * alike — and running it with process.execPath sidesteps `.bin` shell
25
+ * shims entirely (which also don't exist as POSIX scripts on Windows).
26
+ *
27
+ * Exported for tests.
28
+ */
29
+ export async function resolveWranglerEntry(requireFn) {
30
+ const pkgPath = requireFn.resolve("wrangler/package.json");
31
+ const pkg = JSON.parse(await fs.readFile(pkgPath, "utf-8"));
32
+ const binRel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.wrangler;
33
+ if (!binRel) {
34
+ throw new Error(`wrangler package.json at ${pkgPath} has no usable bin field`);
35
+ }
36
+ return path.join(path.dirname(pkgPath), binRel);
37
+ }
14
38
  /**
15
39
  * Patch Turbopack runtime to inline chunk loading.
16
40
  *
@@ -645,8 +669,9 @@ export async function bundleForWorkers(opts) {
645
669
  const destPath = path.join(opts.outputDir, destName);
646
670
  await fs.copyFile(absPath, destPath);
647
671
  }
648
- // Resolve adapter paths
649
- const adapterDir = path.dirname(path.dirname(new URL(import.meta.url).pathname));
672
+ // Resolve adapter paths. fileURLToPath, not URL#pathname — the latter
673
+ // yields "/C:/..." on Windows, which every alias below would inherit.
674
+ const adapterDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
650
675
  // Generate wrangler config for the bundle step
651
676
  const wranglerConfig = {
652
677
  name: "creek-adapter-build",
@@ -778,10 +803,9 @@ export async function bundleForWorkers(opts) {
778
803
  }
779
804
  }
780
805
  const bundleDir = path.join(opts.outputDir, "__bundle");
781
- // Resolve wrangler binary from the adapter's own node_modules
782
- const wranglerBin = path.join(adapterDir, "node_modules", ".bin", "wrangler");
806
+ const wranglerEntry = await resolveWranglerEntry(adapterRequire);
783
807
  try {
784
- execSync(`"${wranglerBin}" deploy --dry-run --outdir "${bundleDir}" --config "${configPath}"`, {
808
+ execFileSync(process.execPath, [wranglerEntry, "deploy", "--dry-run", "--outdir", bundleDir, "--config", configPath], {
785
809
  cwd: path.dirname(opts.distDir),
786
810
  stdio: "pipe",
787
811
  env: process.env,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solcreek/adapter-creek",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Next.js deployment adapter for Creek (Cloudflare Workers)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",