webpack: certain complex dependency chains don't resolve
Do you want to request a feature or report a bug? bug
What is the current behavior?
in certain circumstances calling require('stream').Transform
give an object
If the current behavior is a bug, please provide the steps to reproduce.
see this repo
What is the expected behavior? it should be a Transform stream constructor If this is a feature request, what is motivation or use case for changing the behavior?
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System. webpack@2.2.1
split off from #272 also see nodejs/readable-stream#237
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
I spent many hours in the relevant webpack code yesterday. I do not think there is anything special about streams to set this up. (I’ll try to create a repo to demonstrate it without streams.)
To create a module, webpack first puts an empty object in the cache, then it begins executing the code to fill in
module.exports
. In the problem case, the dependency chain leads to another call to create this first module. At that point, webpack finds the module in the cache and returns it, but that is still the empty object because the code that fills in the exports is still loading the dependencies.If webpack were to check that the module had been loaded instead of just in the cache, it would see
module.l
is false.This webpack template code is the function controlling all this.
confirmed as well and updated the demo repo, you don’t even need through2, calling
gives an empty object for TransformStream