signalfx / splunk-otel-js-web

Splunk distribution of Open Telemetry for browser environment.
Apache License 2.0
48 stars 31 forks source link

Webpack is using cjs files instead of esm #397

Open seanparmelee opened 2 years ago

seanparmelee commented 2 years ago

For context, I'm using NextJS and following the instructions here to instrument the @splunk/otel-web package. While using @next/bundle-analyzer, I noticed that the @splunk/otel-web/dist/cjs files are being pulled in. I was hoping to see the @splunk/otel-web/dist/esm files being used so that Webpack can tree shake off the modules that @splunk/otel-web is not using.

It looks like the reason the CJS files are being used is because Webpack checks the browser field of the package.json first by default and currently it contains:

  "browser": "dist/cjs/index.js",
  "module": "dist/esm/index.js",

I was wondering if the team would be open to:

I'm happy to open a PR.

jtmal-signalfx commented 2 years ago

We talked about this offline, but I still think we want to fix this issue. I'll add it to our internal backlog.