#Problem with import
63 messages · Page 1 of 1 (latest)
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.
its from apis
How is this file being imported in your Tauri app? Is it linked in the index HTML?
yes, using <script>
importing node modules like that requires using a bundler like Vite or a framework, are you using one of them?
using vanilla html/css
yeah you'll need a bundler to serve the node modules along with your own code
i think tauri has a vanilla vite template?
and then I can use js (instead of rust) for my code?
hm looks like they don't but vite itself has vanilla examples you can check out
only if you select vanilla _type_script, the vanilla js comes without it
depends what you want to do, the js will still only be capable of things that work in the browser so ws won't work
but if you just need a websocket client then you can use the browser's builtin WebSocket
I also need node-binance-api
you'll have to look into it
I thought I can change from electron to tauri in 2 days..
But there much more work here
well it's all dependent on what you're building
crypto screener
if your app used stuff specific to electron then yeah you're going to have a harder time moving over
So basically if I want tauri I will need write all code on rust ? and using rust libraries ?
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.
hmm
if node-binance-api doesn't support use in browser you might wanna check out this https://github.com/tiagosiebler/binance
or just use raw http/websockets
Thx guys, I will try it
the best and easier option is Vite?
yeah i'd say
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)
you have to run npm install in the project dir once
Can I somehow use main.js instead of main.ts ? Or it will better to learn ts ?
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
code from previous main.js
- replace the webviewwindow thingy with
import { WebviewWindow } from "@tauri-apps/api/window"; - add a
?after each getElementById()
I think that should make ts happy
okay, did a quick test. to convert it to js:
- rename main.ts to main.js
- in package.json remove
tsc &&from the"build"script - in index.html rename the main.ts import to main.js
I will listen you and try use&learn ts
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
Do I need somehow write file instead of url in 5th line of code?
where is the html file?
if that file needs javascript imports then you'll need to look at this https://vitejs.dev/guide/build.html#multi-page-app
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.
npm install --save-dev @types/node
or I don't need to use dirname?
still same problem
in your knifes.html file add type="module" to the js import maybe? i thought vite can take care of that but maybe not