Skip to content

Svelte 5#1078

Open
benjaminknox wants to merge 11 commits intobrave:mainfrom
benjaminknox:bpk/svelte5
Open

Svelte 5#1078
benjaminknox wants to merge 11 commits intobrave:mainfrom
benjaminknox:bpk/svelte5

Conversation

@benjaminknox
Copy link
Copy Markdown
Contributor

@benjaminknox benjaminknox commented May 7, 2025

What?

Svelte5 upgrade branch, branched from #890

Issues:

@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 7, 2025

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
High CVE: npm flatted vulnerable to unbounded recursion DoS in parse() revive phase

CVE: GHSA-25h7-pfq9-p65f flatted vulnerable to unbounded recursion DoS in parse() revive phase (HIGH)

Affected versions: < 3.4.0

Patched version: 3.4.0

From: package-lock.jsonnpm/@storybook/svelte-vite@8.6.14npm/@storybook/svelte@8.6.14npm/flatted@3.3.3

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/flatted@3.3.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: npm minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions

CVE: GHSA-23c5-xmqv-rm74 minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions (HIGH)

Affected versions: >= 10.0.0 < 10.2.3; >= 9.0.0 < 9.0.7; >= 8.0.0 < 8.0.6; >= 7.0.0 < 7.4.8; >= 6.0.0 < 6.2.2; >= 5.0.0 < 5.1.8; >= 4.0.0 < 4.2.5; < 3.1.4

Patched version: 3.1.4

From: package-lock.jsonnpm/@storybook/svelte-vite@8.6.14npm/@storybook/svelte@8.6.14npm/ts-jest@29.4.6npm/minimatch@3.1.2

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/minimatch@3.1.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: npm minimatch has a ReDoS via repeated wildcards with non-matching literal in pattern

CVE: GHSA-3ppc-4f35-3m26 minimatch has a ReDoS via repeated wildcards with non-matching literal in pattern (HIGH)

Affected versions: >= 10.0.0 < 10.2.1; >= 9.0.0 < 9.0.6; >= 8.0.0 < 8.0.5; >= 7.0.0 < 7.4.7; >= 6.0.0 < 6.2.1; >= 5.0.0 < 5.1.7; >= 4.0.0 < 4.2.4; < 3.1.3

Patched version: 3.1.3

From: package-lock.jsonnpm/@storybook/svelte-vite@8.6.14npm/@storybook/svelte@8.6.14npm/ts-jest@29.4.6npm/minimatch@3.1.2

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/minimatch@3.1.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
High CVE: npm minimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments

CVE: GHSA-7r86-cg39-jmmj minimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments (HIGH)

Affected versions: >= 10.0.0 < 10.2.3; >= 9.0.0 < 9.0.7; >= 8.0.0 < 8.0.6; >= 7.0.0 < 7.4.8; >= 6.0.0 < 6.2.2; >= 5.0.0 < 5.1.8; >= 4.0.0 < 4.2.5; < 3.1.3

Patched version: 3.1.3

From: package-lock.jsonnpm/@storybook/svelte-vite@8.6.14npm/@storybook/svelte@8.6.14npm/ts-jest@29.4.6npm/minimatch@3.1.2

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/minimatch@3.1.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Medium CVE: npm ajv has ReDoS when using `$data` option

CVE: GHSA-2g4f-4pwh-qvx6 ajv has ReDoS when using $data option (MODERATE)

Affected versions: >= 7.0.0-alpha.0 < 8.18.0; < 6.14.0

Patched version: 8.18.0

From: package-lock.jsonnpm/style-loader@3.3.4npm/ajv@8.17.1

ℹ Read more on: This package | This alert | What is a medium CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known medium severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/ajv@8.17.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Low CVE: npm webpack buildHttp HttpUriPlugin allowedUris bypass via HTTP redirects → SSRF + cache persistence

CVE: GHSA-38r7-794h-5758 webpack buildHttp HttpUriPlugin allowedUris bypass via HTTP redirects → SSRF + cache persistence (LOW)

Affected versions: >= 5.49.0 < 5.104.0

Patched version: 5.104.0

From: package-lock.jsonnpm/style-loader@3.3.4npm/webpack@5.99.8

