Created
March 20, 2017 22:23
-
-
Save gsathya/7647bf81374c17782ff306da2e272b50 to your computer and use it in GitHub Desktop.
dynamic import
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
// Original: | |
import("module/id").then(...); | |
// Node.js (synchronous require; easy): | |
Promise.resolve().then(_ => require("module/id")).then(...); | |
// AMD (async require; non-standard): | |
new Promise(resolve => require("module/id", resolve)).then(...); | |
// Webpack 2 (require.ensure is Webpack-specific): | |
new Promise(resolve => { | |
require.ensure(["module/id"], require => { | |
resolve(require("module/id")); | |
}); | |
}).then(...); | |
// Meteor 1.5: | |
module.dynamicImport("module/id").then(…); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment