1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.InlineViewDependenciesPlugin = void 0;
|
4 |
|
5 |
|
6 | const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
|
7 | const htmlLoader = require("./html-requires-loader");
|
8 | const BasicEvaluatedExpression = require("webpack/lib/javascript/BasicEvaluatedExpression");
|
9 | const TAP_NAME = "Aurelia:InlineViewDependencies";
|
10 |
|
11 | class InlineViewDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
|
12 | parser(compilation, parser, add) {
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | parser.hooks.evaluateIdentifier.for('javascript/auto').tap(TAP_NAME, (expr) => {
|
20 | if (expr.name === "inlineView") {
|
21 | return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
|
22 | }
|
23 | return undefined;
|
24 | });
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | parser.hooks.evaluate.for('javascript/auto').tap(TAP_NAME, expr => {
|
32 |
|
33 |
|
34 | if (expr.type === 'MemberExpression' && expr.property.name === "inlineView") {
|
35 | return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
|
36 | }
|
37 | return undefined;
|
38 | });
|
39 | parser.hooks.call.for('javascript/auto').tap(TAP_NAME, $expr => {
|
40 | const expr = $expr;
|
41 | if (expr.arguments.length !== 1)
|
42 | return;
|
43 | let arg1 = expr.arguments[0];
|
44 | let param1 = parser.evaluateExpression(arg1);
|
45 | if (!(param1 === null || param1 === void 0 ? void 0 : param1.isString())) {
|
46 | return;
|
47 | }
|
48 | let modules;
|
49 | try {
|
50 | modules = htmlLoader.modules(param1.string);
|
51 | }
|
52 | catch (e) {
|
53 | return;
|
54 | }
|
55 | modules.forEach(add);
|
56 | });
|
57 | }
|
58 | }
|
59 | exports.InlineViewDependenciesPlugin = InlineViewDependenciesPlugin;
|