matrix-org / matrix-bifrost

General purpose bridging with a variety of backends including libpurple and xmpp.js
Apache License 2.0
164 stars 31 forks source link

Some imported modules are missing type declarations #173

Closed bodqhrohro closed 4 years ago

bodqhrohro commented 4 years ago

Describe the bug

> matrix-bifrost@0.1.8 build /media/d/temp/git/matrix-bifrost
> tsc

src/xmppjs/XJSConnection.ts:1:25 - error TS2307: Cannot find module '@xmpp/component-core' or its corresponding type declarations.

1 import {Component} from "@xmpp/component-core";
                          ~~~~~~~~~~~~~~~~~~~~~~

src/xmppjs/XJSConnection.ts:2:23 - error TS2307: Cannot find module '@xmpp/reconnect' or its corresponding type declarations.

2 import Reconnect from "@xmpp/reconnect";
                        ~~~~~~~~~~~~~~~~~

Found 2 errors.

 ERROR  Command failed with exit code 2.

To Reproduce

npm i
npm run build

Expected behavior Packages with all required type declarations are provided in package.json.

Desktop (please complete the following information):

Half-Shot commented 4 years ago

Hey, I tried this out on my laptop and I see:

➜  /tmp git clone git@github.com:matrix-org/matrix-bifrost.git          
Cloning into 'matrix-bifrost'...
remote: Enumerating objects: 323, done.
remote: Counting objects: 100% (323/323), done.
remote: Compressing objects: 100% (190/190), done.
remote: Total 3920 (delta 201), reused 215 (delta 128), pack-reused 3597
Receiving objects: 100% (3920/3920), 1012.83 KiB | 969.00 KiB/s, done.
Resolving deltas: 100% (2861/2861), done.
➜  /tmp cd matrix-bifrost 
➜  matrix-bifrost git:(develop) nvm use 12
Now using node v12.18.3 (npm v6.14.6)
➜  matrix-bifrost git:(develop) npm i      
npm WARN deprecated tslint@6.1.3: TSLint has been deprecated in favor of ESLint. Please see https://github.com/palantir/tslint/issues/4534 for more information.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported

> fast-xml-parser@3.17.4 postinstall /tmp/matrix-bifrost/node_modules/fast-xml-parser
> node tasks/postinstall.js || exit 0

Love fast-xml-parser? Check https://amitkumargupta.work for more projects and contribution.

> matrix-bifrost@0.1.8 prepare /tmp/matrix-bifrost
> npm run build

> matrix-bifrost@0.1.8 build /tmp/matrix-bifrost
> tsc

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 608 packages from 440 contributors and audited 616 packages in 14.43s

40 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

➜  matrix-bifrost git:(develop) ✗ 

I'm afraid it might be something wrong with your environment. You can try building the docker image which should confirm if it's environmental.

bodqhrohro commented 4 years ago

True; I probably did something wrong when trying to check if it is reproduced with npm first time. It actually compiles well with both yarn (which is used in Dockerfile) and npm.

This is actually a pnpm issue. The packages above are not explicitly listed in package.json, but rather are the dependencies of @xmpp/component. pnpm seems to resolve the dependencies, but fails to install them properly, even in the recursive mode. So I'll readdress the issue to pnpm developers, sorry for disturbance.

zkochan commented 4 years ago

Any package that is used by the project directly, should be installed as a direct dependency. This is not a pnpm issue. This works with npm and Yarn 1 only because they create a flat node_modules. This will not work with Yarn v2 and pnpm because they create a strict node_modules, which allows access only to the dependencies that are listed in package.json.

There is a workaround to use pnpm install --shamefully-hoist but that is just a workaround, the correct solution is to add the missing dependencies.