@marko/translator-default 5.18.2 → 5.19.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -45,11 +45,13 @@ function _default(path, isNullable) {
45
45
 
46
46
  if (relativePath) {
47
47
  if (binding) {
48
- console.warn(
49
- path.buildCodeFrameError(
50
- `The <${tagName}> tag has been resolved from the filesystem, however a local variable with the same name exists. In the next major version of Marko the local variable will tag precedence.`));
51
-
52
-
48
+ // TODO: implement auto migration for conflicts here
49
+ // and log below warning
50
+ // console.warn(
51
+ // path.buildCodeFrameError(
52
+ // `The <${tagName}> tag has been resolved from the filesystem, however a local variable with the same name exists. In the next major version of Marko the local variable will tag precedence.`
53
+ // )
54
+ // );
53
55
  }
54
56
 
55
57
  tagIdentifier = (0, _babelUtils.importDefault)(file, relativePath, tagName);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/tag/custom-tag.js"],"names":["path","isNullable","hub","file","node","markoOpts","name","key","tagIdentifier","t","isStringLiteral","tagName","value","relativePath","extra","tagDef","taglibId","renderer","binding","scope","getBinding","identifier","loc","console","warn","buildCodeFrameError","set","ignoreUnrecognizedTags","get","foundAttrs","customTagRenderCall","expressionStatement","callExpression","isNullLiteral","objectExpression","_componentDefIdentifier","renderBodyIdentifier","renderBodyProp","isObjectExpression","properties","find","prop","generateUidIdentifier","insertBefore","variableDeclaration","variableDeclarator","replaceWith","ifStatement"],"mappings":"uJAAA;AACA;;;;;;AAMA;AACA;AACA;AACA;;AAEe,kBAAUA,IAAV,EAAgBC,UAAhB,EAA4B;AACzC,QAAM;AACJC,IAAAA,GAAG,EAAE,EAAEC,IAAF,EADD;AAEJC,IAAAA,IAFI;AAGFJ,EAAAA,IAHJ;AAIA,QAAM,EAAEK,SAAF,KAAgBF,IAAtB;AACA,QAAM,EAAEG,IAAF,EAAQC,GAAR,KAAgBH,IAAtB;;AAEA,gCAAaJ,IAAb;;AAEA,MAAIQ,aAAJ;;AAEA,MAAIC,gBAAEC,eAAF,CAAkBJ,IAAlB,CAAJ,EAA6B;AAC3B,UA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M,IAAAA,oBAAoB;AAClB3B,oBAAEsB,mBAAF;AACEtB,oBAAEuB,cAAF,CAAiBI,oBAAjB,EAAuC,CAAC3B,gBAAEY,UAAF,CAAa,KAAb,CAAD,CAAvC,CADF,CAJJ,CADF;;;;AAUD,GA7BD,MA6BO;AACLrB,IAAAA,IAAI,CAAC8C,WAAL,CAAiBhB,mBAAjB;AACD;AACF","sourcesContent":["import { types as t } from \"@marko/compiler\";\nimport {\n assertNoArgs,\n getTagDef,\n importDefault,\n resolveRelativePath\n} from \"@marko/babel-utils\";\nimport { getAttrs, buildEventHandlerArray } from \"./util\";\nimport nativeTag from \"./native-tag\";\nimport dynamicTag from \"./dynamic-tag\";\nimport withPreviousLocation from \"../util/with-previous-location\";\n\nexport default function (path, isNullable) {\n const {\n hub: { file },\n node\n } = path;\n const { markoOpts } = file;\n const { name, key } = node;\n\n assertNoArgs(path);\n\n let tagIdentifier;\n\n if (t.isStringLiteral(name)) {\n const tagName = name.value;\n let relativePath = node.extra && node.extra.relativePath;\n\n if (!relativePath) {\n const tagDef = getTagDef(path);\n if (\n tagDef &&\n tagDef.taglibId === \"marko-default-core\" &&\n tagDef.renderer\n ) {\n // Normally new tags should not be added in the translate stage.\n // We make an exception here for core tags, init-components & _preserve being the primary culprits.\n // TODO: in the future refactor so this is not needed.\n relativePath = resolveRelativePath(file, tagDef.renderer);\n }\n }\n\n let binding = path.scope.getBinding(tagName);\n if (binding && !binding.identifier.loc) binding = null;\n\n if (relativePath) {\n if (binding) {\n console.warn(\n path.buildCodeFrameError(\n `The <${tagName}> tag has been resolved from the filesystem, however a local variable with the same name exists. In the next major version of Marko the local variable will tag precedence.`\n )\n );\n }\n\n tagIdentifier = importDefault(file, relativePath, tagName);\n } else if (binding) {\n path.set(\"name\", t.identifier(tagName));\n return dynamicTag(path);\n } else if (markoOpts.ignoreUnrecognizedTags) {\n return nativeTag(path);\n } else {\n throw path\n .get(\"name\")\n .buildCodeFrameError(\n `Unable to find entry point for custom tag <${tagName}>.`\n );\n }\n } else {\n tagIdentifier = name;\n }\n\n const foundAttrs = getAttrs(path);\n const customTagRenderCall = withPreviousLocation(\n t.expressionStatement(\n t.callExpression(\n importDefault(\n file,\n \"marko/src/runtime/helpers/render-tag.js\",\n \"marko_tag\"\n ),\n [\n tagIdentifier,\n // TODO: this could be left as null if we froze input mutations and used a default object in the runtime.\n t.isNullLiteral(foundAttrs) ? t.objectExpression([]) : foundAttrs,\n t.identifier(\"out\"),\n file._componentDefIdentifier,\n key,\n ...buildEventHandlerArray(path)\n ]\n )\n ),\n node\n );\n\n if (isNullable) {\n let renderBodyIdentifier;\n const renderBodyProp =\n t.isObjectExpression(foundAttrs) &&\n foundAttrs.properties.find(\n prop => prop.key && prop.key.value === \"renderBody\"\n );\n\n if (renderBodyProp) {\n renderBodyIdentifier = path.scope.generateUidIdentifier(\"renderBody\");\n path.insertBefore(\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(renderBodyIdentifier, renderBodyProp.value)\n ])\n );\n\n renderBodyProp.value = renderBodyIdentifier;\n }\n\n path.replaceWith(\n t.ifStatement(\n name,\n customTagRenderCall,\n renderBodyIdentifier &&\n t.expressionStatement(\n t.callExpression(renderBodyIdentifier, [t.identifier(\"out\")])\n )\n )\n );\n } else {\n path.replaceWith(customTagRenderCall);\n }\n}\n"],"file":"custom-tag.js"}
