0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

fix hoisting of imported, mutated stores (#5022)

This commit is contained in:
Bassam Ismail 2020-06-24 01:47:42 +05:30 committed by GitHub
parent 92578706b0
commit 0e2bc352df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -1152,7 +1152,9 @@ export default class Component {
for (const specifier of specifiers) {
const variable = var_lookup.get(specifier.local.name);
if (!variable.mutated) variable.hoistable = true;
if (!variable.mutated || variable.subscribable) {
variable.hoistable = true;
}
}
}
}

View File

@ -0,0 +1,7 @@
export default {
compileOptions: { dev: true }, // tests `@validate_store` code generation
html: `
<p>42</p>
`
};

View File

@ -0,0 +1,3 @@
import { writable } from '../../../../store';
export default writable(42);

View File

@ -0,0 +1,7 @@
<script>
import foo from './foo.js';
foo.bar = 'baz';
const answer = $foo;
</script>
<p>{answer}</p>