Skip to content
Discussion options

You must be logged in to vote

Both are real, supported ways to ship PeerJS - they are just two different build formats for two different workflows, and the errors you hit come from mixing them up. You can confirm all of this from the package's own build config (package.json targets plus the lib/global.ts / lib/exports.ts sources on the repo).

The npm package = ES/CJS modules for a bundler.
package.json points its module / main / types fields at dist/bundler.mjs, dist/bundler.cjs and dist/types.d.ts, all built from lib/exports.ts. That file has the real named exports (Peer, PeerError, and type-only exports like DataConnection, MediaConnection, PeerOptions, etc.). This is what makes import { Peer, DataConnection } from …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vindicatorr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants