Fred Collins
Fred Collins

Reputation: 5010

What's the difference between these two imports statement?

In Meteor 1.4, what's the difference between these two import statements in the client code and in the server code? Why?

Client code:

import { Items } from '../imports/api/items.js';

Server code:

import '../imports/api/items.js';

Upvotes: 0

Views: 106

Answers (1)

Mylan Connolly
Mylan Connolly

Reputation: 526

Both statements will execute the file given, however the first one will add Item to the scope. This can be useful if the file has many exports and you are only concerned with that single class/function/object/etc.

The second is used for side effects provided from importing it (like initializing a store or something like that; I confess I don't know much about meteor).

Mozilla has a great resource on the import statement https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Upvotes: 1

Related Questions