Skip to content

Conversation

@elliott-with-the-longest-name-on-github
Copy link
Contributor

This also gives us an avenue for supporting CSS stuff in the future.

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.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

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

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2025

⚠️ No Changeset found

Latest commit: 2f394b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

Playground

pnpm add https://pkg.pr.new/svelte@17338

@svelte-docs-bot
Copy link

body
body,
hashes: {
script: renderer.global.csp.script_hashes

Choose a reason for hiding this comment

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

as of now, this will only ever have one hash in it -- however, with streaming, it would be more...

Thinking ahead, with streaming, this should probably error if you try to access it prior to fully-reading tail, because it needs to be fully-populated before you send the response.

{
${prelude}
const body = `
{

Choose a reason for hiding this comment

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

I dedented and changed the formatting of this stuff because it was confusing in the browser... I could be convinced to sacrifice browser readability for code readability but I don't think the readability here is that bad, and it also technically reduces the byte count

Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should look into some sort of minification in production?

Copy link
Member

Choose a reason for hiding this comment

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

not sure I follow — this is what it looked like before:

image

this is what it looks like now:

image

surely it's more readable on main?

not too concerned about minification personally — I think the sacrifice of a dozen bytes is worth it for the readability

Choose a reason for hiding this comment

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

Yeah as far as the actual code output it's pretty much as minified as it can be without just nuking all of the whitespace

Do you have some weird set of settings on your browser? This is what it looks like for me in Chrome Devtools:

CleanShot 2025-12-11 at 18 04 53@2x

And with the old version it would be indented way off to the right

Copy link
Member

Choose a reason for hiding this comment

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

Ah, it's about whether you're viewing source or inspecting

Choose a reason for hiding this comment

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

Even when viewing source that seems wrong -- we don't send formatted HTML so it's like... indenting the tags but not the content? Weird

export async function sha256(data) {
text_encoder ??= new TextEncoder();
// @ts-ignore - we don't install node types in the prod build
crypto ??= (await import('node:crypto')).webcrypto;
Copy link
Member

Choose a reason for hiding this comment

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

come to think of it didn't we talk about skipping this and assuming that crypto is always available as a global, given that hydratable is behind the experimental.async flag? not worried about excluding people who want to use bleeding edge Svelte features but are still rocking Node 16 or whatever

Choose a reason for hiding this comment

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

The workaround to make it work with the Node 18 tests is just way more annoying than doing this for now 😆 given it won't even run with the above change I'm inclined to just leave it

Copy link
Member

Choose a reason for hiding this comment

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

Can't we just do globalThis.crypto ??= await import('node:crypto').webcrypto in the tests, before this module is imported?

Comment on lines +64 to +68
if (options.csp) {
csp =
'nonce' in options.csp
? { nonce: options.csp.nonce, hash: false }
: { hash: options.csp.hash, nonce: undefined };
Copy link
Member

Choose a reason for hiding this comment

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

can't we just use options.csp directly?

Choose a reason for hiding this comment

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

Not as currently typed -- the input value is a union. Maybe this is undesirable and we should just use an object with optional keys and JSDoc?

{
${prelude}
const body = `
{
Copy link
Member

Choose a reason for hiding this comment

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

not sure I follow — this is what it looked like before:

image

this is what it looks like now:

image

surely it's more readable on main?

not too concerned about minification personally — I think the sacrifice of a dozen bytes is worth it for the readability

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.

5 participants