How to use socket.io-client in electron? - socket.io

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.

Related

How to use vite inside Laravel package

I am building Laravel package locally and my package has views therefore I am using css and scripts. I decided to use vite but I am kind of stack because vite is looking for manifest.json in main Laravel public folder instead of inside the vendor and my package folder.
This is the error I am getting,
Vite manifest not found at: /Users/User/Sites/laravel-project/public/build/manifest.json
The way I am registering style and script in my package is like below
#vite(['resources/css/app.css', 'resources/js/app.js'])
For some reason you need to pass the second parameter (which is the default):
#vite(['resources/css/critical.css'], config('vite.configs.default.build_path'))

Google Cloud Function using internal private function

Project looks something like this
project
- internal
- package
code.go
- cmd
- function
main.go
In cmd/function, the go.mod looks like this:
module github.com/private/repo/cmd/function
go 1.13
require (
github.com/private/repo/internal/package v0.0.0-00010101000000-000000000000
)
replace github.com/private/repo/internal/package => ../../internal/package
Which works fine locally, however, when deploying as a Cloud Function, it doesn't work, as Cloud Function only contains the "cmd/function" directory.
Instead, I try to copy the module into the project directory and the replace.
project
- cmd
- function
main.go
- internal
- package
code.go
replace github.com/private/repo/internal/package => ./internal/package
But this replace seems to be ignored as the Cloud Function deploy build still tries to download this package.
Next, I try using go mod vendor instead, and ignore the go.mod and go.sum files. This seems to do the trick, but not fully, since removing the go.mod, I can't use the internal package anymore.
use of internal package function/vendor/github.com/private/repo/internal/package not allowed
Not sure how I would go about and solve this and still being able to use the internal package name.
Edit:
Added a repository showing the error and a simple fix by not using the internal keyword in the library name. https://github.com/lobbin/gcloud-function-error
Thank you for reporting this issue.
I filed a Feature Request for this improvement [1].
I suggest you to star the FR to give it more visibility and every time there is an update you will be notified through your email.
Please note there is no ETA for this request at this moment.
[1]. https://issuetracker.google.com/184141587

Best way to import sass / code from GitHub?

I'm trying to figure out how Hugo can (automatically) pull the most recent files from a Github folder when running hugo server. In particular, I like to pull css files from Primer CSS by GitHub. What is the best way to implement that, so that I do not always have to update the Primer CSS manually on my Git?
I was thinking modules would be a way (config.yaml):
module:
imports:
- disable: false
path: github.com/primer/css
mounts:
- source: src/scss
target: assets/scss/primer
However, when adding this to config.yaml, it does not appear to work:
Error: module "github.com/primer/css" not found; either add it as a Hugo Module or store it in "/Users/user/code/my-theme/themes".: module does not exist
Is there any simple best practice in automatically pulling the most recent files from https://github.com/primer/css/(/src) and loading it into the /assets folder? Or is the only way to work with npm node modules, like here: https://github.com/lucperkins/hugo-primer
Thanks in advance!
I struggled with this for a long time. The key is to initialize your your site as a "go module" by running hugo mod init {anything}. That will create a go.mod file. So if you ran hugo mod init mywebsite that generate a go.mod that looks something like this:
module mywebsite
go 1.14
require github.com/primer/css v1.0.0 // indirect
After that, the modules should work for you.

Cannot find module 'rxjs-compat/Subscription'

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.

Heroku Golang - command 'main' not found

I got a Go API up on Heroku to which I push some code; in my procfile I have the following
web: main
In order to launch the Go built binary on Heroku's side. When I build it on my side with
go build cmd/main.go
It produces a binary file namned 'main' in my project root and works as expected but on Heroku I get
app[web.1]: bash: main: No such file or directory
The build process on Heroku seems fine, it finds all my dependencies and installs/compiles it all.
This was super simple once I realised this;
All main packages in the repo are compiled and binaries placed in the /app/bin directory, which is in the PATH. Binaries are named after the directory that contains them.
Another thing to note: Like other Go programs, the code in main.go has to belong to package main:
package main
func main() {
// your code here
}
I'm afraid I totally forgot about this at first and it stumped me for a while.

Resources