Perhaps we can tell Meteor 1.3’s new modules
system not to load entry points (main.js
files) so we can load them manually.
We can currently import any file by referencing it relative to /app
inside of a module, for example
import foo from '/app/path/to/foo'
By the same token, maybe we can tell Meteor 1.3 not to load a given entry point using the same type of path relative to /app
(in package.json?):
{
"dependencies": {
// ...
},
"meteor": {
"skipLoad": [
"/app/client/home/main.js",
"/app/client/about/main.js"
]
}
}
Then, Meteor would compile those entry points as usual with one small difference: they won’t be loaded. Additionally, we can use the same exact paths to load them manually when we desire, so, for example, we could manually put this into the <head>
of our app:
<script src="/app/client/about/main.js"></script>
We could load the entry points any way we wish, manuall/programmatically.
I think that’d be a killer feature. As a side-effect, we can use existing tools to programmatically load JavaScript files, for example with SystemJS
:
System.import('/app/client/about/main.js')
.then(...)
// easy!
This would all work in harmony with Meteor 1.3’s new module system. Apps could still take advantage of build plugins to handle things like import image from './image.png'
, but, the entry point simply won’t be loaded.
Meteor would need to serve the URL for each file (f.e. /app/client/about/main.js
) so that we can load them. There could also be an option to configure the URL prefix, so it could be /whatever/we/want/client/about/main.js
or /js/client/about/main.js
@benjamn Any thoughts on this?