UNPKG

956 BJavaScriptView Raw
1"use strict";
2const parse = require("html-loader/lib/attributesParser");
3const _htmlSymbol = Symbol("HTML dependencies");
4function loader(content) {
5 this.cacheable && this.cacheable();
6 this._module[_htmlSymbol] = loader.modules(content);
7 return content;
8}
9(function (loader) {
10 loader.htmlSymbol = _htmlSymbol;
11 loader.attributes = {
12 "require": ["from"],
13 "compose": ["view", "view-model"],
14 "router-view": ["layout-view", "layout-view-model"],
15 };
16 function modules(html) {
17 return parse(html, (tag, attr) => {
18 const attrs = loader.attributes[tag];
19 return attrs && attrs.includes(attr);
20 })
21 // Ignore values that contain interpolated values
22 .filter(attr => !/(^|[^\\])\$\{/.test(attr.value))
23 .map(attr => attr.value);
24 }
25 loader.modules = modules;
26})(loader || (loader = {}));
27module.exports = loader;