question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

new Peer only works if using window.Peer in angular application

See original GitHub issue

Hi.

I am importing peerjs npm package into my client-side application vie plugins capability in webpack:

... let plugins = [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", Peer: "peerjs" ...

Until recently, I was able to just call var peer = new Peer(idService.generateId(), config.peerConfig); and the Peer object would be instantiated for me. Now with a recent update, only calling a window.Peer as a constructor results in expected behavior, while simply trying to call new Peer(... will result in Peer is not a constructor error.

Did I miss some change announcement or the way I import it is wrong for .ts-based peerjs implementation?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
maxpavlovcommented, Mar 24, 2019

@kidandcat you have a terrific intuition, man 👍

new webpack.ProvidePlugin({
		$: "jquery",
		jQuery: "jquery",
		Peer: ['peerjs','default']
	}),

Importing with default property specified has fixed the problem of having to use window.Peer. Thank you.

0reactions
kidandcatcommented, Mar 22, 2019

Are you doing this?

For importing the default export of an ES2015 module, you have to specify the default property of module.

See the Vue example:

          Vue: ['vue/dist/vue.esm.js', 'default']
Read more comments on GitHub >

github_iconTop Results From Across the Web

npm WARN ... requires a peer of ... but none is installed. You ...
npm WARN @angular/animations@4.3.6 requires a peer of @angular/core@4.3.6 but none is installed. You must install peer dependencies yourself.
Read more >
npm Peer Dependencies - JavaScript inDepth
Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular...
Read more >
npm-ci
An easy way to do this is to run, for example, npm config set legacy-peer-deps=true --location=project and commit the .npmrc file to your...
Read more >
Difference between dependencies, devDependencies and ...
Peer dependencies are only encountered when you publish your own package, that is, when you develop code that will be used by other...
Read more >
Creating libraries - Angular
Use the Angular CLI to generate a new library skeleton in a new workspace with the following ... Refactoring parts of an application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found