https://github.com/bcomnes/uland-isomorphic
Isomorphic exports of uland
https://github.com/bcomnes/uland-isomorphic
Last synced: about 1 year ago
JSON representation
Isomorphic exports of uland
- Host: GitHub
- URL: https://github.com/bcomnes/uland-isomorphic
- Owner: bcomnes
- License: mit
- Created: 2021-09-06T19:14:22.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T18:23:31.000Z (over 1 year ago)
- Last Synced: 2025-03-29T19:34:25.430Z (about 1 year ago)
- Language: JavaScript
- Size: 43.9 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE
Awesome Lists containing this project
README
# uland-isomorphic
[](https://github.com/bcomnes/uland-isomorphic/actions)
Isomorphic exports of [uland][uland]
```
npm install uland-isomorphic
```
## Usage
Use [uland][uland] or [uland-ssr][ssr] from a single import identifier depending on then environment you are running.
``` js
import {Component, render, html, useState} from 'uland-isomorphic';
const Counter = Component((initialState) => {
const [count, setCount] = useState(initialState);
return html`
setCount(count + 1)}>
Count: ${count}
`;
});
// basic example, show two independent counters
render(document.body, () => html`
A bounce of counters.
${Counter(0)} ${Counter(1)}
`);
```
## How
While @webreflection recomends [require-overrides](https://github.com/WebReflection/require-overrides/#readme) in the offical documentation, that requires special flags or transforms to work.
`uland-isomorphic` works by utilizing environment specific exports fields so that you can have dependency injection at the built-in module resolver layer.
It supports the following export fields:
- `main` (cjs node)
- `browser` (cjs browser)
- `exports.import` (esm node)
- `exports.reqire` (cjs node)
- `exports.browser` (esm browser)
## License
MIT
[uland]: https://github.com/WebReflection/uland
[ssr]: https://github.com/WebReflection/uland-ssr