@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.
@@ -30,7 +30,7 @@ module.exports = function BabelPluginIsograph(context) {
30
30
  }
31
31
 
32
32
  const visitor = {
33
- TaggedTemplateExpression(path) {
33
+ CallExpression(path) {
34
34
  compileTag(t, path, IsographConfig);
35
35
  },
36
36
  };
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 tag = path.get('tag');
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
- const quasis = path.node.quasi.quasis;
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 = path.node.quasi.quasis[0].value.raw;
42
+ const content = quasis[0].value.raw;
40
43
  const typeAndField = typeAndFieldRegex.exec(content);
41
44
 
42
45
  const keyword = typeAndField[1];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@isograph/babel-plugin",
3
3
  "description": "A Babel plugin for use with Isograph applications.",
4
- "version": "0.0.0-main-f7ff4ee4",
4
+ "version": "0.0.0-main-c3e3c34d",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "isograph",