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

feat: add rootDir option and set __svelte_meta.file like in svelte4 #11627

Merged
merged 11 commits into from
May 16, 2024

Conversation

dominikg
Copy link
Member

@dominikg dominikg commented May 14, 2024

lots of tests fail because there are still ... in various expects and i havn't found a way to automatically update them.

tbd: not defaulting to process.cwd would make svelte more independant, but means bundler plugins will have to set it to avoid issues with path leaks

it gets complicated with error handling (stacktraces) and sourcemap merging that might need the absolute path still.
In general we should try to use the stripped filename everywhere in output, not just in dev mode like in this PR.

This is basically the minimum way i think it could be added, feel free to completely refactor/change/close this, but for svelte-inspector to work we need

__svelte_meta.file to be src/foo/Bar.svelte and not .../foo/Bar.svelte

Svelte 5 rewrite

Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (main).

If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is svelte-4 and not main.

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

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented May 14, 2024

🦋 Changeset detected

Latest commit: f767eb5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

lots of tests fail because there are still ... in various expects and i havn't found a way to automatically update them

working on this

.changeset/khaki-mails-scream.md Outdated Show resolved Hide resolved
.changeset/kind-doors-grin.md Outdated Show resolved Hide resolved
@Rich-Harris
Copy link
Member

I think this is ready to go, though there are some Windows failures that I don't really understand — forward slashes versus backward slashes — and will leave to someone else

@Rich-Harris
Copy link
Member

oh and I guess we should summon @Conduitry in case he wants to veto the fallback to process.cwd()

@dominikg
Copy link
Member Author

I think this is ready to go, though there are some Windows failures that I don't really understand — forward slashes versus backward slashes — and will leave to someone else

looks nice now. I did wonder about using state for it as well but cheaped out 👍

the windows path separator issue is really unfortunate. Do we want to go the lengths to normalize \ to / to avoid it?
To make only windows users pay the price we'd have to spy on process.platfrom too which adds yet another quirk.

@Rich-Harris
Copy link
Member

I mean I don't understand how and where it's happening. surely filename and rootDir both use the same separators?

@dummdidumm
Copy link
Member

dummdidumm commented May 15, 2024

Fixed it by normalizing slashes. The slashes were a mix of \ and / on windows because of this code in the test suite - I could've fixed that there instead, but I figured that such a mixup could happen in userland, too, so it's more robust to normalize slashes instead.

@Rich-Harris Rich-Harris marked this pull request as ready for review May 16, 2024 01:39
@Rich-Harris Rich-Harris merged commit dc9b0d0 into main May 16, 2024
8 checks passed
@Rich-Harris Rich-Harris deleted the feat/rootdir branch May 16, 2024 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants