directory-named-webpack-plugin
directory-named-webpack-plugin copied to clipboard
Doesn't resolve when using HMR
Let's say I have a folder in source folder named Component and two files inside it: index.js and Component.js. Configuration looks like so:
extensions: ['*', '.js', '.jsx', '.json'],
plugins: [
new DirectoryNamedWebpackPlugin(true),
],
When I start Webpack everything works as expected, index.js file is loaded. But when I remove index.js file I expect Component.js to be loaded, but instead it still tries to load index.js file. It works as expected if I restart Webpack though. But I want this to be working correctly with Webpack Dev Server and HMR.
What am I doing wrong?
Any updates on this?
Sorry, somehow I missed this.
From what I understand, I think this is an issue of Webpack. I feel Webpack caches the resolved path for a given import path and doesn't use the resolver to resolve the path again with HMR.
From what I understand, I think this is an issue of Webpack. I feel Webpack caches the resolved path for a given import path and doesn't use the resolver to resolve the path again with HMR.
Perhaps something as simple as delete require.cache[path].
Just an idea, we're not having the issue.
Thanks for the idea. Actual require call is done by Webpack, this plugin only tells Webpack which file should be loaded for a given import/require. I didn't check the source code of Webpack but I suspect it probably is not using require as Node interpret things as JavaScript, but Webpack supports loading all kinds of things.