diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 24e2098901..52ac299ec0 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -543,30 +543,20 @@ export default class Component { }); } - if (!/Import/.test(node.type)) { - const kind = node.type === 'VariableDeclaration' - ? node.kind - : node.type === 'ClassDeclaration' - ? 'class' - : node.type === 'FunctionDeclaration' - ? 'function' - : null; - - // sanity check - if (!kind) throw new Error(`Unknown declaration type ${node.type}`); - - this.add_var({ - name, - module: true, - hoistable: true, - writable: kind === 'var' || kind === 'let' - }); - } + this.add_var({ + name, + module: true, + hoistable: true, + writable: node.kind === 'var' || node.kind === 'let' + }); }); - globals.forEach(name => { + globals.forEach((node, name) => { if (name[0] === '$') { - // TODO should this be possible? + this.error(node, { + code: 'illegal-subscription', + message: `Cannot reference store value inside + +

{answer}

\ No newline at end of file diff --git a/test/runtime/samples/store-imported-module/_config.js b/test/runtime/samples/store-imported-module/_config.js new file mode 100644 index 0000000000..c2d471a329 --- /dev/null +++ b/test/runtime/samples/store-imported-module/_config.js @@ -0,0 +1,5 @@ +export default { + html: ` +

42

+ ` +}; \ No newline at end of file diff --git a/test/runtime/samples/store-imported-module/foo.js b/test/runtime/samples/store-imported-module/foo.js new file mode 100644 index 0000000000..340c3e6bd8 --- /dev/null +++ b/test/runtime/samples/store-imported-module/foo.js @@ -0,0 +1,3 @@ +import { writable } from '../../../../store.js'; + +export default writable(42); \ No newline at end of file diff --git a/test/runtime/samples/store-imported-module/main.svelte b/test/runtime/samples/store-imported-module/main.svelte new file mode 100644 index 0000000000..8710e3d1c6 --- /dev/null +++ b/test/runtime/samples/store-imported-module/main.svelte @@ -0,0 +1,9 @@ + + + + +

{answer}

\ No newline at end of file