Fix #6606: warning on reactive use of module const

This generated a warning:

    <script context="module">
      export const foo = 123;
    </script>

    <script>
      $: console.log(foo);
    </script>

while this did not:

    <script>
      const foo = 123;
      $: console.log(foo);
    </script>

We don't need a warning to tell us that we will not be reactive to a
variable that isn't going to change anyway; regardless of whether or not
it's in a module.

(Maybe there should be a 'no reactive variable used' warning, but this
also happens in cases where other mutable variables are used; such as a
shared const formatter function, formatting a prop.)
pull/6607/head
Oliver Ford 5 years ago
parent 4b3151408e
commit a0534a17c7
No known key found for this signature in database
GPG Key ID: 15CCFACF010F70D2

@ -1310,7 +1310,7 @@ export default class Component {
if (variable) {
variable.is_reactive_dependency = true;
if (variable.module) {
if (variable.module && variable.writable) {
should_add_as_dependency = false;
module_dependencies.add(name);
}

Loading…
Cancel
Save