0

I'm using webpack with babel-loader to organize my webdriverio scripts. Since I'm writing automated web-site testing scripts, I don't have a production environment per-se, so the point of using webpack is really just to organize my code chunks better and transpile my es6 code to es5 since node does not allow all es6 features.

I have a script: "../../../external/file-search.js" which I am requiring at the top of an index.js file. The point of file-search.js is to search through the directory and require all files in that directory using fs. This is what my index.js file looks like (located in ~/tasks/):

var fileSearch = require("../../../external/file-search.js");

var d = __dirname;

fileSearch(d);

when I run "webpack tasks test.js" webpack compiles file-search.js into my "test.js" file rather than requiring file-search.js and allowing me to use it's exported method in my index.js file. I will use file-search.js in all my index.js files so it's important to include it as a module. I've tried using externals but as far as I know, externals simply exclude certain modules from being compile/transpiled and try to bundle them into the final script. I actually want to require that script and use it right away in my index.js file. How can I require file-search.js and use it right away as part of my index.js file?

mags
  • 590
  • 1
  • 8
  • 25
  • This seems to have the answer. Looking in to it. http://stackoverflow.com/questions/29168433/es6-variable-import-name-in-node-js – mags Oct 15 '16 at 19:11
  • solved: https://webpack.github.io/docs/context.html – mags Oct 16 '16 at 05:39

0 Answers0