Created
July 8, 2017 07:12
-
-
Save CodingPapi/3a37048f24953f40be227a4f8dbdc464 to your computer and use it in GitHub Desktop.
Node dynamic import modules
This file contains 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
ES6 specification doesn't seem to support the dynamic loading of modules: | |
function renderView(viewName) { | |
const view = require(path.join('./views', viewName)); | |
... | |
} | |
@kruncher dynamic module loads go through System | |
function renderView (viewName) { | |
System.import(path.join('./views', viewName)) | |
.then(view => ...) | |
.catch(error => console.error(error.stack)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment