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 dev incompatible with vercel dev - ?import query param expects JS #3781

Closed
6 tasks done
t3dotgg opened this issue Jun 13, 2021 · 1 comment
Closed
6 tasks done

Comments

@t3dotgg
Copy link
Contributor

t3dotgg commented Jun 13, 2021

Describe the bug

I am unable to use vite with vercel dev CLI command that allows local hosting of vercel serverless functions.

I believe the core issue is that vercel dev eagerly returns source files when they exist, so static assets i.e. /src/image.svg?import will immediately resolve to /src/image.svg. The vite server seems to use the ?import query param to hijack the request and return a small JS file with the asset exported

I'm not sure if the best path is for vercel dev to honor the ?import query param and handoff to vite, or if there should be an option to resolve the static asset URLs directly in vite's dev environment.

Reproduction

  • Create a new Vite project with an SVG import
  • Push to vercel using vercel CLI (or github)
  • Run locally using vercel dev

I have a more detailed breakdown in a discussion on the vercel github:
vercel/vercel#6356

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 11.4
    CPU: (8) arm64 Apple M1
    Memory: 310.05 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v15.14.0/bin/yarn
    npm: 7.7.6 - ~/.nvm/versions/node/v15.14.0/bin/npm
    Watchman: 4.9.0 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 91.0.4472.101
    Firefox: 88.0
    Safari: 14.1.1

Used package manager: npm

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@Niputi
Copy link
Contributor

Niputi commented Oct 31, 2021

mentioned pull request was merged

@Niputi Niputi closed this as completed Oct 31, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants