@isograph/babel-plugin 0.0.0-main-f7ff4ee4 → 0.0.0-main-c3e3c34d
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.
- package/BabelPluginIsograph.js +1 -1
- package/compileTag.js +9 -6
- package/package.json +1 -1
package/BabelPluginIsograph.js
CHANGED
package/compileTag.js
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
const pathModule = require('path');
|
4
4
|
|
5
5
|
function compileTag(t, path, config) {
|
6
|
-
const
|
7
|
-
|
8
|
-
if (tag.isIdentifier({ name: 'iso' })) {
|
6
|
+
const callee = path.node.callee;
|
7
|
+
if (t.isIdentifier(callee) && callee.name === 'iso' && path.node.arguments) {
|
9
8
|
const { keyword, type, field } = getTypeAndField(path);
|
10
9
|
if (keyword === 'entrypoint') {
|
11
10
|
// This throws if the tag is invalid
|
@@ -19,7 +18,6 @@ function compileTag(t, path, config) {
|
|
19
18
|
);
|
20
19
|
}
|
21
20
|
}
|
22
|
-
|
23
21
|
return false;
|
24
22
|
}
|
25
23
|
|
@@ -29,14 +27,19 @@ const typeAndFieldRegex = new RegExp(
|
|
29
27
|
);
|
30
28
|
|
31
29
|
function getTypeAndField(path) {
|
32
|
-
|
30
|
+
if (path.node.arguments.length !== 1) {
|
31
|
+
throw new Error(
|
32
|
+
`BabelPluginIsograph: Iso invocation require one parameter, found ${path.node.arguments.length}`,
|
33
|
+
);
|
34
|
+
}
|
35
|
+
const quasis = path.node.arguments[0].quasis;
|
33
36
|
if (quasis.length !== 1) {
|
34
37
|
throw new Error(
|
35
38
|
'BabelPluginIsograph: Substitutions are not allowed in iso fragments.',
|
36
39
|
);
|
37
40
|
}
|
38
41
|
|
39
|
-
const content =
|
42
|
+
const content = quasis[0].value.raw;
|
40
43
|
const typeAndField = typeAndFieldRegex.exec(content);
|
41
44
|
|
42
45
|
const keyword = typeAndField[1];
|