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

Fix: Module not found: node-fetch #524

Merged
merged 1 commit into from
Jan 28, 2021
Merged

Fix: Module not found: node-fetch #524

merged 1 commit into from
Jan 28, 2021

Conversation

Baarsgaard
Copy link
Contributor

@Baarsgaard Baarsgaard commented Jan 27, 2021

Since the fetch implementation is figured out at runtime as described here.
I'd like to add the "browser" field to the package.json too in order to fix bundlers like webpack.
You can see more about the "browser" field here.

In short, this is a better fix than modifying (in my case non-existent) tsconfig.json

image

Since the fetch implementation is figured out at runtime as described [here](https://github.com/openzipkin/zipkin-js#typescript).
I'd like to add the `"browser"` field to the `package.json` too in order to fix bundlers like webpack.
You can see more about the `"browser"`field [here](https://github.com/defunctzombie/package-browser-field-spec).

In short, this is a better fix than modifying (in my case non-existent) `tsconfig.json`
For now my workaround was adding the `"browser"` field to my projects own `package.json`
@jcchavezs
Copy link
Contributor

Thanks @Raunow for the fix and the details. Any input on this @anuraaga?

@jcchavezs
Copy link
Contributor

Is this also related to #465?

@Baarsgaard
Copy link
Contributor Author

Baarsgaard commented Jan 27, 2021

Is this also related to #465?

Short answer no, long answer:

As far as I can tell, it's not the same issue.
As long as you don't use the following functions:

os.userInfo()
os.getPriority()
os.version()
os.setPriority(0)

No errors will be thrown by an up-to-date chromium based browser.
And I didn't get any errors from webpack with require('os'), unlike require('node-fetch').

For reference the Zipkin npm package only makes use of os.networkInterfaces()

That said, it could possible solve the problem as os.networkInterfaces() just returns an empty object { } in browsers.

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to make sense, thanks

@jcchavezs jcchavezs merged commit 735dc61 into openzipkin:master Jan 28, 2021
@jcchavezs
Copy link
Contributor

Thanks @Raunow I will publish a release very soon but in case you want to try the package, you can use the canary release:

A new version of the package zipkin-transport-http (0.22.1-alpha.5) was published at 2021-01-28T14:14:12.467Z from
35.196.72.151. The shasum of this package was ec6aef17241f32dbf9f90a3b101f9db742496a0f.

@Baarsgaard Baarsgaard deleted the patch-1 branch January 28, 2021 15:22
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

Successfully merging this pull request may close these issues.

3 participants