From 22094cd0eabd4a6be71ba3a9f27b1495511e338b Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Tue, 16 May 2017 13:29:58 -0400 Subject: [PATCH] change name, prepare for release --- .npmignore | 5 ++++- LICENSE.md | 2 +- README.md | 42 +++++++++++++++++++++--------------------- contributing.md | 4 ++-- package.json | 10 +++++----- 5 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.npmignore b/.npmignore index fea554a..c37fa09 100644 --- a/.npmignore +++ b/.npmignore @@ -5,4 +5,7 @@ coverage .nyc_output yarn.lock .travis.yml -rollup.config.js +rollup.browser.js +rollup.ast-vdom.js +src +!lib diff --git a/LICENSE.md b/LICENSE.md index ea963e4..04de21c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ License (MIT) ------------- -Copyright © 2017 reshape +Copyright © 2017 Jeff Escalante Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index a689b4d..6a0627e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Reshape Preact SSR +# Reshape Preact Components -[![npm](https://img.shields.io/npm/v/reshape-preact-ssr.svg?style=flat-square)](https://npmjs.com/package/reshape-preact-ssr) -[![tests](https://img.shields.io/travis/reshape/preact-ssr.svg?style=flat-square)](https://travis-ci.org/reshape/preact-ssr?branch=master) -[![dependencies](https://img.shields.io/david/reshape/preact-ssr.svg?style=flat-square)](https://david-dm.org/reshape/preact-ssr) -[![coverage](https://img.shields.io/codecov/c/github/reshape/preact-ssr.svg?style=flat-square)](https://codecov.io/gh/reshape/preact-ssr) +[![npm](https://img.shields.io/npm/v/reshape-preact-components.svg?style=flat-square)](https://npmjs.com/package/reshape-preact-components) +[![tests](https://img.shields.io/travis/reshape/preact-components.svg?style=flat-square)](https://travis-ci.org/reshape/preact-components?branch=master) +[![dependencies](https://img.shields.io/david/reshape/preact-components.svg?style=flat-square)](https://david-dm.org/reshape/preact-components) +[![coverage](https://img.shields.io/codecov/c/github/reshape/preact-components.svg?style=flat-square)](https://codecov.io/gh/reshape/preact-components) Render preact components to static html and use them like custom elements. @@ -11,7 +11,7 @@ Render preact components to static html and use them like custom elements. ### Installation -`yarn add reshape-preact-ssr` +`yarn add reshape-preact-components` ### Usage @@ -20,7 +20,7 @@ Setup is pretty simple -- just add the plugin to reshape and pass it an object w ```js const {h} = require('preact') const reshape = require('reshape') -const ssr = require('reshape-preact-ssr') +const renderComponents = require('reshape-preact-components') const MyComponent = ({ foo }) => { return h('p', {}, `the value of foo is "${foo}"`) @@ -28,7 +28,7 @@ const MyComponent = ({ foo }) => { const html = "" -reshape({ plugins: [ssr({ 'my-component': MyComponent })] }) +reshape({ plugins: [renderComponents({ 'my-component': MyComponent })] }) .process(html) .then((res) => { console.log(res.output()) //

the value of foo is "bar"

@@ -56,13 +56,13 @@ export default class SortableList { } ``` -Now you set up the component through the ssr plugin as such: +Now you set up the component through the plugin as such: ```js -const ssr = require('reshape-preact-ssr') +const renderComponents = require('reshape-preact-components') const SortableList = require('./sortable-list') -ssr({ 'sortable-list': SortableList }) +renderComponents({ 'sortable-list': SortableList }) ``` And now in your html, you'd put down something like this: @@ -103,7 +103,7 @@ render( ) ``` -Ok so this works, but now we have some seriously non-DRY code. Now our markup has to be repeated both in our html for the initial static render, and in the client-side js for the client render. Luckily, reshape-preact-ssr has got your back. By default, it takes the initial html you used to render your preact element, parsed into a reshape AST and compressed as efficiently as possible, and gives it to your element as a prop called `_ssr`. It also provides a helper that you can use to decompress and hydrate it into a vdom tree that can be directly rendered by preact. So let's take advantage of this in our code and completely cut out all repetition - starting with our component. +Ok so this works, but now we have some seriously non-DRY code. Now our markup has to be repeated both in our html for the initial static render, and in the client-side js for the client render. Luckily, `reshape-preact-components` has got your back. By default, it takes the initial html you used to render your preact element, parsed into a reshape AST and compressed as efficiently as possible, and gives it to your element as a prop called `_state`. It also provides a helper that you can use to decompress and hydrate it into a vdom tree that can be directly rendered by preact. So let's take advantage of this in our code and completely cut out all repetition - starting with our component. What we'll do here is put our compressed initial state on a data attribute so that our client-side js can pick it up and hydrate: @@ -111,7 +111,7 @@ What we'll do here is put our compressed initial state on a data attribute so th export default class SortableList { render () { return ( -