Using ES6 `import` with CSS/HTML files in Meteor project: bug or feature?

Viewed 5267

I am currently learning Meteor and I found out something that intrigued me.

I can load HTML and CSS assets from a JS file using the import statement.

import '../imports/hello/myapp.html';
import '../imports/hello/myapp.css';
import * as myApp from '../imports/hello/myapp.js';

This was a surprise to me so I ran to google but could not find this behavior documented in the specification for ES6 import or in Meteor's Docs.

So my questions are:

  • Can I rely on this behavior to build my apps?
  • Will my app will break when Meteor gets around to fix it -- if it's a bug --?

Notes

  • I am using Meteor v1.3, not sure if this works also with previous versions.
  • You can download the app to see this behavior from Github
3 Answers
Related