-
Notifications
You must be signed in to change notification settings - Fork 257
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
Feature request: Svelte 5 support #962
Comments
Hi @alex-knyaz thanks for your interest to getting dependency-cruiser to work with svelte 5. A while ago I attempted an upgrade as part of a 3rd party dependency bump of a bunch of dependencies but aborted as it took more than the time I had for doing an upgrade. The svelte compile function got a different profile (calling it as is makes that it throws) and the generated code looks quite different (so my integration tests threw a hissy fit as well). So it's definitely some effort to make it work. Slightly better rested with more time + prior knowledge I attempted again just now. It seems it's working now. I'll see if I can publish a beta for you to check tonight.
That will indeed work in many cases, but not why you'd think. If dependency-cruiser doesn't find a suitable svelte compiler it'll treat the .svelte file as if it's plain javascript. That will error out and fall back to the error tolerant acorn-loose parser, that often will be able to get a remarkable amount of information out of svelte (, vue, typescript, tsx, typo ridden javascript, ...) files. The results you get as current behavior are very likely because of this fallback for the fallback scenario... |
@alex-knyaz I've published a version of dependency-cruiser with svelte 5 support to npm with the beta tag: [email protected] Let me know if it works for you. |
Thank you for the quick response and implementation! The beta works perfectly. Really appreciate the detailed explanation and the swift response. Dependency-cruiser is amazing. Thanks for maintaining it! |
## Description - updates the svelte _compile_ call to include an empty object as a 2nd parameter. This is required for svelte 5 and svelte 4 seems to ignore it so it seems we're in luck and don't need funky branching. - Adjusts the supported compiler range for svelte - Adjusts the integration & unit tests to expect svelte 5 output ## Motivation and Context Svelte 5 seems to have become stable and in their release notes they encourage users to upgrade. Also fixes #962 ## How Has This Been Tested? - [x] green ci - [x] adjusted automated non-regression tests ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation only change - [ ] Refactor (non-breaking change which fixes an issue without changing functionality) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
@alex-knyaz I've just released [email protected] onto npm which contains (a.o.) the linked pull request. Thanks again for raising this issue! |
Context
Dependency-cruiser doesn't officially support Svelte 5 while analyzing project dependencies.
Svelte 4 support was implemented in #948
Expected Behavior
Parse and analyze Svelte 5 files properly.
Current Behavior
No official Svelte 5 support, but adding
.svelte
tooptions.extensions
array in.dependency-cruiser.cjs
seems to make it work anyway?Possible Solution
Extend current Svelte 4 handling to support Svelte 5. Should not be difficult if it just works with workaround.
Considered alternatives
Using .svelte extension workaround, but proper support would be better.
The text was updated successfully, but these errors were encountered: