Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

Dependency on "events" library not declared. #14

Closed
brodo opened this issue Jan 8, 2022 · 6 comments · Fixed by #16
Closed

Dependency on "events" library not declared. #14

brodo opened this issue Jan 8, 2022 · 6 comments · Fixed by #16

Comments

@brodo
Copy link

brodo commented Jan 8, 2022

Description

lib-jitsi-meet depends on the events package. This depencency should be declared in the package.json


Current behavior

When packaging the library with esbuild I get the following errors:

$ esbuild app.ts --bundle --target=es2016 --sourcemap --define:__filename='"filename"' --outfile=build/app.js
✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/modules/detection/TrackVADEmitter.js:6:41:
      6 │ const events_1 = __importDefault(require("events"));
        ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/JitsiMediaDevices.js:25:41:
      25 │ const events_1 = __importDefault(require("events"));
         ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/modules/statistics/statistics.js:25:41:
      25 │ const events_1 = __importDefault(require("events"));
         ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/modules/statistics/PrecallTest.js:16:41:
      16 │ const events_1 = __importDefault(require("events"));
         ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/JitsiConference.js:35:41:
      35 │ const events_1 = __importDefault(require("events"));
         ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

✘ [ERROR] Could not resolve "events"

    node_modules/@lyno/lib-jitsi-meet/dist/modules/util/Listenable.js:6:41:
      6 │ const events_1 = __importDefault(require("events"));
        ╵                                          ~~~~~~~~

  The package "events" wasn't found on the file system but is built into node. Are you trying to
  bundle for node? You can use "--platform=node" to do that, which will remove this error.

6 of 13 errors shown (disable the message limit with --log-limit=0)


Expected Behavior

Packaging the library with esbuild should not result in errors.


Possible Solution

Proposed solutions:

  • add 'events' as a dependency
  • add 'events' as a peer depenency

Steps to reproduce

import JitsiMeetJS from '@lyno/lib-jitsi-meet';

JitsiMeetJS.init({});

package.json

{
  "name": "jitsi-meet-experiments",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "build": "esbuild app.ts --bundle --target=es2016 --sourcemap --define:__filename='\"filename\"' --outfile=build/app.js",
    "serve": "serve ."
  },
  "devDependencies": {
    "esbuild": "^0.14.5",
    "serve": "^13.0.2",
    "typescript": "^4.5.4"
  },
  "dependencies": {
    "@lyno/lib-jitsi-meet": "^2.6726.2",
    "jquery": "^3.6.0"
  }
}

Environment details


@brodo brodo changed the title Peer depencency to "events" library not declared. Dependency to "events" library not declared. Jan 8, 2022
@brodo brodo changed the title Dependency to "events" library not declared. Dependency on "events" library not declared. Jan 8, 2022
@sapkra
Copy link
Member

sapkra commented Jan 8, 2022

Mhh, interesting that it was never a problem before. Do you have an idea why? As I understand it should have crashed in the browser but it didn't, it seems like.

@brodo
Copy link
Author

brodo commented Jan 9, 2022

Maybe you used another library with also had that dependency and so it was there already.

@sapkra
Copy link
Member

sapkra commented Jan 9, 2022

I checked the dependencies. events is a direct dependency of webpack. So it should always be resolvable in this repository.

@huangll99
Copy link

I checked the dependencies. events is a direct dependency of webpack. So it should always be resolvable in this repository.

It doesn't work in Vite

@brodo
Copy link
Author

brodo commented Jan 10, 2022

I checked the dependencies. events is a direct dependency of webpack. So it should always be resolvable in this repository.

That really depends on the build system and package manager.

Moreover, it is a really bad idea to put webpack (or any other dev dependency) into the finished bundle. If a library has a runtime dependency on another library, it should be declared either in the 'dependencies' or 'peer-dependencies' section in package.json. And in this case 'dependencies' is the right place.

Thanks!

@sapkra
Copy link
Member

sapkra commented Jan 10, 2022

I created a PR in the main repo.

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

Successfully merging a pull request may close this issue.

3 participants