Q: Meteor file Structure

i want to ask :slight_smile:

1st Q
if i must use this app structure http://guide.meteor.com/structure.html#example-app-structure?

and in this example https://github.com/meteor/todos he used a new code concept like this

import { Meteor } from ‘meteor/meteor’;
import { ValidatedMethod } from ‘meteor/mdg:validated-method’;
import { SimpleSchema } from ‘meteor/aldeed:simple-schema’;
import { DDPRateLimiter } from ‘meteor/ddp-rate-limiter’;

2nd Q

if i want to use this new structure guide.meteor.com/structure.html#example-app-structure

i must use the imports like he did?

You don’t have to use the structure or the imports if you really don’t want to, v1.3 is backwards compatible with v1.2

You can use imports with any structure you like

The imports are ES6 module syntax

Please can you explain me what is the utility of using the structure or the imports

The main benefit for using imports is you can define the load order of the files rather than relying on meteor to do it for you. It may be a bit counter-intuitive in most cases, but it does make things more predictable.

In addition, using imports will allow you to avoid implicit globals in your code so linters would have an easier time.

The structure uses a folder named ‘imports’ where files in there won’t be loaded unless you explicitly import them

To be really clear, if you use the structure with the “imports” directory, you must use imports in your code because files under any imports directory are not loaded unless explicitly included by import or require.

Furthermore, if you’re writing new code and believe you’ll continue using meteor beyond 1.3, IMO it would be wise to use the modular structure (imports) now because there is an expectation that a future release will lazy load files from all directories, not just the imports directory.

You’ll find many opinions as to the advantage(s) of modular structure. IMO it keeps the namespace cleaner and I like the explicit indication of dependencies in every file. Of course, I cut my teeth on languages like Pascal and Ada and applications with millions of lines.