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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export for commonjs #5

Merged
merged 1 commit into from May 19, 2023
Merged

Conversation

kearfy
Copy link
Contributor

@kearfy kearfy commented May 19, 2023

Description

Currently, commonjs projects will be hit with the following error:

/.../node_modules/unws/src/node.js:3
export { WebSocket }
^^^^^^

SyntaxError: Unexpected token 'export'

By replacing the export statement with module.export for the commonjs node.js fiel, I am quite positive that this PR should solve that issue.

I tested this on Node v16.16.0 & v18.14.2 with a commonjs and a module project and lastly with a nodejs (index.js) script and a typescript (index.ts) script via ts-node. All combinations of what I mentioned here.

Linked Issues

--

Additional context

I need this change somewhat urgently for a library that I'm maintaining as two people are stuck on this issue as of now. I made the change from isomorphic-ws as it's barely maintained and had caused issues for importing into certain environments. Ironically, this library is now also causing issues though I can see how this library is better than isomorphic-ws 馃槢

@stackblitz
Copy link

stackblitz bot commented May 19, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Owner

@sxzz sxzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. Merged!

@sxzz sxzz changed the title Fix export for commonjs fix: export for commonjs May 19, 2023
@sxzz sxzz merged commit 178f517 into sxzz:main May 19, 2023
2 checks passed
@kearfy kearfy deleted the fix-export-for-commonjs branch May 19, 2023 12:35
@kearfy
Copy link
Contributor Author

kearfy commented May 19, 2023

Thanks for your fast response @sxzz! Really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants