├── .gitignore ├── index.js ├── yarn.lock ├── package.json ├── LICENSE └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // DEPRECATED DO NOT INSTALL -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | hyperapp@^0.9.2: 6 | version "0.9.3" 7 | resolved "https://registry.yarnpkg.com/hyperapp/-/hyperapp-0.9.3.tgz#f2613c7ac0530c14323f2200e9e4be87ff38ffb1" 8 | 9 | prettier@^1.5.2: 10 | version "1.5.2" 11 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.5.2.tgz#7ea0751da27b93bfb6cecfcec509994f52d83bb3" 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hyperapp-webpack-hmr", 3 | "description": "Maintain state during Webpack HMR", 4 | "author": "Andy Johnson ", 5 | "version": "1.1.4", 6 | "license": "MIT", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/andyrj/hyperapp-webpack-hmr.git" 10 | }, 11 | "keywords": [ 12 | "hyperapp", 13 | "plugin", 14 | "webpack", 15 | "hmr", 16 | "state" 17 | ], 18 | "scripts": { 19 | "format": "prettier --write \"./*.js\"" 20 | }, 21 | "devDependencies": { 22 | "hyperapp": "^0.10.1", 23 | "prettier": "^1.5.2" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Andy Johnson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # hyperapp-webpack-hmr 3 | 4 | > *DEPRECATED* Readme now contains example usage of hyperapp with webpack-hmr, this package is no longer needed 5 | 6 | ## Example Usage 7 | 8 | 1. Setup webpack for hmr as specified in their documentation. 9 | 10 | 2. Basically you need to make it so your whole app will be re-instantiated on top of your currently rendered output which will use the built-in hydration. The only requirement of your app is you provide a getState() action that returns the current state for access in our module.hot code. 11 | ```js 12 | /* myApp.js */ 13 | var { h, app } = require('hyperapp') 14 | module.exports = function myApp(initState) { 15 | return app( 16 | initState, 17 | { 18 | getState: () => state => state, 19 | increment: () => state => ({ count: state.count + 1 }), 20 | decrement: () => state => ({ count: state.count - 1}) 21 | }, 22 | (state) => h("div", {}, count) 23 | ); 24 | } 25 | ``` 26 | To complete the hmr setup your entry point should have something like the following. 27 | ```js 28 | /* index.js */ 29 | var myApp = require('./myApp') 30 | 31 | var appActions = myApp({ count: 0 }) 32 | 33 | if (module.hot) { 34 | module.hot.accept('./myApp', function(){ 35 | appActions = myApp(appActions.getState()) 36 | }) 37 | } 38 | 39 | ``` 40 | --------------------------------------------------------------------------------