shiply-cli 0.18.2 → 0.18.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/bundle.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cp, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
2
2
  import { tmpdir } from 'node:os';
3
- import { isAbsolute, join, relative } from 'node:path';
3
+ import { dirname, isAbsolute, join, relative } from 'node:path';
4
4
  import { build } from 'esbuild';
5
5
  const BUNDLE_COMPAT_DATE = '2025-05-05';
6
6
  /** Cloudflare runtime built-ins (`cloudflare:workers`, …) and `node:*` (provided
@@ -8,10 +8,12 @@ const BUNDLE_COMPAT_DATE = '2025-05-05';
8
8
  * else, including the framework server code that an adapter's `_worker.js`
9
9
  * imports from OUTSIDE its output dir, gets inlined. */
10
10
  const WORKER_EXTERNALS = ['cloudflare:*', 'node:*'];
11
- /** esbuild-bundle a worker entry into one self-contained ESM module. */
12
- async function bundleWorker(entryAbs) {
13
- const result = await build({
14
- entryPoints: [entryAbs],
11
+ /** esbuild-bundle a worker entry into one self-contained ESM module.
12
+ * When `wrapDefaultFetch` is set, the entry exports a NAMED `fetch` (Qwik's
13
+ * Pages adapter); we bundle a synthetic entry that re-exports it as the Workers
14
+ * `export default { fetch }` shape. */
15
+ async function bundleWorker(entryAbs, wrapDefaultFetch = false) {
16
+ const common = {
15
17
  bundle: true,
16
18
  format: 'esm',
17
19
  platform: 'neutral',
@@ -19,7 +21,17 @@ async function bundleWorker(entryAbs) {
19
21
  external: WORKER_EXTERNALS,
20
22
  write: false,
21
23
  logLevel: 'silent',
22
- });
24
+ };
25
+ const result = wrapDefaultFetch
26
+ ? await build({
27
+ ...common,
28
+ stdin: {
29
+ contents: `import { fetch } from ${JSON.stringify(entryAbs.split('\\').join('/'))}\nexport default { fetch }\n`,
30
+ resolveDir: dirname(entryAbs),
31
+ loader: 'js',
32
+ },
33
+ })
34
+ : await build({ ...common, entryPoints: [entryAbs] });
23
35
  return result.outputFiles[0].text;
24
36
  }
25
37
  /** Stage a temp publish dir: a single bundled worker under `.shiply/bundle/`,
@@ -35,7 +47,7 @@ export async function prepareBundle(sourceDir, ssr) {
35
47
  const bundleDir = join(out, '.shiply', 'bundle');
36
48
  await mkdir(bundleDir, { recursive: true });
37
49
  // Bundle the worker entry into one self-contained ESM module.
38
- await writeFile(join(bundleDir, 'index.js'), await bundleWorker(join(sourceDir, ssr.workerEntry)));
50
+ await writeFile(join(bundleDir, 'index.js'), await bundleWorker(join(sourceDir, ssr.workerEntry), ssr.wrapDefaultFetch));
39
51
  // Copy static assets, if any. The worker entry may live inside the assets dir
40
52
  // (SvelteKit, Astro) or in a sibling (Nitro's .output/server vs .output/public);
41
53
  // when inside, drop it so it isn't double-served.
@@ -40,6 +40,18 @@ export async function detectSsr(dir) {
40
40
  const nitro = await detectNitro(dir);
41
41
  if (nitro)
42
42
  return nitro;
43
+ // Qwik City — cloudflare-pages adapter: `server/entry.cloudflare-pages.js`
44
+ // (named `fetch` export) + `dist/` client assets. Entry is self-contained.
45
+ if ('@builder.io/qwik-city' in d &&
46
+ (await exists(join(dir, 'server/entry.cloudflare-pages.js')))) {
47
+ return {
48
+ framework: 'qwik',
49
+ workerEntry: 'server/entry.cloudflare-pages.js',
50
+ assetsDir: 'dist',
51
+ wrapDefaultFetch: true,
52
+ compatibilityFlags: NODE_COMPAT,
53
+ };
54
+ }
43
55
  // Generic Cloudflare Worker via a wrangler config (Hono, itty, raw fetch).
44
56
  return detectWrangler(dir);
45
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shiply-cli",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "description": "Publish static sites to shiply.now from the command line — instant web hosting for agents.",
5
5
  "license": "MIT",
6
6
  "type": "module",