Comparing version 0.0.0 to 0.0.1
@@ -1,2 +0,5 @@ | ||
module.exports = function (html) { | ||
module.exports = function () { | ||
// Allow `bel` to be swapped in benchmarking | ||
const html = require('bel') | ||
const greeting = 'Hello' | ||
@@ -3,0 +6,0 @@ const name = 'special characters, <, >, &' |
@@ -1,21 +0,13 @@ | ||
const bel = require('bel') | ||
const stringify = require('.') | ||
const pelo = require('.') | ||
const createApp = require('./app') | ||
const warmup = 100 | ||
const iteration = 10000 | ||
const strApp = createApp(stringify) | ||
const belApp = createApp(bel) | ||
console.log('# stringify output') | ||
console.log(strApp.render().toString()) | ||
console.log('# bel output') | ||
console.log(belApp.render().toString()) | ||
console.log(`# benchmark ${iteration} iterations`) | ||
console.time('pelo') | ||
for (let i = 0; i < iteration; i++) { | ||
strApp.render().toString() | ||
const belApp = createApp() | ||
for (let i = 0; i < warmup; i++) { | ||
belApp.render().toString() | ||
} | ||
console.timeEnd('pelo') | ||
console.time('bel') | ||
@@ -26,1 +18,12 @@ for (let i = 0; i < iteration; i++) { | ||
console.timeEnd('bel') | ||
pelo.replace('bel') | ||
const peloApp = createApp() | ||
for (let i = 0; i < warmup; i++) { | ||
peloApp.render().toString() | ||
} | ||
console.time('pelo') | ||
for (let i = 0; i < iteration; i++) { | ||
peloApp.render().toString() | ||
} | ||
console.timeEnd('pelo') |
@@ -1,2 +0,1 @@ | ||
const bel = require('bel') | ||
const nanomorph = require('nanomorph') | ||
@@ -6,3 +5,3 @@ | ||
const app = createApp(bel) | ||
const app = createApp() | ||
@@ -9,0 +8,0 @@ const root = document.getElementById('root') |
14
index.js
@@ -0,1 +1,3 @@ | ||
const Module = require('module') | ||
function handleValue (value) { | ||
@@ -45,2 +47,14 @@ if (Array.isArray(value)) { | ||
function replace(moduleId) { | ||
const originalRequire = Module.prototype.require | ||
Module.prototype.require = function (id) { | ||
if (id === moduleId) { | ||
return stringify | ||
} else { | ||
return originalRequire.apply(this, arguments) | ||
} | ||
} | ||
} | ||
stringify.replace = replace | ||
module.exports = stringify |
{ | ||
"name": "pelo", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Lightning fast server-side rendering with tagged template literals", | ||
"main": "index.js", | ||
"browser": "bel", | ||
"scripts": { | ||
"start": "npm run build && node server.js", | ||
"test": "node benchmark.js", | ||
"build": "browserify client.js > bundle.js" | ||
"build": "browserify client.js > bundle.js", | ||
"compare": "node compare.js" | ||
}, | ||
"dependencies": { | ||
"bel": "^4.6.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"bel": "^4.6.0", | ||
"browserify": "^14.3.0", | ||
@@ -20,4 +19,9 @@ "nanomorph": "^4.0.4", | ||
}, | ||
"homepage": "https://github.com/shuhei/pelo", | ||
"bugs": { | ||
"url": "https://github.com/shuhei/pelo/issues" | ||
}, | ||
"repository": "shuhei/pelo", | ||
"author": "Shuhei Kagawa <shuhei.kagawa@gmail.com>", | ||
"license": "ISC" | ||
} |
@@ -5,10 +5,28 @@ # pelo (work in progress) | ||
A tiny library that enables lightning fast server-side rendering with [hyperx](https://github.com/substack/hyperx)-like libraries such as `bel`, `yo-yo` and `choo/html`. It replaces the tag function of those libraries and just renders string without creating intermediate objects. | ||
## Installing | ||
```sh | ||
npm install pelo | ||
``` | ||
## Usage | ||
**TBD** | ||
`ssr.js`: Call `pelo.replace(moduleId)` before you require any view module, `bel` in this case. | ||
```js | ||
const html = require('pelo') | ||
const pelo = require('pelo') | ||
pelo.replace('bel') | ||
const view = require('./view') | ||
function helloView(name) { | ||
const renderedString = view('pelo').toString() | ||
``` | ||
`view.js`: You don't need to change your view files at all. You can use them for client-side rendering and server-side rendering. | ||
```js | ||
const html = require('bel') | ||
module.exports = function helloView(name) { | ||
return html`<p>Hello, ${name}</p>` | ||
@@ -15,0 +33,0 @@ } |
const http = require('http') | ||
const fs = require('fs') | ||
const pelo = require('.') | ||
pelo.replace('bel') | ||
const createApp = require('./app') | ||
const html = require('.') | ||
const app = createApp(html) | ||
const app = createApp() | ||
@@ -9,0 +10,0 @@ function layout (content) { |
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
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
70705
0
10
197
1
1
57
4
3
- Removedbel@^4.6.0
- Removedbel@4.6.0(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removedglobal@4.4.0(transitive)
- Removedhyperscript-attribute-to-property@1.0.2(transitive)
- Removedhyperx@2.5.4(transitive)
- Removedmin-document@2.19.0(transitive)
- Removednanoassert@1.1.0(transitive)
- Removedon-load@3.4.1(transitive)
- Removedprocess@0.11.10(transitive)