1

How can I import all files in a folder using ES6 modules tools?

need something like:

files.forEach(function (file){
  import * as object from 'file';
}};
3
  • 2
    What is it you're actually trying to do with these imported files? The short answer is "that won't work" with ES6 module syntax but it's hard to give more meaningful feedback with no other info to go on. Mar 23, 2016 at 6:25
  • If you want to migrate current project with many modules, amd you lookin for fast&dirty solution, try use require(): /** * Requires all directives from subdirectories. */ function requireAll(requireContext) { return requireContext.keys().map(requireContext); } requireAll(require.context("<path to sub dir>", true, /^\.\/.*\.js$/)); stackoverflow.com/questions/35343362/…
    – DanDuh
    Mar 23, 2016 at 10:04
  • I'm just trying create one npm package, which will manipulate users modules. I can know the folder were will be all the modules, but i can't now files and variables names. Mar 23, 2016 at 15:22

0