event-bus
event-bus copied to clipboard
No export default
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
- [X] Chrome
- [ ] Edge*
- [ ] Safari
- [ ] Firefox
- [ ] Opera
- [ ] IE
- [ ] Other
Platform
- [ ] Windows
- [ ] MacOS
- [ ] Linux
- [ ] Android
- [ ] iOS
- [ ] Other
Additional Information
No response
Odd, I'll take a look.
@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:
- Which build tool and version are you using (webpack 5, rollup 4, vite 5, etc...)?
- Are you using the named export
import { EventBus } from "@trutoo/event-bus";or are you attempting to use commonjs default requireconst 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.
Just cra. It's webpack 5. m1 Mac
Latest version v3.0.0 has resolved this issue. The following should work:
import { EventBus } from "@trutoo/event-bus";