@riotjs/compiler
Advanced tools
Comparing version 6.0.3 to 6.0.4
{ | ||
"name": "@riotjs/compiler", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"description": "Compiler for riot .tag files", | ||
@@ -38,5 +38,5 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.15.0", | ||
"@babel/preset-env": "^7.15.0", | ||
"@riotjs/dom-bindings": "^6.0.0", | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@riotjs/dom-bindings": "^6.0.2", | ||
"@rollup/plugin-alias": "^3.1.5", | ||
@@ -54,6 +54,6 @@ "@rollup/plugin-commonjs": "^20.0.0", | ||
"pug": "^3.0.2", | ||
"rollup": "^2.56.0", | ||
"rollup-plugin-node-builtins": "^2.0.0", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"shelljs": "^0.8.4", | ||
"typescript": "^4.3.5" | ||
"typescript": "^4.4.3" | ||
}, | ||
@@ -67,3 +67,3 @@ "author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)", | ||
"dependencies": { | ||
"@babel/parser": "^7.15.0", | ||
"@babel/parser": "^7.15.7", | ||
"@riotjs/parser": "^4.3.1", | ||
@@ -75,3 +75,3 @@ "@riotjs/util": "2.0.4", | ||
"dom-nodes": "^1.1.3", | ||
"globals": "^13.10.0", | ||
"globals": "^13.11.0", | ||
"recast": "^0.20.5", | ||
@@ -78,0 +78,0 @@ "source-map": "^0.7.3" |
@@ -17,8 +17,7 @@ import { | ||
createBindingAttributes, | ||
createCustomNodeNameEvaluationFunction, | ||
createNestedRootNode, | ||
createSelectorProperties, | ||
getChildrenNodes, | ||
getCustomNodeNameAsExpression, | ||
getNodeAttributes, | ||
toScopedFunction | ||
getNodeAttributes | ||
} from '../utils' | ||
@@ -122,3 +121,3 @@ import build from '../builder' | ||
BINDING_EVALUATE_KEY, | ||
toScopedFunction(getCustomNodeNameAsExpression(sourceNode), sourceFile, sourceCode) | ||
createCustomNodeNameEvaluationFunction(sourceNode, sourceFile, sourceCode) | ||
), | ||
@@ -125,0 +124,0 @@ simplePropertyNode(BINDING_SLOTS_KEY, createSlotsArray(sourceNode, sourceFile, sourceCode)), |
@@ -423,7 +423,9 @@ import { | ||
/** | ||
* Get the name of a custom node transforming it into an expression node | ||
* Create custom tag name function | ||
* @param {RiotParser.Node} node - riot parser node | ||
* @param {string} sourceFile - original tag file | ||
* @param {string} sourceCode - original tag source code | ||
* @returns {RiotParser.Node.Attr} the node name as expression attribute | ||
*/ | ||
export function getCustomNodeNameAsExpression(node) { | ||
export function createCustomNodeNameEvaluationFunction(node, sourceFile, sourceCode) { | ||
const isAttribute = findIsAttribute(node) | ||
@@ -433,9 +435,12 @@ const toRawString = val => `'${val}'` | ||
if (isAttribute) { | ||
return isAttribute.expressions ? isAttribute.expressions[0] : { | ||
...isAttribute, | ||
text: toRawString(isAttribute.value) | ||
} | ||
return isAttribute.expressions ? wrapASTInFunctionWithScope( | ||
mergeAttributeExpressions(isAttribute, sourceFile, sourceCode) | ||
) : | ||
toScopedFunction({ | ||
...isAttribute, | ||
text: toRawString(isAttribute.value) | ||
}, sourceFile, sourceCode) | ||
} | ||
return { ...node, text: toRawString(getName(node)) } | ||
return toScopedFunction({ ...node, text: toRawString(getName(node)) }, sourceFile, sourceCode) | ||
} | ||
@@ -442,0 +447,0 @@ |
@@ -11,2 +11,3 @@ import {TAG_CSS_PROPERTY, TAG_LOGIC_PROPERTY, TAG_NAME_PROPERTY, TAG_TEMPLATE_PROPERTY} from './constants' | ||
import hasHTMLOutsideRootNode from './utils/has-html-outside-root-node' | ||
import isEmptyArray from './utils/is-empty-array' | ||
import isEmptySourcemap from './utils/is-empty-sourcemap' | ||
@@ -141,16 +142,8 @@ import javascriptGenerator from './generators/javascript' | ||
* @param { Object } meta - compilation meta information | ||
* @returns { Promise<Output> } object containing output code and source map | ||
* @returns { function(): Promise<Output> } Function what resolves to object containing output code and source map | ||
*/ | ||
function hookGenerator(transformer, sourceNode, source, meta) { | ||
if ( | ||
// filter missing nodes | ||
!sourceNode || | ||
// filter nodes without children | ||
(sourceNode.nodes && !sourceNode.nodes.length) || | ||
// filter empty javascript and css nodes | ||
(!sourceNode.nodes && !sourceNode.text)) { | ||
return result => result | ||
} | ||
const hasContent = sourceNode && (sourceNode.text || !isEmptyArray(sourceNode.nodes) || !isEmptyArray(sourceNode.attributes)) | ||
return curry(transformer)(sourceNode, source, meta) | ||
return hasContent ? curry(transformer)(sourceNode, source, meta) : result => result | ||
} | ||
@@ -157,0 +150,0 @@ |
@@ -0,1 +1,3 @@ | ||
import isEmptyArray from './is-empty-array' | ||
/** | ||
@@ -7,3 +9,3 @@ * True if the sourcemap has no mappings, it is empty | ||
export default function isEmptySourcemap(map) { | ||
return !map || !map.mappings || !map.mappings.length | ||
} | ||
return !map || isEmptyArray(map.mappings) | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53
52676
1926378
Updated@babel/parser@^7.15.7
Updatedglobals@^13.11.0