Unable to use tdl package with vite
Pre-flight checklist
- [x] I have read the contribution documentation for this project.
- [x] I agree to follow the code of conduct that this project uses.
- [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Forge version
7.8.3
Electron version
37.2.6
Operating system
Windows 10
Last known working Forge version
No response
Expected behavior
I can use it.
Actual behavior
An error occurred
Error: No native build was found for platform=win32 arch=x64 runtime=electron abi=136 uv=1 libc=glibc node=22.17.1 electron=37.2.6
loaded from: D:\CodeSpace\eeeeeee\my-new-vtt\.vite
at load.resolve.load.path (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2145:11)
at load (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2113:33)
at loadAddon (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2316:47)
at init (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2437:41)
at createAnyClient (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2505:7)
at Object.createClient (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2535:12)
at App.createWindow (D:\CodeSpace\eeeeeee\my-new-vtt\.vite\build\main.js:2754:7)
at App.emit (node:events:518:28)
Steps to reproduce
use npx create-electron-app@latest my-new-app --template=vite-typescript to create project
use npm install tdl prebuilt-tdlib
import tdl from "tdl";
import { getTdjson } from "prebuilt-tdlib";
tdl.configure({ tdjson: getTdjson() });
const client = tdl.createClient({
apiId: 0,
apiHash: "...",
});
npm run start
Additional information
When I don't use vite, it worke. (use npx create-electron-app@latest my-app)
I found that, tdl use node-gyp-build to load .node file
@qiaoshouzi I believe the issue is the tdl.node and tdjson.dll are not being included in the build (.vite) folder that's why this issue exists, for now you can use this, I tried many ways to make it work, I tried changining preStart function as well, I thought the issue exists only in build server but it maybe either in @electron/rebuild idk, I may need to dig deeper.
Till that time you can try this workaround, mind you, just typescript recommendations wont work otherwise it is working in dev
https://github.com/RNAdvani/electron-forge-tdl-bug-turnaround
This pic includes the content of tdl
see #3934 for a solution