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

fix: ?html-proxy with trailing = added by some servers #7093

Merged
merged 1 commit into from Feb 26, 2022
Merged

fix: ?html-proxy with trailing = added by some servers #7093

merged 1 commit into from Feb 26, 2022

Conversation

JuanM04
Copy link
Contributor

@JuanM04 JuanM04 commented Feb 25, 2022

Description

Similar to #3805, vercel dev replaces the urls that Vite uses. For example:

  • When using vite dev: /home/juanm04/dev/tests/test-vercel/src/pages/index.astro?html-proxy&index=0.js
  • When using vercel dev: /home/juanm04/dev/tests/test-vercel/src/pages/index.astro?html-proxy=&index=0.js

To prevent Vercel for breaking the dev enviroment, I changed the regex to accept both ?html-proxy and html-proxy=

Additional context

Fixes withastro/astro#2639

Error generated when using Astro (that uses Vite internally) and vercel dev:

[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
  Plugin: vite:import-analysis
  File: /home/juanm04/dev/tests/test-vercel/src/pages/index.astro?html-proxy=&index=0.js
  6  |                  <meta charset="utf-8" />
  7  |                  <meta name="viewport" content="width=device-width" />
  8  |                  <title>Astro</title>
     |                        ^
  9  |          </head>
  10 |          <body>
      at formatError (/home/juanm04/dev/tests/test-vercel/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38082:46)
      at TransformContext.error (/home/juanm04/dev/tests/test-vercel/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38078:19)
      at TransformContext.transform (/home/juanm04/dev/tests/test-vercel/node_modules/vite/dist/node/chunks/dep-971d9e33.js:69759:22)
      at async Object.transform (/home/juanm04/dev/tests/test-vercel/node_modules/vite/dist/node/chunks/dep-971d9e33.js:38318:30)
      at async doTransform (/home/juanm04/dev/tests/test-vercel/node_modules/vite/dist/node/chunks/dep-971d9e33.js:53014:29)

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Niputi Niputi added the p3-minor-bug An edge case that only affects very specific usage (priority) label Feb 25, 2022
@patak-dev patak-dev merged commit 5818ac9 into vitejs:main Feb 26, 2022
@JuanM04 JuanM04 deleted the fix-html-proxy branch February 26, 2022 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: vite:import-analysis error with vercel dev
4 participants