evanderkoogh / otel-cf-workers

An OpenTelemetry compatible library for instrumenting and exporting traces for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
208 stars 39 forks source link

Broken with tsx #143

Closed jasonkuhrt closed 1 month ago

jasonkuhrt commented 1 month ago

When trying to run tsx on code that imports this library the following error happens:

/Users/jasonkuhrt/projects/prisma/pdp-control-plane/node_modules/.pnpm/@microlabs+otel-cf-workers@1.0.0-rc.39/node_modules/@microlabs/otel-cf-workers/src/spanprocessor.ts:4
import { Action, State, stateMachine } from 'ts-checked-fsm'
                        ^

SyntaxError: The requested module 'ts-checked-fsm' does not provide an export named 'stateMachine'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

Node.js v20.12.2

It actually appears to be coming from Node.

I've bee looking at this and ts-checked-fsm package but do not see what the issue is yet.

jasonkuhrt commented 1 month ago

When I change the import to the following and log it:

import * as x from 'ts-checked-fsm';

I get:

[Module: null prototype] { default: { stateMachine: [Function: n] } }

so, its coming through as a default export, not a named export... hm 😕

This pnpm patch solves it for me:

CleanShot 2024-05-30 at 17 16 29@2x

jahands commented 1 month ago

Thanks for tracking this down! Should be fixed in 1.0.0-rc.40

jasonkuhrt commented 1 month ago

Happy it helped!

jasonkuhrt commented 1 month ago

@jahands resolved the issue thanks!