Clarify app structure and more import examples #356
Conversation
* Add info on npm install requirements for builds `meteor build` requires that npm dependencies are installed manually first. This isn't in the guide yet. * Remove unnecessary extra --production * Add back in build tool default loading order rules * Add back in build tool default loading order and cleanup * Fix typo * Update README.md * Delete research.md File isn't relevant anymore * Move old organizational files into meta dir * Recommend against overriding config.xml and mention alternative * Add more details about App.accessRule usage * Add CHANGELOG and CONTRIBUTING files * Improve link to changelog * Delete mkdocs.yml * Add more content on using Atmosphere packages - Update README.md - Clarification on meteor add for packages - Add link to meteor publish command * Fix typo * Fix bad link * Change export name to myName * Updated the createContainer section to match the latest version of the todos app (react branch). * Update linter-eslint screen capture and npm prefix command * Update code-style.md * Update atom-configuration.png * Fix a small typo. * Fix a small typo. * Fix a few broken links. * chore(docs): Add recommended changes to angular meteor apps * Link directly to CSS pre-processor section
|
||
In Meteor, it is also simple and straightforward to use the `import` syntax to load npm packages on the client or server, and access the package's exported symbols as you would with any other module. You can also import from Atmosphere packages, but the import path must be prefixed with `meteor/` to avoid conflict with the npm package namespace. For example, to import `HTTP` you could use `import { HTTP } from 'meteor/http'`. | ||
Meteor allows you to `import` not only JavaScript in your application, but also CSS and HTML: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not really clear from this what importing HTML and CSS does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
Meteor allows you to import
not only JavaScript in your application, but also CSS and HTML if you want to control their load order:
Looks really good, a few comments! |
(BTW probably what you want to do to fix this PR is |
@stubailo Let me know if this looks OK now. If not, I can start over... |
```js | ||
import '../../api/lists/methods.js'; // import from relative path | ||
import '/imports/startup/client'; // import module with index.js from absolute path | ||
import './loading.html'; // import HTML from relative path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is maybe not quite correct. I'm not sure what the best one liner is, but it's something like "import Blaze-compiled HTML"
This is looking great @skirunman |
@stubailo Anything else you want done to this PR? |
LGTM! |
Love it! |
|
||
There are several load order rules. They are *applied sequentially* to all applicable files in the application, in the priority given below: | ||
|
||
1. HTML template files are *always* loaded before everything else | ||
1. HTML template files are **always** loaded before everything else | ||
2. Files beginning with `main.` are loaded **last** | ||
3. Files inside **any** `lib/` directory are loaded next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit odd to say something gets "loaded next", when the previous point said what will be "loaded last".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be a bit confusing, but the order listed is the priority order that the rules are evaluated, not files are loaded, as shown in the little example below this section. If you can come up with a better way to express this I'm sure MDG will accept the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think the fact that this is so confusing is one reason why we don't recommend it anymore, and instead encourage people to use modules.
If my merge upstream commit f7cf78b is an issue let me know. Still learning idiosyncrasies of git and github and not sure if this pollutes upstream commit history.