#Problem with import

63 messages · Page 1 of 1 (latest)

dire cliff
#

@faint stump do you need file or project ?

faint stump
#

Let's begin with just the file

#

You should get a new API key & secret now that those have been shared.

I'm reading over the file now.

faint stump
#

How is this file being imported in your Tauri app? Is it linked in the index HTML?

bright spruce
#

importing node modules like that requires using a bundler like Vite or a framework, are you using one of them?

bright spruce
#

yeah you'll need a bundler to serve the node modules along with your own code

#

i think tauri has a vanilla vite template?

dire cliff
bright spruce
tall cedar
bright spruce
#

but if you just need a websocket client then you can use the browser's builtin WebSocket

dire cliff
#

I also need node-binance-api

bright spruce
#

you'll have to look into it

dire cliff
#

I thought I can change from electron to tauri in 2 days..

#

But there much more work here

bright spruce
#

well it's all dependent on what you're building

dire cliff
#

crypto screener

bright spruce
#

if your app used stuff specific to electron then yeah you're going to have a harder time moving over

dire cliff
#

So basically if I want tauri I will need write all code on rust ? and using rust libraries ?

faint stump
#

No

#

You'll need to interface with Rust for specifically the things you want to do that require some native/non-browser API. You'll still write plenty of JS.

dire cliff
#

hmm

bright spruce
#

or just use raw http/websockets

dire cliff
#

Thx guys, I will try it

dire cliff
bright spruce
#

yeah i'd say

dire cliff
#

But here is no Vite

#

or I need to install it after?

tall cedar
#

vanilla and then typescript

#

you can use normal javascript in the typescript project, but only the typescript template comes with vite

#

(well, and all non vanilla templates also use vite)

dire cliff
#

Thank you

#

is that normal ?

tall cedar
#

you have to run npm install in the project dir once

dire cliff
#

Can I somehow use main.js instead of main.ts ? Or it will better to learn ts ?

tall cedar
#

i think you can write js in ts no?

#

either way, vite needs at least one ts file i think, at least i had an error in my test project without it but adding a empty.ts file fixed that

#

but honestly, learning ts is better if you ask me/us

dire cliff
tall cedar
#
  1. replace the webviewwindow thingy with import { WebviewWindow } from "@tauri-apps/api/window";
  2. add a ? after each getElementById()
    I think that should make ts happy
#

okay, did a quick test. to convert it to js:

  1. rename main.ts to main.js
  2. in package.json remove tsc && from the "build" script
  3. in index.html rename the main.ts import to main.js
dire cliff
bright spruce
# dire cliff

For your errors at the bottom, ?. need to be together rather than separated by a newline

#

Also fwiw, everything in that screenshot is pure JS. TS is just making you do more work to account for its warnings

dire cliff
#

Do I need somehow write file instead of url in 5th line of code?

tall cedar
#

where is the html file?

dire cliff
tall cedar
#

by default vite only handles a single entry html file

#

if the html files don't need vite to actually do anything you could move them into /public/knives.html and then vite will serve them as-is, but yeah, doesn't sound like that's what you want here.

dire cliff
tall cedar
#

npm install --save-dev @types/node

dire cliff
#

or I don't need to use dirname?

dire cliff
#

still same problem

tall cedar
#

in your knifes.html file add type="module" to the js import maybe? i thought vite can take care of that but maybe not