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

Astro’s dev server can't bundle when there is a space in a parent folder #5598

Closed
1 task
ffraenz opened this issue Dec 13, 2022 · 2 comments · Fixed by #5756
Closed
1 task

Astro’s dev server can't bundle when there is a space in a parent folder #5598

ffraenz opened this issue Dec 13, 2022 · 2 comments · Fixed by #5756
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@ffraenz
Copy link

ffraenz commented Dec 13, 2022

What version of astro are you using?

1.6.15

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

M1 macOS

Describe the Bug

I just started to compose a bug report without being able to reproduce the issue outside my local environment when I found the culprit: An innocent space character in one of the parent folder's name.

Steps to reproduce:

  1. Create a folder with a space in it, e.g. mkdir Project\ Name and change into it.

  2. Run npm create astro@latest and select 'an empty project', say yes to 'install npm dependencies', say no to 'initialize a new git repository', choose the 'Strict' TypeScript setup, and change into the newly created folder.

  3. Append the following lines to src/pages/index.astro:

    <script>
      console.log('Hello, World.')
    </script>
  4. Run npm run dev.

  5. Visit http://127.0.0.1:3000/ as advertised in the command line.

The following exception is thrown in the CLI, blocking the page from being rendered in the browser.

error   Could not import `/src/pages/index.astro?astro&type=script&index=0&lang.ts`.
  Hint:
    This is often caused by a typo in the import path. Please make sure the file exists.
  Stacktrace:
Error: failed to load module for ssr: /src/pages/index.astro?astro&type=script&index=0&lang.ts
    at instantiateModule (file:///Users/user/Projects/Project%20Name/majestic-mass/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:53281:15)

Note that building the project (running npm run build and then npm run preview) works just fine and yields the expected result. Thus, this seems to be related to esbuild only.

After some work I was able to reproduce the issue on Stackblitz, so the issue is no longer restricted to my local environment.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-q52vqt?file=project%20name/src/pages/index.astro

(I needed to manually replace project name by project%20name as even Stackblitz does not seem to work properly with spaces)

Participation

  • I am willing to submit a pull request for this issue.
@ffraenz ffraenz changed the title Astro’s development server can't bundle scripts when there is a space character in a parent folder Astro’s dev server can't bundle when there is a space in a parent folder Dec 13, 2022
@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Dec 19, 2022
@Princesseuh
Copy link
Member

Princesseuh commented Jan 4, 2023

Bumping the priority on this as we're getting many many reports in our support threads and this issue is getting a fair amount of thumb ups

@Princesseuh Princesseuh added - P4: important Violate documented behavior or significantly impacts performance (priority) and removed - P3: minor bug An edge case that only affects very specific usage (priority) labels Jan 4, 2023
@reksaandhika
Copy link

This also happens to me, when trying to update Astro version from 1.6.11 to latest version.
I'm using Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants