Last active
August 25, 2018 09:54
-
-
Save SevInf/64b4221f7564e219db7bc502c2407356 to your computer and use it in GitHub Desktop.
HMR proxy module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1 | |
| import { export1, export2 } from './original.mjs?mtime=0'; | |
| import { hmrClient } from '/hmrClient.mjs'; | |
| // 2 | |
| let export1Proxy = export1; | |
| let export2Proxy = export2; | |
| // 3 | |
| export { | |
| export1Proxy as export1, | |
| export2Proxy as export2 | |
| }; | |
| // 4 | |
| hmrClient.onUpdate('original.mjs', (newMtime) => { | |
| // 5 | |
| import(`./original.mjs?mtime=${newMtime}`) | |
| .then(newExports => { | |
| // 6 | |
| export1Proxy = newExports.export1; | |
| export2Proxy = newExports.export2; | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment