Until the move to Typescript, the peerjs repo could have been used just like any other NPM depenency. Simply add dependency as "peerjs": "git+https://github.com/peers/peerjs.git" and it would get compiled into /node_modules/peerjs/dist/peer.js.
Thus a node application that is using the dependency could have easily imported it into an application and use peer.
However, with move to TS, we have a non-required postinstall
tasks that break the usage in such scenario with an error (just try to clone use the current repo as a dependency via git and you'll know what I mean). Furthermore, even in we fork the current peerjs repo and remove postinstall
, it still doesn't have an install or build tasks that would result in the creation of "dist/peer.js" file.
So my suggestion is to add those build tasks.
A Question - now with current repo configuration, how do I build the peerjs library into dist/peer.js?
Thanks.
@Caballerog
Selenium was removed from postinstall. Grunt tasks should work fine. Could you try with latest version? 0.3.19
Also to answer your question, the build is still done with grunt, it is in gruntfile.js. The main task is ts (typescript). After that are some minifying tasks.
To build you just need to use grunt, the best way is npx grunt
.
@kidandcat
Apologies for reopening a closed issue, but I still can't use PeerJS as a module... To reproduce:
yarn create react-app my-app
yarn add peerjs
src/App.js
and add:import Peer from "peerjs";
// ...
class App extends Component {
componentDidMount() {
const peer = new Peer('peer-id', {});
}
// ...
}
yarn start
if you browse to http://localhost:3000 you will get:
TypeError: peerjs__WEBPACK_IMPORTED_MODULE_9___default.a is not a constructor
As @xavierfuentes said -> Issue is still present. To reproduce:
ng new app
npm install --save peerjs
import * as Peer from 'peerjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'app';
ngOnInit(): void {
new Peer('123', {})
}
}
ERROR TypeError: peerjs__WEBPACK_IMPORTED_MODULE_2__ is not a constructor
Sorry for the delay, [email protected] should fix the issue
This issue is still unresovled, sorry.
Most helpful comment
@kidandcat
Apologies for reopening a closed issue, but I still can't use PeerJS as a module... To reproduce:
yarn create react-app my-app
yarn add peerjs
src/App.js
and add:yarn start
if you browse to http://localhost:3000 you will get:
TypeError: peerjs__WEBPACK_IMPORTED_MODULE_9___default.a is not a constructor