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

NPM packages are missing "esm" and "esnext" builds #2843

Closed
domasx2 opened this issue Mar 18, 2022 · 0 comments · Fixed by #2844
Closed

NPM packages are missing "esm" and "esnext" builds #2843

domasx2 opened this issue Mar 18, 2022 · 0 comments · Fixed by #2844
Labels
bug Something isn't working

Comments

@domasx2
Copy link
Contributor

domasx2 commented Mar 18, 2022

Please answer these questions before submitting a bug report.

What version of OpenTelemetry are you using?

1.10

What version of Node are you using?

v14.18.3

Please provide the code you used to setup the OpenTelemetry SDK

import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { DocumentLoadInstrumentation } from '@opentelemetry/instrumentation-document-load';
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';

const provider = new WebTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

registerInstrumentations({
  instrumentations: [new DocumentLoadInstrumentation()],
});

What did you do?

  • Installed latest (1.1.0) version of otel deps
  • Added example setup snippet
  • Tried to build app (using Parcel)

What did you expect to see?

I expected my app to build

What did you see instead?

Error:

@parcel/resolver-default: Could not load './build/esm/index.js' from module
'@opentelemetry/sdk-trace-web' found in package.json#module
  /Users/bogdan/Workspace/Grafana/grafana-javascript-agent/node_modules/@opentelemetry/sdk-trace-web/package.json:6:13
    5 |   "main": "build/src/index.js",
  > 6 |   "module": "build/esm/index.js",
  >   |             ^^^^^^^^^^^^^^^^^^^^ './build/esm/index.js' does not exist, did you mean './build/src/index.js'?'
    7 |   "esnext": "build/esnext/index.js",
    8 |   "types": "build/src/index.d.ts",

It seems most @opentelemtry packages only have build/src, but are missing esm and esnext builds.

Additional context

Quick investigation found:

  • Each package has a tsconfig.all.json that would build all versions of the package
  • Root compile command uses ts --build
  • Root tsconfig.json has references to each package directory only, thus each package is built using it's default tsconfig.json which only builds the commonjs module. Therein lies the issue

Possible solutions:

  • modify root tsconfig.json references to point to tsconfig.all.json for each package
  • Modify root compile command to lerna run compile instead of ts --build
@domasx2 domasx2 added the bug Something isn't working label Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant