Created
November 8, 2017 05:55
-
-
Save fuchao2012/777a6a9a83e308d07f3cd81bca74493d to your computer and use it in GitHub Desktop.
great export function
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
exports = module.exports = webpack | |
const exportsFn = (obj, mappings)=>{ | |
Object.keys(mappings).forEach(prop=>{ | |
Object.defineProperty(obj, prop, { | |
configurable: false, | |
enumerable: true, | |
get: mappings[prop] | |
}) | |
}) | |
} | |
exportsFn(exports, { | |
"module1": ()=>require('path/to/module1'), | |
"module2": ()=>require('path/to/module2'), | |
"module3": ()=>require('path/to/module3'), | |
"module4": ()=>require('path/to/module4'), | |
"module5": ()=>require('path/to/module5'), | |
"module6": ()=>require('path/to/module6'), | |
"module7": ()=>require('path/to/module7'), | |
"module8": ()=>require('path/to/module8'), | |
"module9": ()=>require('path/to/module9'), | |
"module10": ()=>require('path/to/module10'), | |
"module11": ()=>require('path/to/module11') | |
}) | |
// output as | |
const module1 = require('path/to/module1') | |
module.exports = module1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment