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

Cant import { mainReduxBridge } #6

Closed
automationghost opened this issue May 16, 2024 · 9 comments
Closed

Cant import { mainReduxBridge } #6

automationghost opened this issue May 16, 2024 · 9 comments

Comments

@automationghost
Copy link

automationghost commented May 16, 2024

Greetings I cant import main mainReduxBridge in my project . ( also cant import preloadReduxBridge )

im using electron-vite-builder and the tsconfig there seems to cause the issue

I dont want to mess with their config ... so im not sure what to do :)

Cannot find module 'reduxtron/main' or its corresponding type declarations.
  There are types at '..../node_modules/reduxtron/dist/main.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.ts(2307)

im currently debating if I build my own solution for handling state across multiple windows ...

already fiddled around abit . handling the state in the main process seemed like a good solution for me ... also I would need to persist the data and be able to debug / connect to the redux store ...

Previously I expermented with having a renderer store only .. but it got abit messy sharing the the state .. as there is no single source of truth .. still found a solution to that .. but wasnt happy ... so i ended up looking into other solutions ... electron-redux didnt seem to work with preload script / context isolation .. and reduxtron gave me trouble with import ... yeah :)

@automationghost automationghost changed the title Cant import { mainReduxBridge } from "reduxtron/main"; Cant import { mainReduxBridge } May 16, 2024
@vitordino
Copy link
Owner

hey there @automationghost, do you have a repo to share?

alternatively: i’ve recently revamped the boilerplates and provided scripts to get them:

  • react
    npx degit vitordino/reduxtron/packages/boilerplate-react project-name
  • svelte
    npx degit vitordino/reduxtron/packages/boilerplate-svelte project-name
  • vue
    npx degit vitordino/reduxtron/packages/boilerplate-vue project-name
  • vanilla
    npx degit vitordino/reduxtron/packages/boilerplate-vanilla project-name

they might help with this initial proof of concept (:

@automationghost
Copy link
Author

automationghost commented May 17, 2024

This is the boilerplate.

https://github.com/cawa-93/vite-electron-builder

maybe you can take a quick look on the ts configs and tell me what your aproach would be. I think its mainly about the

"moduleResolution": "Node",

settings ...

I tried changing it to nodenext as you have it .. but then it breaks some of their stuff :D...

You could basically install taht boilerpalte and try to install the mainbridge to see the problem

the configs are in the packages folders

@vitordino
Copy link
Owner

i won’t be able to check this until next week.. hold tight..

@automationghost
Copy link
Author

i won’t be able to check this until next week.. hold tight..

ok no worries . I will try buidling a variation of electron-redux with persiting the state via a json file until then .

I would like to try both your version and mine see how it goes . Maybe I use both.
The automationghost app will have a heavy focus on windows creations .. so im currently dabbling alot with this to see what works best.

have a nice weekend

@automationghost
Copy link
Author

automationghost commented May 18, 2024

I spent whole day re-creating my own version of redux-electron.

damn my brain is fried after this ipc pingpong :D .... but it works.

I used redux persists with electron store for the main process
and for the renderer process i use normal redux without persist but forward all actions to main . Main then updates all renderer windows...

I have 2 middlewares
forwardToMain
forwardToRenderer

utility functions :
setupPreload()
initilizeRendererListeners
intilizeMainlistener

i can plug initilizeRendererListeners to any new window I create so pretty convienent.

and i can debug with redux extension in the frontend ...
strangely though i havent figured out how to connect to the mainprocesses redux store with the redux chrome extension... doesnt seem to work for some reason... (event though i use the redux toolkit devtools option ... cant connect to the store .... anyway :D ... just sharing my excitement and pain :D ... have a nice day

@automationghost
Copy link
Author

automationghost commented May 19, 2024

i have found the problem >

the npm package seems to have a problem with the dist folder so the import statement is wrong :)

though i checked your package.json ... guess all is setup correcetly there .. still not sure whats going on :D

import { mainReduxBridge } from "reduxtron/main";
import { mainReduxBridge } from "reduxtron/dist/main"; <<works

i leave it to you

@vitordino
Copy link
Owner

vitordino commented May 25, 2024

this might help: https://github.com/vitordino/vite-electron-builder-reduxtron

i couldn’t find a perfect way to make both typescript and the bundler happy that quick..

so i did the age old trick of using patch-package, and left only the typescript source to be imported


i’ve also noticed that although it claims:

Written following the latest safety requirements, recommendations and best practices.

looks like any exposed preload work if you set BrowserWindow to webPreferences.sandbox: false with the standard configuration


on a personal note:
i didn’t liked that much the way this boilerplate deals with some details..
the biggest one is how they rely on some preload magic* that might make it harder to use some electron packages

the magic is that unplugin-auto-expose..

@automationghost
Copy link
Author

automationghost commented May 25, 2024

Thanks . I will give it a go some sometime. So far im fine with this boilerplate.
this one loads much faster thanks to vite and it looks like for now it will be easy to update electron versions which was a problem with the other boilerplate.

looking at vscode repo for inspiration. I want to build a extension system as a final goal down the road ... just researching takes me hours at the moment .. but its good fun.

Thanks again.

@vitordino
Copy link
Owner

alright, let me know if you need anything else

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

No branches or pull requests

2 participants