peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

Releases 2.0

Open afrokick opened this issue 3 years ago • 2 comments

Sorry, just copy&paste it from CHANGELOG because I want to sync it.


  • [ ] update docs
  • [ ] update readme

V2

The main goals of the second version:

  • modernize the code base: use es6 and latest tools;
  • target to the latest browsers API(you can use webrtc adapter to shim old browsers);
  • shrink the package size;

Breaking changes

Drop ES5 supports

If you need to support es5, you can recompile the lib from the sources or use the latest version from the v1 branch like npm i peerjs@1.

Remove webrtc-adapter package from dependencies

The modern browsers mostly works good without any additional libs like webrtc-adapter.

You can increase cross browsers support by manually add webrtc-adapter package to your project:

npm install webrtc-adapter

Then import it as soon as possible. For example, you have an entry point for your application in the file index.tsx. So, lets add the import:

import 'webrtc-adapter'; // as soon as possible

//
//... your startup code
//

See more: https://github.com/webrtcHacks/adapter

Remove browser detection features from the library.

The browser field was removed from the util class and the OFFER packet.

The main field of package.json now points to the non minified version.

Today, most projects use bundlers with a minification step. Sometimes, double minification can lead to issues.

If you want to use the minified version, use it directly from the dist folder like:

import Peer from 'peerjs/dist/peerjs.min.js';

...

Use ESBuild as bundler.

Parcel 1 was a good choice years ago, but now esbuild seems like simple and good solution!

Another changes

  • update devDependencies
  • apply Prettier for the code style

afrokick avatar Feb 19 '22 22:02 afrokick

npm i peerjs@beta published!

afrokick avatar Feb 20 '22 02:02 afrokick

I've been testing the latest beta.3 release for a new project and I'm loving the smaller package size. I did have problems using it in along with webpack though. When building for a web target (the default) webpack looks for the following package.json fields as entry points: browser, module, main using the first one it finds. With this 2.0 version the browser field points a JS file whose contents are wrapped in a IIFE and doesn't successfully export anything. All attempts to use the library fail until I do one of:

  • update webpack config to prefer module or main fields over browser
  • replace import Peer from 'peerjs'; with import 'peerjs' and rely on the Peer global it attaches to window

Neither of these are ideal. I'm not familiar with the specifics of the IIFE wrapper or the specific differences between the way all three of your builds are targeted, but I've never run into an issue like this before.

noahm avatar Sep 10 '22 07:09 noahm