1
+ {"version":3,"sources":["../../src/tag/custom-tag.js"],"names":["path","isNullable","hub","file","node","markoOpts","name","key","tagIdentifier","t","isStringLiteral","tagName","value","relativePath","extra","tagDef","taglibId","renderer","binding","scope","getBinding","identifier","loc","set","ignoreUnrecognizedTags","get","buildCodeFrameError","foundAttrs","customTagRenderCall","expressionStatement","callExpression","isNullLiteral","objectExpression","_componentDefIdentifier","renderBodyIdentifier","renderBodyProp","isObjectExpression","properties","find","prop","generateUidIdentifier","insertBefore","variableDeclaration","variableDeclarator","replaceWith","ifStatement"],"mappings":"uJAAA;AACA;;;;;;AAMA;AACA;AACA;AACA;;AAEe,kBAAUA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AtB,EAA+B;AAC7BjC,sBAAEkC,kBAAF,CAAqBT,oBAArB,EAA2CC,cAAc,CAACvB,KAA1D,CAD6B,CAA/B,CADF;;;;AAMAuB,MAAAA,cAAc,CAACvB,KAAf,GAAuBsB,oBAAvB;AACD;;AAEDlC,IAAAA,IAAI,CAAC4C,WAAL;AACEnC,oBAAEoC,WAAF;AACEvC,IAAAA,IADF;AAEEsB,IAAAA,mBAFF;AAGEM,IAAAA,oBAAoB;AAClBzB,oBAAEoB,mBAAF;AACEpB,oBAAEqB,cAAF,CAAiBI,oBAAjB,EAAuC,CAACzB,gBAAEY,UAAF,CAAa,KAAb,CAAD,CAAvC,CADF,CAJJ,CADF;;;;AAUD,GA7BD,MA6BO;AACLrB,IAAAA,IAAI,CAAC4C,WAAL,CAAiBhB,mBAAjB;AACD;AACF","sourcesContent":["import { types as t } from \"@marko/compiler\";\nimport {\n assertNoArgs,\n getTagDef,\n importDefault,\n resolveRelativePath\n} from \"@marko/babel-utils\";\nimport { getAttrs, buildEventHandlerArray } from \"./util\";\nimport nativeTag from \"./native-tag\";\nimport dynamicTag from \"./dynamic-tag\";\nimport withPreviousLocation from \"../util/with-previous-location\";\n\nexport default function (path, isNullable) {\n const {\n hub: { file },\n node\n } = path;\n const { markoOpts } = file;\n const { name, key } = node;\n\n assertNoArgs(path);\n\n let tagIdentifier;\n\n if (t.isStringLiteral(name)) {\n const tagName = name.value;\n let relativePath = node.extra && node.extra.relativePath;\n\n if (!relativePath) {\n const tagDef = getTagDef(path);\n if (\n tagDef &&\n tagDef.taglibId === \"marko-default-core\" &&\n tagDef.renderer\n ) {\n // Normally new tags should not be added in the translate stage.\n // We make an exception here for core tags, init-components & _preserve being the primary culprits.\n // TODO: in the future refactor so this is not needed.\n relativePath = resolveRelativePath(file, tagDef.renderer);\n }\n }\n\n let binding = path.scope.getBinding(tagName);\n if (binding && !binding.identifier.loc) binding = null;\n\n if (relativePath) {\n if (binding) {\n // TODO: implement auto migration for conflicts here\n // and log below warning\n // console.warn(\n // path.buildCodeFrameError(\n // `The <${tagName}> tag has been resolved from the filesystem, however a local variable with the same name exists. In the next major version of Marko the local variable will tag precedence.`\n // )\n // );\n }\n\n tagIdentifier = importDefault(file, relativePath, tagName);\n } else if (binding) {\n path.set(\"name\", t.identifier(tagName));\n return dynamicTag(path);\n } else if (markoOpts.ignoreUnrecognizedTags) {\n return nativeTag(path);\n } else {\n throw path\n .get(\"name\")\n .buildCodeFrameError(\n `Unable to find entry point for custom tag <${tagName}>.`\n );\n }\n } else {\n tagIdentifier = name;\n }\n\n const foundAttrs = getAttrs(path);\n const customTagRenderCall = withPreviousLocation(\n t.expressionStatement(\n t.callExpression(\n importDefault(\n file,\n \"marko/src/runtime/helpers/render-tag.js\",\n \"marko_tag\"\n ),\n [\n tagIdentifier,\n // TODO: this could be left as null if we froze input mutations and used a default object in the runtime.\n t.isNullLiteral(foundAttrs) ? t.objectExpression([]) : foundAttrs,\n t.identifier(\"out\"),\n file._componentDefIdentifier,\n key,\n ...buildEventHandlerArray(path)\n ]\n )\n ),\n node\n );\n\n if (isNullable) {\n let renderBodyIdentifier;\n const renderBodyProp =\n t.isObjectExpression(foundAttrs) &&\n foundAttrs.properties.find(\n prop => prop.key && prop.key.value === \"renderBody\"\n );\n\n if (renderBodyProp) {\n renderBodyIdentifier = path.scope.generateUidIdentifier(\"renderBody\");\n path.insertBefore(\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(renderBodyIdentifier, renderBodyProp.value)\n ])\n );\n\n renderBodyProp.value = renderBodyIdentifier;\n }\n\n path.replaceWith(\n t.ifStatement(\n name,\n customTagRenderCall,\n renderBodyIdentifier &&\n t.expressionStatement(\n t.callExpression(renderBodyIdentifier, [t.identifier(\"out\")])\n )\n )\n );\n } else {\n path.replaceWith(customTagRenderCall);\n }\n}\n"],"file":"custom-tag.js"}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
3
  "description": "Translates Marko templates to the default Marko runtime.",
4
- "version": "5.18.2",
4
+ "version": "5.19.0",
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": {
8
8
  "@babel/runtime": "^7.16.0",
9
- "@marko/babel-utils": "^5.18.2",
9
+ "@marko/babel-utils": "^5.19.0",
10
10
  "escape-string-regexp": "^4.0.0",
11
11
  "magic-string": "^0.25.7",
12
12
  "self-closing-tags": "^1.0.1"
13
13
  },
14
14
  "devDependencies": {
15
- "@marko/compiler": "^5.18.2",
16
- "marko": "^5.18.2"
15
+ "@marko/compiler": "^5.19.0",
16
+ "marko": "^5.19.0"
17
17
  },
18
18
  "files": [
19
19
  "dist"
@@ -42,5 +42,5 @@
42
42
  "type": "git",
43
43
  "url": "https://github.com/marko-js/marko/tree/master/packages/translator-default"
44
44
  },
45
- "gitHead": "65999cf2accd091c1455705b94b91ca1ed64203f"
45
+ "gitHead": "07f5e26b79d46982caf0d1ed593675b4778877ac"
46
46
  }