Skip to content

Conversation

@Rich-Harris
Copy link
Member

There's a bug in Vite's SSR module transformation — this code...

constructor(serialized: string | undefined) {
if (serialized) {
const [index, guesses, answers] = serialized.split('-');
this.index = +index;
this.guesses = guesses ? guesses.split(' ') : [];
this.answers = answers ? answers.split(' ') : [];
} else {
this.index = Math.floor(Math.random() * answers.length);
this.guesses = ['', '', '', '', '', ''];
this.answers = /** @type {string[]} */ [] /***/;
}
this.answer = answers[this.index];
}

...breaks because the const [index, guesses, answers] line causes it to mistakenly think that the answers import is shadowed, when it's actually in a different scope. I don't have time to create a repro/issue on Vite right now, but fixing the demo app is a high priority.

Please don't delete this checklist! 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

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

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Sep 29, 2022

🦋 Changeset detected

Latest commit: 46399ad

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

This PR includes changesets to release 1 package
Name Type
create-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

@dummdidumm dummdidumm merged commit 4f603ad into master Sep 29, 2022
@dummdidumm dummdidumm deleted the work-around-vite-bug branch September 29, 2022 17:31
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.

3 participants