ℹ Read more on: This package | This alert | What is a mild CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known low severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/webpack@5.99.8. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Low CVE: npm webpack buildHttp: allowedUris allow-list bypass via URL userinfo (@) leading to build-time SSRF behavior

CVE: GHSA-8fgc-7cc6-rx7x webpack buildHttp: allowedUris allow-list bypass via URL userinfo (@) leading to build-time SSRF behavior (LOW)

Affected versions: >= 5.49.0 < 5.104.1

Patched version: 5.104.1

From: package-lock.jsonnpm/style-loader@3.3.4npm/webpack@5.99.8

ℹ Read more on: This package | This alert | What is a mild CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known low severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/webpack@5.99.8. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@benjaminknox benjaminknox force-pushed the bpk/svelte5 branch 6 times, most recently from afc9b0d to 565e004 Compare May 7, 2025 21:13
@benjaminknox benjaminknox changed the title Svelte 5 WIP: Svelte 5 May 7, 2025
Comment thread svelte.config.js
Comment thread src/tokens/transformation/tailwind/extractComponentStyles.js
Copy link
Copy Markdown
Collaborator

@AlanBreck AlanBreck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really good! I have several "why" questions below, none of which are meant to imply "we shouldn't be doing this".

Comment on lines +30 to +38
type ButtonHTMLAttributes = Pick<
SvelteHTMLElements['button'],
'id' | 'class' | 'style' | 'disabled' | 'type' | 'aria-label'
>;

type LinkHTMLAttributes = Pick<
SvelteHTMLElements['a'],
'id' | 'class' | 'style' | 'target' | 'rel' | 'aria-label'
>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary?

Copy link
Copy Markdown
Contributor Author

@benjaminknox benjaminknox Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly for the react bindings IIRC, the type was too complex and the compiler couldn't figure it out, details are here: benjaminknox#4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 This may also be an issue with some other components, so I'm spending a bit of time importing each to the example react app.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... ok. It would be ideal not to have to do this since we theoretically would like to expose all of the available button attributes via props spreading, and wouldn't want TS to complain about legitimately used attributes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, just for reference the types are here: svelte/elements

In svelte 5 it looks like there's more comprehensive types than 4 and combining them here is too much for the compiler, but we may be able to find another way to get the type we want?

I'll be working on this with this draft pr: benjaminknox#6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that's a good solution!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... looks like we may be coming back full circle to your initial solution of providing a defined list of allowed attributes. 😅 Despite working in the examples, it still triggers the same error in brave-core.

I did a quick audit of some of my projects, and here are some of the attributes that I'd ideally like to support for Button:

Global

  • id
  • style
  • aria-*
  • data-*

Anchor:

  • href
  • target
  • rel

Button:

  • type
  • for
  • form

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I played around a bit more and just keep bumping into more and more problems 😢

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more properties that'd be helpful:

  1. name
  2. title
  3. autofocus
  4. type (for button)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also hitting issues with navigation item in brave-core, so maybe it need the same treatment

Comment thread .storybook/main.ts
Comment thread src/components/navigation/navigation.stories.svelte
Comment thread src/types/attributes.ts
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file necessary?

Copy link
Copy Markdown
Contributor Author

@benjaminknox benjaminknox Mar 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for code reuse and because of a svelte 5 type change in the HTMLAttributes type exported by svelte/elements.

This type gets used in:

src/components/buttonMenu/buttonMenu.svelte
src/components/dropdown/dropdown.svelte
src/components/menu/menu.svelte

Svelte 5 added a children prop to HTMLAttributes<T> typed as a Snippet, but these components need children as raw DOM content, so using it caused a type conflict after I upgraded.

@benjaminknox benjaminknox changed the title WIP: Svelte 5 Svelte 5 Mar 19, 2026
* [Collapse]: Add :global() style for details open arrow

* [Dialog]: Add :global() style for actions slot

* [Alert]: Add :global() style for active selector

* [FormItem]: Add :global() style to for :focus-visible wildcard

* fix review feedback

* upgrade to latest minor version of svelte5

* pin svelte version

* [FormItem]: rescope :global around css rules
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.

4 participants