Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐞] vite preview fails with vite template starters #4880

Closed
gioboa opened this issue Jul 27, 2023 · 4 comments · Fixed by vitejs/vite#15975
Closed

[🐞] vite preview fails with vite template starters #4880

gioboa opened this issue Jul 27, 2023 · 4 comments · Fixed by vitejs/vite#15975
Labels
TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply

Comments

@gioboa
Copy link
Member

gioboa commented Jul 27, 2023

Which component is affected?

Qwik Rollup / Vite plugin

Describe the bug

I created a Qwik Typescript app with
pnpm create vite
the preview script doesn't work

I have this error in the terminal
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
from this piece of code
Screenshot 2023-07-27 at 23 55 04

Reproduction

https://stackblitz.com/github/vitejs/vite/tree/main/packages/create-vite/template-qwik?file=README.md

Steps to reproduce

  • run pnpm create vite in the terminal
  • create a Qwik application JS or TS
  • run pnpm preview

System Info

System:
  OS: macOS 13.4.1
  CPU: (8) arm64 Apple M1
  Memory: 1.48 GB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 20.0.0 - ~/.nvm/versions/node/v20.0.0/bin/node
  Yarn: 1.22.10 - /opt/homebrew/bin/yarn
  npm: 9.6.4 - ~/.nvm/versions/node/v20.0.0/bin/npm
  pnpm: 8.6.5 - /opt/homebrew/bin/pnpm
Browsers:
  Chrome: 114.0.5735.248
  Safari: 16.5.2
npmPackages:
  @builder.io/qwik: ^1.2.6 => 1.2.6 
  vite: ^4.4.5 => 4.4.5

Additional Information

No response

@gioboa gioboa added TYPE: bug Something isn't working STATUS-1: needs triage New issue which needs to be triaged labels Jul 27, 2023
@CharlesEkkel
Copy link

CharlesEkkel commented Aug 12, 2023

Bumping to say this is still an issue - it looks like the ssrOutDir is null, which path.join doesn't like.

I'm not at all familiar with this repo, so all I can say is that when I create the qwik typescript app (no qwikcity) with vite, it looks like qwikViteOpts.csr (client-side-rendering, perhaps?) is true, which means that this code never runs:

if (!qwikViteOpts.csr) {
  clientOutDir = qwikPlugin.normalizePath(
    sys.path.resolve(
      opts.rootDir,
      qwikViteOpts.client?.outDir || CLIENT_OUT_DIR
    )
  );
  clientPublicOutDir = viteConfig.base
    ? path.join(clientOutDir, viteConfig.base)
    : clientOutDir;

  // ------ THIS BIT HERE ------
  ssrOutDir = qwikPlugin.normalizePath(
    sys.path.resolve(
      opts.rootDir,
      qwikViteOpts.ssr?.outDir || SSR_OUT_DIR
    )
  );

  clientDevInput =
    "string" === typeof qwikViteOpts.client?.devInput
      ? path.resolve(opts.rootDir, qwikViteOpts.client.devInput)
      : opts.srcDir
      ? path.resolve(opts.srcDir, CLIENT_DEV_INPUT)
      : path.resolve(opts.rootDir, "src", CLIENT_DEV_INPUT);
  clientDevInput = qwikPlugin.normalizePath(clientDevInput);
}

This is the only place that gives ssrOutDir a non-null value, and it's not getting run for me, presumably because these are SSR-only settings. Is there an entry.preview file for csr apps somewhere? I can't find in in my project.

@shairez shairez added WAITING FOR: team Waiting for one of the core team members to review and reply and removed STATUS-1: needs triage New issue which needs to be triaged labels Aug 13, 2023
@wmertens
Copy link
Member

Is this fixed?

@supfiger
Copy link

supfiger commented Feb 19, 2024

Any news?
Still have the same issue.

Demo here.

  1. Create a new terminal.
  2. Run npm run preview.

P.S: the code is taken from the official Vite + Qwik + TS template from the Vite docs.

@gioboa
Copy link
Member Author

gioboa commented Feb 20, 2024

@supfiger I created a PR for that in the Vite repo, you can use that workaround.
Change the qwikVite plugin to support this config
qwikVite({ csr: true, })
is complicated and time consuming I guess.

@gioboa gioboa closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug Something isn't working WAITING FOR: team Waiting for one of the core team members to review and reply
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants