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

Consider adding support for Webpack-bundled projects #100

Closed
keturiosakys opened this issue Jul 18, 2023 · 0 comments · Fixed by #137
Closed

Consider adding support for Webpack-bundled projects #100

keturiosakys opened this issue Jul 18, 2023 · 0 comments · Fixed by #137
Labels
enhancement New feature or request

Comments

@keturiosakys
Copy link
Member

Currently any/all Webpack supports will by default fail at build time as Webpack attempts to resolve Node-native libraries regardless that they're guarded for Node-only use. The Node-native libraries are: stream-http, url (used in the Prometheus Exporter that is bundled) and async_hooks that is used in the library itself.

The issue can be worked around by manually installing and setting up polyfills as documented in #40 and/or probably setting resolve.fallback values to false for the afore-mentioned Node-native libraries. However that is somewhat brittle, and will not work with a default create-react-app config.

We should investigate supporting Webpack without extra configuration if we're looking to support client-side Autometrics.


This is the full error that shows:

Module not found: Error: Can't resolve 'http' in '<USR_PATH>/react-repro/node_modules/@opentelemetry/exporter-prometheus/build/src'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }
ERROR in ./node_modules/@opentelemetry/exporter-prometheus/build/src/PrometheusExporter.js 25:15-30
Module not found: Error: Can't resolve 'http' in '<USR_PATH>/react-repro/node_modules/@opentelemetry/exporter-prometheus/build/src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
        - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "http": false }

ERROR in ./node_modules/@opentelemetry/exporter-prometheus/build/src/PrometheusExporter.js 28:14-28
Module not found: Error: Can't resolve 'url' in '<USR_PATH>/react-repro/node_modules/@opentelemetry/exporter-prometheus/build/src'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

ERROR in ./node_modules/@autometrics/autometrics/dist/index.mjs 53:12-33
Module not found: Error: Can't resolve 'async_hooks' in '<USR_PATH>/react-repro/node_modules/@autometrics/autometrics/dist'
@keturiosakys keturiosakys added the enhancement New feature or request label Jul 18, 2023
@arendjr arendjr linked a pull request Nov 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant