##Component module structure
app.js
/components
/list
list.js
router.js
controller.js
template.html
styles.scss // this is converted to styles.css by your SCSS pre-processor
The list module is imported into your main app using
import listModule from './components/list/list'
Inject in the main app using
listModule.name
###Controller and ES6 class
I recommend using the controller-no-class style. Why?
##CSS
A CSS wrapper class gives us CSS specificity to modularize the component CSS. All CSS selectors are effectively globals so we cannot get isolation. This approach means we do not need convoluted naming conventions (BEM, SMACSS, ATOMIC) that add error prone naming conventions via verbose markup, and do not solve the real problem.
Use your CSS pre-processor to generate modular CSS and clean HTML.
To import CSS install the jspm CSS plugin
##ES6
ES6 transpiling is handled automatically by jspm using Traceur or Babel. I recommend Babel as it does not require an additional run-time.
Using jspm.io we can bundle everything into a single javascript file using the sfx command:
jspm bundle-sfx path/to/entry/file path/to/output/file;
Tip: If you are using WebStorm set your JavaScript language version to JSX Harmony to prevent "file not found" warning for the HTML file import.