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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring for V2 #926

Merged
merged 3 commits into from
Feb 19, 2022
Merged

Conversation

afrokick
Copy link
Member

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


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
Copy link
Member Author

Any thoughts about V2 are welcome!

@afrokick afrokick added this to the 2.0.0 milestone Feb 19, 2022
@afrokick afrokick changed the base branch from master to releases/2.0.0 February 19, 2022 22:43
@afrokick afrokick changed the title Release 2.0 Refactoring for V2 Feb 19, 2022
@afrokick afrokick merged commit c8a0db3 into peers:releases/2.0.0 Feb 19, 2022
@afrokick afrokick deleted the refactoring/target-es6 branch February 19, 2022 22:44
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

1 participant