Cannot find module 'rxjs-compat/Subscription' - rxjs

I am trying to migrate from rx5 to rx6 by following the guide here. Initially, I installed along with the rxjs-compat package and everything works fine. However, when I try to remove the rxjs-compat package, I am getting an exception Cannot find module 'rxjs-compat/Subscription'. I used the rxjs-5-to-6-migrate to perform the migration
I am using this statement for Subscription : import { Subscription } from "rxjs";
For reference this is my branch- https://github.com/akshita31/omnisharp-vscode/tree/rxjs_update and this is the corresponding pull request that lists all the changes - https://github.com/OmniSharp/omnisharp-vscode/pull/2830

I updated all the dependencies to the latest versions and used the rxjs-tslint-rules as follows
npm install rxjs-tslint-rules --save-dev
Then in my tslint.json add the rule "rxjs-no-compat" : true
Execute ./node_modules/.bin/tslint -c tslint.json -p tsconfig.json in the project folder. This will give all the set of invalid imports
Resolve the invalid imports and then try removing the rxjs-compat package.
I also cleaned my npm cache - npm cache clean --force
If there are no more errors, we can as well remove the above tslint dependency from the package.json
More details can be found in the issue.
Thanks #cartant for the help

Do you by any chance still have some imports that are still using rxjs-compat?
With the migration from rxjs 5 to 6, you need to be very careful about all the imports, since you don't want to import some module from wrong the wrong path. I believe rxjs-tslint can help you.

Related

Build constraints exclude all the Go files

I'm newbie to go and I've created a file and init a mod inside of it by typing:
go mod init github.com/AnmarDc/e-commerce
After that, I made a folder called controllers which will contain all the controllers of my operations on my site and then tried to import it into my routes folder, but that didn't work.
I kept getting the following error:
Build constraints exclude all the Go files in 'C:/Users/engan/Go/src/Projects/eCommerce/controllers'
I thought it was about GoPath, or GoRoot, but I found it out it's because GoLand itself, but I have no idea how to fix it, as I can see everything seems reasonable to me.
GoEnv attached.
Oh, it looks like there's some issue in building constraints, I just imported the following code in my routers:
//go:build (linux && 386) || (darwin && !cgo)
and it worked perfectly.
Reference:
Constraints

Yarn installing wrong version of jest in workspace

I have a project with yarn (v1) workspaces.
project/
packages/
pkgA/
subPkgA1/
pkgB/
package.json has this:
"workspaces": {
"packages": [
"packages/pkgA",
"packages/pkgA/subPkgA1",
"packages/pkgB"]}
note that there's a nested workspace in there.
Top-level has jest#27.4.7 in its package.json.
pkgA has jest#24.9.0 because one of its dependencies requires that version; its package.json has no entry for jest.
pkgA/subPkgA1 has jest#27.4.7 in its package.json, BUT it actually gets 24.9.0 installed in its node_modules/.bin/jest, presumably because its parent workspace has that.
My main question is how to get jest#27.4.7 in the nested package subPkgA1? I tried adding an entry in pkgA's package.json, but that didn't help.
BTW, I know nested workspaces aren't fully supported until Yarn v2, but I can't upgrade right now, and I can't easily move my subpackage out of its parent, so any hacky solution would be better than nothing.

How do I stop the auto importing of imported item in go outside of my project?

I have my projects that have many packages which import each other and import outside packages. When I make a change to one of my low lever packages, and then push it to git it is fine and works in that section. When I go get it for use in another project that was working perfectly I now get this go get this error:
module declares its path as: github.com/xdg-go/scram
but was required as: github.com/xdg/scram
None of my code uses either of those directly. It looks like it automatically updated some lower external packages and broke things the used to then old import.
How do I either find out the package that is importing the wrong name or stop all auto-updates?
The go.mod file at github.com/xdg/scram declares itself as github.com/xdg-go/scram:
module github.com/xdg-go/scram
go 1.11
require (
github.com/xdg-go/stringprep v1.0.2
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
)
The go.mod file should be updated to reflect the correct import path.
Unfortunately if this module is for you an indirect dependency, the best fix possible is to update whatever project you import that is directly importing it.
When that is not an option, a solution to this error is to clone the problematic repository locally and use the replace directive in your go.mod file:
module mymodule
replace github.com/xdg/stringprep => ../strprep
go 1.16.2
require (
github.com/divjotarora/mgo v0.0.0-20190308170442-1d451d2a3149
)
where ../strprep is where the code of the required module exists in your local machine, relative to the go.mod file of your project.
The downside of this of course is that you have to replicate this palliative fix wherever you plan to go get your modules.
Note also:
divjotarora/mgo is just a random example of a project that imports one of those packages using their old import path.
I'm using xdg/stringprep as an example because I can't find modules that import xdg/scram instead, but apparently it suffers from the same issue
Beside, you can use:
go mod why <package> to find out why a certain package is listed as a dependency of your project
go mod graph to show the full dependency graph. The output is in <package> <requirement> format

How to use socket.io-client in electron?

I'm trying to add socket.io-client to my project.
I've installed
socket.io-client & #types/socket.io-client
but I'm getting this error when I try to build:
/myproject/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:37
TypeError: Cannot read property 'request' of undefined
node_modules is not embedeed in electron-builder package, a solution is to import all modules into the index.js entry point like describe bellow:
https://www.electron.build/tutorials/loading-app-dependencies-manually
Ok that is working now, after long seek the problem was that you have to push your "socket.io-client" into dependencies and not devDependencies.

How to use composer with a non-packagist github project containing a packages.json

I want to put https://github.com/timrwood/moment into my composer.json for easy maintenance.
It's not an official packagist project (of course, as it's not PHP), but it contains a packages.json for nodejs. Can I use this in my composer.json?
I tried this, but it didn't work:
{
"repositories": {
"timrwood/moment": {
"type": "git",
"url": "git://github.com/timrwood/moment.git"
}
}
}
It throws an error message saying "No valid composer.json was found in any branch or tag of git://github.com/timrwood/moment.git, could not load a package from it."
And it is lacking the version string to define the version I want to use...
Can anyone help here?
Or shouldn't I use composer here at all cause I'm mixing JS and PHP?
Composer only manages composer packages. It does not know how to parse a package.json file. There are different approaches to this problem. Composer may be able to deal with frontend dependencies in the future.
For the time being I'd recommend using a separate dependency manager for your JavaScript dependencies. Either NPM or something like jam or ender.
Check out composer plugin to handle components via bower, nodejs and git repositories: fxpio/composer-asset-plugin.

Resources