1

I find the section on application structure in the official documentation quite confusing for me. It first says

The only server assets are JavaScript and files in the private subdirectory.

but then immediately

Meteor gathers all your JavaScript files, excluding anything under the client, public, and private subdirectories...

and later

Meteor gathers all JavaScript files in your tree, with the exception of the server, public, and private subdirectories, for the client...

and

Files outside the client, server and tests subdirectories are loaded on both the client and the server!

These seem contradicting for me. For example what if I put some JavaScript files in private, will they be gathered by Meteor? By 1 and 3, yes and to the server only; by 2, no; by 4, yes and to both server and client.

One possible explanation is that the set "JavaScript files" is not a subset of the set "files", which is not logically sound. I know this answer has provided a clear table for the structure and I may ultimately resort to that. But I still need someone to clearify the ambiguity of this part in the official documentation. Thank you.

Community
  • 1
  • 1
Ziyuan
  • 4,215
  • 6
  • 48
  • 77

1 Answers1

2

First I ought to split up the files into 3 types of classes

  1. Files that are parsed by Meteor as part of the project (not considered static)
  2. Files that are considered as part of Meteor but are static
  3. Other files like those necessary for tests

The only server assets are JavaScript and files in the private subdirectory.

These files are considered 'static' and js files in private are not run. What it means is that files in private and server are not visible to the client. (Part of 2 in the criteria above)

Files outside the client, server and tests subdirectories are loaded on both the client and the server!

It ought to say private and public too, private and public files aren't loaded on the browser. (These are mentioned this way, but are in reference to 1) hence the confusing language


Summary

tests - Only used for tests, not parsed by Meteor

private Storing static files that are not parsed by meteor that the browser cannot access, can be accessed by the server only via Assets

public Storing static files that the browser can access, mapped to the the / path

server Files only run on the server and are parsed as part of Meteor,

client Files only run on the web browser and are part of Meteor

packages Stores packages that meteor will parse in a special way, can not contain anything apart from Meteor packages. Can contain code that is considered as parts of the private, public, client or server folders.

. (Folders and files beginning with .) - Ignored

..~ - Folders ending with the tilde - Ignored

Anything Else Parsed as part of Meteor, and runs both on the client side and the server side.

Anything that is run by the client or server and parsed by Meteor is usually concatenated and minified in production.

Static files accessible by the client - notes These will be separated from the app and run in a virtual static folder in production (e.g Images, Fonts, Videos, non js files)

This is not a table like the other question, which explains how to structure an app, but more how Meteor interprets the files in the folders above.

Community
  • 1
  • 1
Tarang
  • 75,157
  • 39
  • 215
  • 276
  • Thank you. Questions: 1. for your 2, do you mean the static files? 2. what does it mean by saying files in `public` aren't loaded on the browser but can be accessed by the browser? – Ziyuan Jul 03 '14 at 20:37
  • 1
    With files in `public`, e.g a file called `test.js`, it won't be included in your code, you need to access it manually by calling `localhost:3000/test.js`, unlike the js files which are parsed by Meteor. No for 2, files are considered part of Meteor and are parsed as Meteor code, they are not static (in contrast, for example to this test.js file. A `test.js` file in `client` automatically runs on the web browser even if you dont manually include it in your html). – Tarang Jul 03 '14 at 20:42