@riotjs/compiler
Advanced tools
Comparing version 6.1.3 to 6.2.0
@@ -44,2 +44,3 @@ import {RawSourceMap} from 'source-map' | ||
// public API | ||
export function generateTemplateFunctionFromString(source: string): string | ||
export function compile(source: string, options?: CompilerOptions): CompilerOutput | ||
@@ -46,0 +47,0 @@ export function registerPreprocessor( |
{ | ||
"name": "@riotjs/compiler", | ||
"version": "6.1.3", | ||
"version": "6.2.0", | ||
"description": "Compiler for riot .tag files", | ||
@@ -38,21 +38,21 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.4", | ||
"@riotjs/dom-bindings": "^6.0.2", | ||
"@rollup/plugin-alias": "^3.1.8", | ||
"@rollup/plugin-commonjs": "^21.0.1", | ||
"@babel/core": "^7.18.5", | ||
"@babel/preset-env": "^7.18.2", | ||
"@riotjs/dom-bindings": "^6.0.3", | ||
"@rollup/plugin-alias": "^3.1.9", | ||
"@rollup/plugin-commonjs": "^22.0.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.32.0", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"chai": "^4.3.6", | ||
"eslint": "^8.17.0", | ||
"eslint-config-riot": "^3.0.0", | ||
"esm": "^3.2.25", | ||
"mocha": "^8.4.0", | ||
"node-sass": "^7.0.0", | ||
"node-sass": "^7.0.1", | ||
"nyc": "^15.1.0", | ||
"pug": "^3.0.2", | ||
"rollup": "^2.61.1", | ||
"rollup": "^2.75.6", | ||
"rollup-plugin-node-builtins": "^2.1.2", | ||
"shelljs": "^0.8.4", | ||
"typescript": "^4.5.3" | ||
"shelljs": "^0.8.5", | ||
"typescript": "^4.7.3" | ||
}, | ||
@@ -66,3 +66,3 @@ "author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)", | ||
"dependencies": { | ||
"@babel/parser": "^7.16.4", | ||
"@babel/parser": "^7.18.5", | ||
"@riotjs/parser": "^4.3.1", | ||
@@ -74,6 +74,6 @@ "@riotjs/util": "2.0.4", | ||
"dom-nodes": "^1.1.3", | ||
"globals": "^13.12.0", | ||
"globals": "^13.15.0", | ||
"recast": "^0.20.5", | ||
"source-map": "^0.7.3" | ||
"source-map": "^0.7.4" | ||
} | ||
} |
@@ -67,3 +67,3 @@ [![Build Status][ci-image]][ci-url] | ||
### compile(string, options) | ||
#### @returns `<Promise>{ code, map }` output that can be used by Riot.js | ||
#### @returns `{ code, map }` output that can be used by Riot.js | ||
@@ -97,2 +97,4 @@ - *string*: is your tag source code | ||
### generateTemplateFunctionFromString(string) | ||
#### @returns `string` with the code to execute the @riotjs/bindings `template` function | ||
@@ -99,0 +101,0 @@ [ci-image]:https://img.shields.io/github/workflow/status/riot/compiler/test?style=flat-square |
@@ -219,3 +219,3 @@ import { | ||
if (isObjectExpression(ast)) { | ||
// doing a small hack here f | ||
// doing a small hack here | ||
// trying to figure out how the recast printer works internally | ||
@@ -375,3 +375,3 @@ ast.extra = { | ||
transformStatiAttributesIntoExpressions, | ||
// root nodes shuold't have directives | ||
// root nodes shouldn't have directives | ||
cleanAttributes | ||
@@ -378,0 +378,0 @@ )(node) |
@@ -5,3 +5,5 @@ import {TAG_CSS_PROPERTY, TAG_LOGIC_PROPERTY, TAG_NAME_PROPERTY, TAG_TEMPLATE_PROPERTY} from './constants' | ||
import {register as registerPreproc, execute as runPreprocessor} from './preprocessors' | ||
import build from './generators/template/builder' | ||
import {builders} from './utils/build-types' | ||
import {callTemplateFunction} from './generators/template/utils' | ||
import compose from 'cumpa' | ||
@@ -96,2 +98,18 @@ import cssGenerator from './generators/css' | ||
/** | ||
* Generate the Riot.js binding template function from a template string | ||
* @param { string } source - template string | ||
* @returns { string } Riot.js bindings template function generated | ||
*/ | ||
export function generateTemplateFunctionFromString(source) { | ||
const { parse } = riotParser() | ||
const { template } = parse(source).output | ||
return compose( | ||
({ code }) => code, | ||
generateJavascript, | ||
callTemplateFunction | ||
)(...build(template, DEFAULT_OPTIONS.file, source)) | ||
} | ||
/** | ||
* Generate the output code source together with the sourcemap | ||
@@ -98,0 +116,0 @@ * @param { string } source - source code of the tag we will need to compile |
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
2081272
56520
110
Updated@babel/parser@^7.18.5
Updatedglobals@^13.15.0
Updatedsource-map@^0.7.4