@marko/compiler 5.27.0 → 5.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
const nodePath = require("path");
|
|
4
4
|
const taglibConfig = require("../config");
|
|
5
5
|
const jsonFileReader = require("./json-file-reader");
|
|
6
|
-
const tagDefFromCode = require("./tag-def-from-code");
|
|
7
6
|
const loaders = require("./loaders");
|
|
8
|
-
const fsReadOptions = { encoding: "utf8" };
|
|
9
|
-
const extend = require("raptor-util/extend");
|
|
10
7
|
const types = require("./types");
|
|
11
8
|
|
|
12
9
|
const tagFileTypes = [
|
|
@@ -188,19 +185,6 @@ dependencyChain)
|
|
|
188
185
|
}
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
|
|
192
|
-
if (!hasTagJson && (tagDef.renderer || tagDef.template)) {
|
|
193
|
-
let templateCode = String(
|
|
194
|
-
taglibConfig.fs.readFileSync(
|
|
195
|
-
tagDef.renderer || tagDef.template,
|
|
196
|
-
fsReadOptions));
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
let extractedTagDef = tagDefFromCode.extractTagDef(templateCode);
|
|
200
|
-
if (extractedTagDef) {
|
|
201
|
-
extend(tagDef, extractedTagDef);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
188
|
}
|
|
205
189
|
|
|
206
190
|
let tagDependencyChain;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/compiler",
|
|
3
3
|
"description": "Marko template to JS compiler.",
|
|
4
|
-
"version": "5.27.
|
|
4
|
+
"version": "5.27.1",
|
|
5
5
|
"author": "Dylan Piercey <dpiercey@ebay.com>",
|
|
6
6
|
"bugs": "https://github.com/marko-js/marko/issues/new?template=Bug_report.md",
|
|
7
7
|
"dependencies": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"strip-json-comments": "^3.1.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@marko/translator-default": "^5.25.
|
|
32
|
+
"@marko/translator-default": "^5.25.1"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict"; // Rather than using a full-blown JavaScript parser, we are going to use a few regular expressions
|
|
2
|
-
// to tokenize the code and find what we are interested in
|
|
3
|
-
var tagStartRegExp = /(^\s*(?:(?:exports.(?:tag|TAG))|(?:TAG))\s*=\s*)\{/m;
|
|
4
|
-
|
|
5
|
-
// Tokens: "<string>", '<string>', /*<some comment*/, //<single line comment>, {, }, ;
|
|
6
|
-
var tokensRegExp =
|
|
7
|
-
/"(?:[^"]|\\")*"|'(?:[^'])|(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*)|[{};]/g;
|
|
8
|
-
|
|
9
|
-
function extractTagDef(code) {
|
|
10
|
-
var startMatches = tagStartRegExp.exec(code);
|
|
11
|
-
|
|
12
|
-
var tagDefStart;
|
|
13
|
-
var tagDefEnd;
|
|
14
|
-
|
|
15
|
-
if (startMatches) {
|
|
16
|
-
tagDefStart = startMatches.index + startMatches[1].length;
|
|
17
|
-
var nextTokenMatches;
|
|
18
|
-
tokensRegExp.lastIndex = tagDefStart;
|
|
19
|
-
var depth = 0;
|
|
20
|
-
|
|
21
|
-
while (nextTokenMatches = tokensRegExp.exec(code)) {
|
|
22
|
-
if (nextTokenMatches[0] === "{") {
|
|
23
|
-
depth++;
|
|
24
|
-
continue;
|
|
25
|
-
} else if (nextTokenMatches[0] === "}") {
|
|
26
|
-
if (--depth === 0) {
|
|
27
|
-
tagDefEnd = tokensRegExp.lastIndex;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
} else if (nextTokenMatches[0] === ";") {
|
|
31
|
-
tagDefEnd = nextTokenMatches.index;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (tagDefStart != null && tagDefEnd != null) {
|
|
37
|
-
var jsTagDef = code.substring(tagDefStart, tagDefEnd);
|
|
38
|
-
var tagDefObject;
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
// Try parsing it as JSON
|
|
42
|
-
tagDefObject = JSON.parse(jsTagDef);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
// Try parsing it as JavaScript
|
|
45
|
-
try {
|
|
46
|
-
tagDefObject = eval("(" + jsTagDef + ")");
|
|
47
|
-
} catch (e) {
|
|
48
|
-
tagDefObject = {};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return tagDefObject;
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
exports.extractTagDef = extractTagDef;
|