Kyriediculous
Kyriediculous

Reputation: 119

ES6 import / export not working with variables? Meteor

Why does this work

export var Tasks = new Mongo.Collection('tasks');

But this doesn't?

var Tasks = new Mongo.Collection('tasks');
export Tasks

Upvotes: 1

Views: 844

Answers (3)

Aboobakkar P S
Aboobakkar P S

Reputation: 806

The Best Practice for use export const Tasks = new Meteor.Collection('tasks');

Upvotes: 0

Kilizo
Kilizo

Reputation: 3382

Try the following syntax:

var Tasks = new Mongo.Collection('tasks');
export { Tasks }

I'd also recommend using camelCase for variable names.

Upvotes: 0

smnbbrv
smnbbrv

Reputation: 24531

Because this is not a standard way of exporting variables. Check the documentation:

export { name1, name2, …, nameN };
export { variable1 as name1, variable2 as name2, …, nameN };
export let name1, name2, …, nameN; // also var
export let name1 = …, name2 = …, …, nameN; // also var, const

export default expression;
export default function (…) { … } // also class, function*
export default function name1(…) { … } // also class, function*
export { name1 as default, … };

export * from …;
export { name1, name2, …, nameN } from …;
export { import1 as name1, import2 as name2, …, nameN } from …;

So what you can do is

export { Tasks };

Upvotes: 3

Related Questions