trutoo / event-bus

Typesafe cross-platform pubsub event bus ensuring reliable communication between fragments and micro frontends.
https://trutoo.github.io/event-bus
MIT License
144 stars 9 forks source link

No export default #103

Open templar820 opened 5 months ago

templar820 commented 5 months ago

Description

In 2.2.0 all working correctly

Steps to reproduce

import {EventBus} from "@trutoo/event-bus";

const eventBus = new EventBus();

function App() {

  useEffect(() => {
    eventBus.register('namespace:eventName', { type: 'string' });
    const sub = eventBus.subscribe<boolean>('namespace:eventName', ({payload}) => {
      console.log(payload);
    });
    return () => {
      sub.unsubscribe();
    }
  },[])

Error EventBus is not exported. In 2.2.0 all working correctly

Library Version

2.3.0

Browser

Platform

Additional Information

No response

Swiftwork commented 5 months ago

Odd, I'll take a look.

Swiftwork commented 5 months ago

@templar820 Thanks for bringing this to our attention. When we upgraded the dependencies rollup CommonJS changed how they handled exports. It no longer includes esModule boolean:

Object.defineProperty(exports, '__esModule', { value: true });

So it is likely that your build system isn't happy with this change. To help us reproduce and resolve this issue could you please provide us with the following information:

  1. Which build tool and version are you using (webpack 5, rollup 4, vite 5, etc...)?
  2. Are you using the named export import { EventBus } from "@trutoo/event-bus"; or are you attempting to use commonjs default require const EventBus = require('@trutoo/event-bus');

We attempted to reproduce your error in a sandbox, but saw no errors https://codesandbox.io/p/sandbox/event-bus-test-92spz4. Try implementing something similar and see if that works.

Until we can resolve your issue feel free to keep using 2.2.0 as very little has changed between the versions other than the build process.

templar820 commented 5 months ago

Just cra. It's webpack 5. m1 Mac