Reputation: 88
I can't seem to get an import statement to work within my packages folder.
I have a file structure like the following:
-client
-model
-users.js
-packages
-mobile
-browser
-client
-auth
-login
-login.component.js
in login.component.js I need to import { user } from '/model/users.js'
. Is this possible? If so how do I do it? If not what is a good workaround?
Edit: users.js
const User = Class.create({
name: 'User',
collection: Meteor.users,
secured: true,
fields: {
username: {type: String },
createdAt: { type: Date },
userData: { type: UserData, optional:true },
fullName: {
type: String,
resolve(doc) {
if (doc && doc.userData)
return doc.userData.firstName + ' ' + doc.userData.lastName;
else {
"no name"
}
}
}
}
});
export { User };
Upvotes: 0
Views: 980
Reputation: 21364
import
statements are necessary for files in the /imports
folder. Everything outside of that folder will be auto-loaded for you, so you don't need to import it manually.
More detail here: https://guide.meteor.com/structure.html#intro-to-import-export
Just make sure your User
object is global, i.e., change
const User = Class.create({
to
User = Class.create({
Upvotes: 2