Created
January 24, 2017 19:52
-
-
Save cmawhorter/33e2c9d305ca4b4b910a5f366089cb2a to your computer and use it in GitHub Desktop.
rollup lazy top scope for node deps thoughts
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
let nodeDeps = {}; | |
let nodeCache = {}; | |
// some dependency | |
Object.defineProperty(nodeDeps, 'some_module', { | |
get: () => { | |
if (process.argv[2] !== 'hello') throw new Error('hello must be first argument'); | |
const nodeModule = nodeCache.some_module || { world: () => console.log('world') }; | |
return nodeModule; | |
} | |
}); | |
// e.g. src/main.js | |
nodeDeps.some_module.world(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment