QwikCommunity / pwa

Turn your Qwik Application into an offline compatible PWA
https://pwa-a3b.pages.dev/
89 stars 6 forks source link

Can't build using Vercel adapter #13

Closed Loshido closed 6 months ago

Loshido commented 6 months ago

i use @qwikdev/pwa & the vercel adapter (for building) +the default setup in pwa/README.md

pnpm run build does (process:12632): GLib-GObject-CRITICAL **: 21:35:04.401: invalid unclassed type '(NULL)' in class cast to '(NULL)' as warning and exit with :

error during build:
Error: ENOENT: no such file or directory, open '{rep_path}\dist\service-worker.js'
    at async open (node:internal/fs/promises:633:25)
    at async Object.readFile (node:internal/fs/promises:1242:14)
    at async Object.handler (file:///{rep_path}/node_modules/.pnpm/@qwikdev+pwa@0.0.4/node_modules/@qwikdev/pwa/lib/index.qwik.js:118:24)
    at async PluginDriver.hookParallel (file:///{rep_path}/node_modules/.pnpm/rollup@4.13.0/node_modules/rollup/dist/es/shared/node-entry.js:19485:17)
    at async Object.close (file:///{rep_path}/node_modules/.pnpm/rollup@4.13.0/node_modules/rollup/dist/es/shared/node-entry.js:20418:13)
    at async build (file:///{rep_path}/node_modules/.pnpm/vite@5.2.6_@types+node@20.11.30/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:67290:13)
    at async CAC.<anonymous> (file:///{rep_path}/node_modules/.pnpm/vite@5.2.6_@types+node@20.11.30/node_modules/vite/dist/node/cli.js:842:9)
 ELIFECYCLE  Command failed with exit code 1.

the issue is that there is no dist folder in the basepath (no /dist) but in /.vercel/output/static i already spotted the variable that point to the wrong path in src/context.ts:67 (from pwa rep)

  // [...]
  ctx.clientOutDir = ctx.qwikPlugin!.api.getClientOutDir()! // there, the path goes wrong
  // console.log(ctx.clientOutDir) => {rep_path}/dist
  ctx.basePathRelDir = ctx
    .qwikCityPlugin!.api.getBasePathname()
    .replace(/^\/|\/$/, "");
  ctx.clientOutBaseDir = join(ctx.clientOutDir, ctx.basePathRelDir);
  ctx.swClientDistPath = join(ctx.clientOutBaseDir, "service-worker.js");
  // [...]
Aslemammad commented 6 months ago

Thank you so much for the valuable investigation!