Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 fails to load in @web/test-runner #513

Closed
tpluscode opened this issue Mar 31, 2023 · 5 comments
Closed

v4 fails to load in @web/test-runner #513

tpluscode opened this issue Mar 31, 2023 · 5 comments

Comments

@tpluscode
Copy link

I started receiving this error when trying to run my tests:

Could not resolve import "stream"

I traced this to a dependency which now uses v4 of readable-stream. In the module lib/ours/index.js there is a const Stream = require('stream')

Why import the built-in?

@mcollina
Copy link
Member

so that instanceof Stream would work. But maybe we should soft-detect if that's available and fall back to our implementation.

@mcollina
Copy link
Member

Would you like to send a PR?

@tpluscode
Copy link
Author

Happy to, although I'm not sure what the fix would entail. How would you "soft-detect" in a way which avoid the import?

@kanongil
Copy link

I expect you can surround the require in try/catch:

try {
    var Stream = require('stre' + 'am');
}
catch (err) {}

This will make the Stream value undefined both if require is undefined and if it fails to find the 'stream' module.

Additionally, I changed the import to a "computed" value so that tooling will leave it alone.

@tpluscode
Copy link
Author

To be honest, I'm at a loss here. I think I will close the issue for now as it likely exposes some other problem with rollup or @web/test-runner which not necessarily caused by readable-stream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants