open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.74k stars 802 forks source link

from Terser Unexpected token punc «:», expected punc «,» #4034

Closed devgalintown closed 1 year ago

devgalintown commented 1 year ago

Discussed in https://github.com/open-telemetry/opentelemetry-js/discussions/4018

Originally posted by **devgalintown** July 24, 2023 Using "terser-webpack-plugin": "^4.2.3", in a Vue,js project. "webpack": "4.41.0", "webpack-bundle-analyzer": "^3.0.4", "webpack-cli": "3.3.12", "webpack-hot-middleware": "^2.25.3", "webpack-merge": "^4.2.2", "webpack-merge-and-include-globally": "^2.3.4", "webpack-node-externals": "^1.7.2", **Prod Config file structure:** new TerserPlugin({ parallel: true, extractComments: false, sourceMap: isDev, terserOptions:{ compress: isProd, ecma: 2020 }, }), It was all building okay before I added Opentelemetry instrumentation. **codebase is similar to this:** import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http' import { WebTracerProvider, BatchSpanProcessor, SimpleSpanProcessor, ConsoleSpanExporter } from '@opentelemetry/sdk-trace-web' import { registerInstrumentations } from '@opentelemetry/instrumentation' import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web' export default function initializeOtel() { const headers = { "Content-Type": "application/json" } const collectorOptions = new OTLPTraceExporter(headers) const provider = new WebTracerProvider() provider.addSpanProcessor(new BatchSpanProcessor(collectorOptions)) provider.register() const instrumentations = [ getWebAutoInstrumentations() ] registerInstrumentations(instrumentations) } Initialized in base vue file : beforeMount() { initializeOtel() } I tried removing terser package but still got the error. Tried ecma script version change, comma remove/add among other. Please help me figure this out. Thanks.
Flarna commented 1 year ago

The tooling you mention above seems to be quiet old. Could you try with up to date tooling?

There is also info missing which OTel version, which typescript version,... you use.

devgalintown commented 1 year ago

@Flarna you are suggesting to upgrade webpack and related dependencies?

Otel versions

"@opentelemetry/api": "^1.4.1", "@opentelemetry/auto-instrumentations-web": "^0.32.2", "@opentelemetry/context-zone": "^1.13.0", "@opentelemetry/exporter-trace-otlp-http": "^0.39.1", "@opentelemetry/instrumentation": "^0.39.1", "@opentelemetry/instrumentation-document-load": "^0.32.2", "@opentelemetry/instrumentation-user-interaction": "^0.32.3", "@opentelemetry/instrumentation-xml-http-request": "^0.39.1", "@opentelemetry/propagator-b3": "^1.13.0", "@opentelemetry/sdk-trace-web": "^1.13.0", "@opentelemetry/semantic-conventions": "^1.13.0",

I am using Vue.js :

"vue": "^2.7.14", "vue-analytics": "^5.22.1", "vue-carousel": "^0.7.3", "vue-clipboard2": "^0.3.1", "vue-date-dropdown": "^1.0.5", "vue-i18n": "^8.27.0", "vue-loader": "^15.10.1", "vue-multiselect": "^2.1.6", "vue-recaptcha": "^1.2.0", "vue-router": "^3.6.5", "vue-select": "^2.6.4", "vue-server-renderer": "^2.7.14", "vue-slick": "^1.2.0", "vue-slider-component": "2.7.7", "vue-social-sharing": "^2.4.7", "vue-style-loader": "^4.1.3", "vue-template-compiler": "^2.7.14", "vue-the-mask": "^0.11.1", "vue2-circle-progress": "^1.2.3", "vuejs-datepicker": "^1.6.2", "vuex": "^3.6.2", "vuex-router-sync": "^5.0.0",

Flarna commented 1 year ago

Yes, I was talking about updating webpack, vue, typescript. Typescript version is not mentioned above so don't know which you you use. e.g. vue 2.x goes EOL soon anyway.

I'm not familiar with all these tools but there was at least one issue recently where someone used a too old typescript version causes it's setup to fail.

devgalintown commented 1 year ago

@Flarna oh okay. typescript version: 2.5.3

Flarna commented 1 year ago

well, that version is 6 years old. OTel uses 4.4.4 as of new (already 2 years old).

I'm quite sure that such an old typescript version doesn't understand the type definitions emitted by 4.4.4.

I think a tooling update is needed to get compatibility.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stale for 14 days with no activity.