Skip to content

Instantly share code, notes, and snippets.

@SevInf
Last active August 25, 2018 09:54
Show Gist options
  • Select an option

  • Save SevInf/64b4221f7564e219db7bc502c2407356 to your computer and use it in GitHub Desktop.

Select an option

Save SevInf/64b4221f7564e219db7bc502c2407356 to your computer and use it in GitHub Desktop.
HMR proxy module
// 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