You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
I'm not sure what I'm doing wrong but for some reason, if I try to lazily load JSON files using this loader, webpack interprets the generated loading code as if it were JSON too and tries to parse it.
This happens using Webpack 4.1.1
I assume it's because the name of the resource bundle-loader generates ends with .json too. (eg. ./node_modules/bundle-loader?lazy&name=file-[name]!./json-files/a.json)
Sadly I haven't found a way to do that for bundle-loader-loaded JSON files only (resourceQuery can be used but you'd need to flag every use of bundle-loader in your codebase)
Adding the following code snippet just before return result.join(""); resolves the issue but it is not nice. I don't know how to property get the generator and parser instance:
if (this._module.type !== "javascript/auto") {
this._module.type = "javascript/auto";
for (var i = 0, ii = this._compilation.modules.length; i < ii; i++) {
if (this._compilation.modules[i].type === "javascript/auto") {
this._module.generator = this._compilation.modules[i].generator;
this._module.parser = this._compilation.modules[i].parser;
break;
}
}
}
Is there a better api to get the instance other then searching in the other modules?
Activity
ephys commentedon Mar 14, 2018
If anyone else is encountering the same bug, my current workaround is to go back to using to
json-loader:Sadly I haven't found a way to do that for
bundle-loader-loaded JSON files only (resourceQuery can be used but you'd need to flag every use of bundle-loader in your codebase)rmja commentedon Apr 13, 2018
I think this is related to webpack/webpack#6572, as applying webpack/webpack#6572 (comment) fixes the issue.
rmja commentedon Jul 3, 2018
Adding the following code snippet just before return result.join(""); resolves the issue but it is not nice. I don't know how to property get the generator and parser instance:
Is there a better api to get the instance other then searching in the other modules?
Support json modules
Support json modules