Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Enable dependency-aware (re-)loading of marko templates
Browse files Browse the repository at this point in the history
- Marko templates can be dependent on other Marko templates via include, tag name reference, etc.
- Tell Webpack about these dependencies so that changes in a parent template causes Webpack to reload (and recompile) all child templates
  • Loading branch information
stephenbrady committed Apr 20, 2017
1 parent bfe8fcc commit 50f824f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ module.exports = function(source) {
writeToDisk: false
});

this.clearDependencies();

if (compiled.context.meta.tags) {
compiled.context.meta.tags.forEach((tag) => {
this.resolve(this.context, tag.value, (err, res) => {
if (err) {
this.emitWarning(`Unable to resolve dependency for ${compiled.filename}: ${tag.value}\n`);
} else {
this.addDependency(res);
}
})
});
}

var dependencies = compiled.dependencies.map((dependency, i) => {
if (!dependency.code) {
// external file, just require it
Expand Down

0 comments on commit 50f824f

Please sign in to comment.