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: handle null/empty sources in source maps #3074

Merged
merged 4 commits into from
Apr 24, 2021

Conversation

danielroe
Copy link
Contributor

@danielroe danielroe commented Apr 20, 2021

UPDATE: issue was produced by @nuxtjs/composition-api-plugin incorrectly producing a sourcemap. Will address in there but it might be worth still handling an empty source.


Description

This PR updates the sourcemap support in vite to handle empty strings.

The issue I'm facing is the following error:

[vite] Internal server error: EISDIR: illegal operation on a directory, read

It is produced by attempting to read a directory path: sourceRoot + an empty sourcePath (= '').

Alternative solutions

We could just filter sources first for non-empty strings.

What is the purpose of this pull request?

  • Bug fix

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.

@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Apr 21, 2021
@danielroe danielroe changed the title fix: respect vue2 sourcemap format fix: handle null sources Apr 21, 2021
@danielroe danielroe changed the title fix: handle null sources fix: handle null/empty sources Apr 21, 2021
@patak-dev
Copy link
Member

I think it may be better to filter sources first as you proposed as an alternative, the file path in map.file may not be related to a source, no?

patak-dev
patak-dev previously approved these changes Apr 24, 2021
@patak-dev patak-dev changed the title fix: handle null/empty sources fix: handle null/empty sources in source maps Apr 24, 2021
@patak-dev patak-dev merged commit 3e9f128 into vitejs:main Apr 24, 2021
@patak-dev
Copy link
Member

Thanks for the PR @danielroe. I was thinking, do you believe it would be useful to log a warning in these cases? Since the original error helped you found an issue in nuxt source maps, that may have been harder to see if it fails silently.

@danielroe danielroe deleted the fix/sourcemap-format branch April 24, 2021 19:29
@danielroe
Copy link
Contributor Author

@patak-js Yes, the error message could be something like Processing a sourcemap with no source filename. I imagine this would mostly be a library/dependency issue and hopefully would be caught in development of the library. Otherwise it might be a bit difficult to debug for a user.

TobiasMelen pushed a commit to TobiasMelen/vite that referenced this pull request May 3, 2021
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.

None yet

3 participants