I've written a loader to handle JSON files with a schema that looks like this:
{
"imports": [
"some-loader!./subdir_1/a.json",
"some-loader!./subdir_2/b.json"
],
...
}
I'm using this.loadModule within my loader to handle the imports. The first imported module loads without issue, but I get an error on the second:
Module not found: Error: Can't resolve './subdir_2/b.json' in './subdir_1'
Note that the context being used for the resolve is subdir_1. I think this is down to this line in lib/dependencies/LoaderPlugin.js, where module is being replaced by dep.module. The module path is being resolved using the context of the last module that was loaded, rather than the context of the module that's doing the loading.
A workaround is to pass absolute paths to this.loadModule.
I think this applies to both webpack 1 and webpack 2.
I have a failing test and a proposed fix that I'll submit in a pull request.
Thanks for supporting an incredible tool!
I've written a loader to handle JSON files with a schema that looks like this:
{ "imports": [ "some-loader!./subdir_1/a.json", "some-loader!./subdir_2/b.json" ], ... }I'm using
this.loadModulewithin my loader to handle the imports. The first imported module loads without issue, but I get an error on the second:Note that the context being used for the resolve is
subdir_1. I think this is down to this line inlib/dependencies/LoaderPlugin.js, wheremoduleis being replaced bydep.module. The module path is being resolved using the context of the last module that was loaded, rather than the context of the module that's doing the loading.A workaround is to pass absolute paths to
this.loadModule.I think this applies to both webpack 1 and webpack 2.
I have a failing test and a proposed fix that I'll submit in a pull request.
Thanks for supporting an incredible tool!