-
Notifications
You must be signed in to change notification settings - Fork 312
Description
Currently the static analysis of assets only supports emitting "files". Whenever there is a static expression that exactly corresponds to a file, that file is emitted.
Many dynamic loading cases use dynamic directory emission though:
exports.getThing = function (name) {
return fs.readFileSync(__dirname + '/things/' + name);
}Now one thing we could do here is adjust the asset emission to support directory expressions as well.
This requires supporting wildcards in static analysis - when name is encountered, basically treating it as a wildcard string path and not stopping but continuing the static analysis. So in the above analysis when /path/to/things/* is formed as an expression, we see that it matches real files and then emit the folder with numeric deduping, along with all files matching the wildcard such that any loads within that folder will work out.
It gets a bit tricky, but it is very much possible to do sensibly.
This would fix super important real-world use cases like cowsay.