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

Erroneous builds, parcelRequire, and manifestations of a bundling problem #859

Closed
StoneCypher opened this issue May 30, 2021 · 5 comments
Closed
Labels
Milestone

Comments

@StoneCypher
Copy link

Hiya.

Something's weirdly wrong with your build. I don't use parcel, so I don't know exactly what, but.

It appears that Parcel has an internal implementation of require called parcelRequire which isn't being put into your build, or is being put into your build in a way that isn't visible in all places, or perhaps is expected to be provided downstream.

You see a variety of strange manifestations of this when your users are using other bundlers:

I hit this myself. Here is a near-minimal build using rollup. Unfortuantely, you're looking through minified code. To find the correct location (line 21 column 890,) either copy pasta into a code editor, or search for parcelRequire=f,i)throw i;return f}({"EgBh"). The revealed selection starts (ie, parcelRequire=) at the throw.

I believe that this is either a timing or a scope visibility bug, on grounds that several people believe they are solving it by making a global with the correct name, at which point the throw goes away (ostensibly because it's now pointing at some irrelevant variable,) only to be replaced by a complaint that the needed constructor or some needed method doesn't exist on said throwaway.

jmonster suggests that the issue is merely the missing declaration of the outer scoped variable, and jlalmes provides a shim on the window object by matching name, which falls into scope through globality rules, but which would break on node.

It seems that this is expositional - in #761 the user is able to self-service by dealing with the scoped instance on the window global. Whatever the problem is is resolved by the time that member is bound.

Either way, parcel shouldn't be building. If it's a missing outer scope variable it should reject, and if it's being pushed before it's ready it should be being deferred.

∴ I believe your parcel configuration to be damaged.

It's worth noting that there's a possibly-related issue:

Strictly speaking this isn't related. However I would have expected a library like peerjs to be available to node, and right now it's requiring the window global, which is node-antithetical. If you expect parcel to be testing for that, or packing in a shim or a sham, it's not currently doing so.

@pankerit
Copy link

pankerit commented Jun 5, 2021

same error

@canotur
Copy link

canotur commented Aug 29, 2021

It is living error. Is there anyone can find a solution that?

@afrokick
Copy link
Member

@StoneCypher Thank you for the detailed issue.

In the next version we'll include esm/cjs files, so it'll suite for all cases.

NodeJS support already exists in beta. You can try it via npm i peerjs@beta

@afrokick afrokick added this to the 2.0.0 milestone Feb 20, 2022
@StoneCypher
Copy link
Author

StoneCypher commented Feb 21, 2022

I'm not interested in node. I just want this to work in a regular build.

Does the cjs build still have access to browser primitives?

How far out is 2?

Are you aware of anyone having this working in a regular build? This blocked me for a nine months. I went to a competitor

jonasgloning added a commit that referenced this issue Apr 27, 2022
- smaller bundle 
- better source maps
- improved bundler compatibility

Closes #845, #859, #552, #585
jonasgloning added a commit that referenced this issue Apr 27, 2022
- smaller bundle
- better source maps
- improved bundler compatibility

Closes #845, #859, #552, #585

.
github-actions bot pushed a commit that referenced this issue May 10, 2022
# [1.4.0](v1.3.2...v1.4.0) (2022-05-10)

### Bug Fixes

* add changelog and npm version to the repo ([d5bd955](d5bd955))
* add token to PeerJSOption type definition ([e7675e1](e7675e1))
* websocket connection string ([82b8c71](82b8c71))

### Features

* upgrade to Parcel@2 ([aae9d1f](aae9d1f)), closes [#845](#845) [#859](#859) [#552](#552) [#585](#585)

### Performance Improvements

* **turn:** lower TURN-latency due to more local servers ([a412ea4](a412ea4))
@jonasgloning
Copy link
Member

Thank you for your detailed report, @StoneCypher. Parcel@1 had some long-standing bugs that weren’t fixed because the engineering capacity was bound for version 2.

It was the same for PeerJS: Creating a possible version 2 delayed fixes for version 1. Also our two main maintainers hadn’t had much time for personal reasons. That changed; we now got two maintainers working on PeerJS and are prioritizing version 1. We are back on track.

All bundling issues should be fixed from version v1.4.

Node support is coming but is not high on the priority list. Node does not support WebRTC natively, and its polyfill wrtc has some issues and has not seen a commit in two years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants