fix hoisting of imported, mutated stores (#5022)

pull/5058/head
Bassam Ismail 4 years ago committed by GitHub
parent 92578706b0
commit 0e2bc352df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}
}
}
}

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

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

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