Skip to content

Commit 5c0ae13

Browse files
committed
Updates to underlying renderer
1 parent cb0d6f4 commit 5c0ae13

12 files changed

Lines changed: 79 additions & 25 deletions

File tree

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ assets/
22
documentation/
33
src/
44
rollup.config.js
5-
dom/src
65
test/
6+
coverage/
77
.travis.yml

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.5.0 - 2019-04-14
4+
- Add support for multiple renderers (JSX, Tagged Template Literals, HyperScript). Added direct imports or 'solid-js/dom' alternatives 'solid-js/html' and 'solid-js/h'.
5+
- Reorganized dependencies work.
6+
37
## 0.4.2 - 2019-03-18
48
- Add fallbacks for control flow
59
- Add new Portal Control Flow - This allows nodes to be rendered outside of the component tree with support for satelite ShadowRoots.

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ To use Solid with JSX (recommended) run:
4747
> npm install solid-js babel-plugin-jsx-dom-expressions
4848
```
4949

50+
You can also run Solid from the browser directly with your flavor of renderer found in the [Solid Standalone](https://github.com/ryansolid/solid-standalone) package.
51+
5052
## Solid State
5153

5254
It all starts with State. State objects are immutable so to update you call their companion setter function. Through the use of proxies they give the control of an immutable interface and the performance of a mutable one. Note only Plain Objects and Arrays are deeply wrapped.
@@ -113,9 +115,7 @@ onCleanup(() => unsubscribe());
113115

114116
## Solid Rendering
115117

116-
To accomplish rendering we use JSX for templating that gets compiled to native DOM element instructions. To do that we take advantage of the [Babel Plugin JSX DOM Expressions](https://github.com/ryansolid/babel-plugin-jsx-dom-expressions) which while converting JSX to DOM element instructions wraps expressions to be wrapped in our computations when indicated by in inner parens `{( )}`.
117-
118-
JSX as a templating language brings a lot of benefits. The just being javascript goes beyond just not needing a DSL, but setting up closure based context instead of creating context objects. This is more transparent and easier to follow and debug.
118+
Solid's rendering is done by the [DOM Expressions](https://github.com/ryansolid/dom-expressions) library. This library provides a generic optimized runtime for fine grained libraries like Solid with the opportunity to use a number of different Rendering APIs. The best option is to use JSX pre-compilation with [Babel Plugin JSX DOM Expressions](https://github.com/ryansolid/babel-plugin-jsx-dom-expressions) to give the smallest code size, cleanest syntax, and most performant code. The compiler converts JSX to native DOM element instructions and wraps expressions to be wrapped in our computations when indicated by in inner parens `{( )}`.
119119

120120
To get setup add this babel plugin config to your .babelrc, webpack, or rollup config:
121121

@@ -129,12 +129,14 @@ And include at the top of your files:
129129
import { r } from 'solid-js/dom'
130130
```
131131

132-
Or, if you prefer you can use HyperScript. It does come at signifigant performance hit, as it doesn't benefit from any of the compile time optimizations that set Solid apart in performance. But it is an option for those who want to avoid Babel or do not wish to use JSX. Even though it is much slower it is still in the performance category of most popular frameworks. There are some minor differences from how you would write typical HyperScript as you need to manually wrap expressions in functions to make them observable. More information available at [Dom Expressions](https://github.com/ryansolid/dom-expressions). Include Solid HyperScript by:
132+
Alternatively in non-compiled environments you can use Tagged Template Literals [Lit DOM Expressions](https://github.com/ryansolid/lit-dom-expressions) or even HyperScript with [Hyper DOM Expressions](https://github.com/ryansolid/hyper-dom-expressions).
133133

134+
For convenience Solid exports interfaces to runtimes for these as:
134135
```js
135-
import { h } from 'solid-js/dom'
136+
import { h } from 'solid-js/h';
137+
import { html } from 'solid-js/html'
136138
```
137-
With HyperScript it is possible to map to element functions or even tagged template literals which offer many different development experiences. See examples below.
139+
Remember you still need to install the library separately for these to work.
138140

139141
## Components
140142

@@ -225,7 +227,7 @@ I cover this in more detail in my Bring Your Own Framework Blog Series(links bel
225227
226228
* [State](../master/documentation/state.md)
227229
* [Signals](../master/documentation/signals.md)
228-
* [Rendering](../master/documentation/rendering.md)
230+
* [JSX Rendering](../master/documentation/rendering.md)
229231
* [API](../master/documentation/api.md)
230232
231233
## Examples

documentation/rendering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rendering
1+
# JSX Rendering
22

33
Rendering involves precompilation of JSX templates into optimized native js code. The JSX code constructs:
44
* Template DOM elements which are cloned on each instantiation

h/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "solid-js/h",
3+
"main": "../lib/h.js",
4+
"module": "../dist/h.js",
5+
"sideEffects": false
6+
}

html/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "solid-js/html",
3+
"main": "../lib/html.js",
4+
"module": "../dist/html.js",
5+
"sideEffects": false
6+
}

package-lock.json

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "solid-js",
33
"description": "A declarative JavaScript library for building user interfaces.",
4-
"version": "0.4.5",
4+
"version": "0.5.0",
55
"author": "Ryan Carniato",
66
"license": "MIT",
77
"repository": {
@@ -17,13 +17,13 @@
1717
"test": "npm run build && jest --coverage"
1818
},
1919
"dependencies": {
20-
"dom-expressions": "~0.6.0",
20+
"dom-expressions": "~0.7.1",
2121
"s-js": "~0.4.9"
2222
},
2323
"devDependencies": {
2424
"coveralls": "^3.0.3",
2525
"jest": "~24.7.1",
26-
"rollup": "^1.9.0",
26+
"rollup": "^1.10.0",
2727
"rollup-plugin-node-resolve": "^4.1.0"
2828
}
2929
}

rollup.config.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default [{
1414
external: ['s-js'],
1515
plugins
1616
}, {
17-
input: 'dom/src/index.js',
17+
input: 'src/dom/index.js',
1818
output: [{
1919
file: 'lib/dom.js',
2020
format: 'cjs'
@@ -24,4 +24,26 @@ export default [{
2424
}],
2525
external: ['s-js', 'dom-expressions'],
2626
plugins
27+
}, {
28+
input: 'src/dom/html.js',
29+
output: [{
30+
file: 'lib/html.js',
31+
format: 'cjs'
32+
}, {
33+
file: 'dist/html.js',
34+
format: 'es'
35+
}],
36+
external: ['solid-js/dom', 'lit-dom-expressions'],
37+
plugins
38+
}, {
39+
input: 'src/dom/h.js',
40+
output: [{
41+
file: 'lib/h.js',
42+
format: 'cjs'
43+
}, {
44+
file: 'dist/h.js',
45+
format: 'es'
46+
}],
47+
external: ['solid-js/dom', 'hyper-dom-expressions'],
48+
plugins
2749
}];

src/dom/h.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createHyperScript } from 'hyper-dom-expressions';
2+
import { r } from 'solid-js/dom';
3+
export { selectWhen, selectEach } from 'solid-js/dom';
4+
5+
export const h = createHyperScript(r);

0 commit comments

Comments
 (0)