Closed okonet closed 9 years ago
Same applies to extensions.
Having require('MyComponent')
will throw an error in wallaby even if I have in webpack.config:
resolve: {
extensions: ['.js', '.jsx']
}
I've added a test case as well
Hi,
Wepback postprocessor supports modulesDirectories
and other resolve
options.
I have pushed a couple of changes to the wallaby config to fix these two issues.
Regarding the first issue with bower_components
:
You had a typo (missing 's' in the modules folder name).
Anyway, when the folder is referenced by a relative path, you had a correct assumption that you need to include { pattern: 'bower_components/**/*.js', instrument: false, load: false }
to your files list. It would have worked for you, however, you restricted the pattern to include js files only ('bowercomponents/*/_.js'), so package bower.json file was not copied over to wallaby cache. It meant that this plugin new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
couldn't find the module entry point, as bower.json
was missing.
An easier and faster solution is to avoid specifying bower_components in the files list and just reference them by an absolute path:
resolve: {
modulesDirectories: [path.join(__dirname, 'bower_components')],
extensions: ["", ".js", ".jsx"]
}
I have added the documentation section to sum it up for future reference.
Regarding the second issue with jsx
extension, I have tried adding and empty string to the list:
extensions: ["", ".js", ".jsx"]
and it worked. I'm not sure exactly why webpack needs it, but according to its docs, an empty string is in a list of the default values for extensions.
Thanks for the help. Now working! Finally! :)
On 23.04.2015, at 04:17, Artem Govorov notifications@github.com wrote:
Hi, I have pushed changes to wallaby config to fix these issues.
Regarding the first issue with bower_components:
You had a typo (missing 's' in the modules folder name). Anyway, when the folder is referenced by a relative path, you had a correct assumption that you need to include { pattern: 'bowercomponents/*/_.js', instrument: false, load: false } to your files list. It would have worked for you, however, you restricted the pattern to include js files only ('bower_components/*/.js'), so package bower.json file was not copied over to wallaby cache. It meant that this plugin new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"]) couldn't find the module entry point, as bower.json was missing.
An easier and faster solution is to avoid specifying bower_components in the files list and just reference them by an absolute path:
resolve: { modulesDirectories: [path.join(__dirname, 'bower_components')], extensions: ["", ".js", ".jsx"] } I have added the documentation section to sum it up for future reference.
Regarding the second issue with jsx extension, I have tried adding and empty string to the list:
extensions: ["", ".js", ".jsx"] and it worked. I'm not sure exactly why webpack needs it, but according to its docs, an empty string is in a list of the default values for extensions.
— Reply to this email directly or view it on GitHub.
In webpack you can configure where to search for modules: http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories
require
For example, then having
moment
module installed via bower intobower_components
, I getTest run failure: Error: Cannot find module "moment"
from wallaby even having this in mywallaby.config.js
: