[Help] Issue with porting an existing app over
Describe the problem you Confuse
Hey there, I'm currently trying to port an existing application over to this template and running into an issue where the content won't load.
[plugin:vite:import-analysis] Failed to resolve import "${moduleName}" from "node_modules/@electron/remote/dist/src/main/server.js?v=b01c5d3c". Does the file exist?
/home/stan/projects/personal/WeakAurasCompanion/node_modules/@electron/remote/dist/src/main/server.js:11:45
9 | import * as __require_for_vite_LxV6Rj from "../common/get-electron-binding";
10 | import * as __require_for_vite_gQPFem from "@electron/remote/main";
11 | import * as __require_for_vite_GEtNgH from "${moduleName}";
| ^
12 | import * as __require_for_vite_lMpJfA from "${moduleName}";
13 | import * as __require_for_vite_lJsWyZ from "electron";
at formatError (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:39055:46)
at TransformContext.error (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:39051:19)
at normalizeUrl (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:58329:26)
at async TransformContext.transform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:58478:57)
at async Object.transform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:39292:30)
at async doTransform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:50012:29
The code is in this branch here https://github.com/WeakAuras/WeakAuras-Companion/tree/v5
Any hint or help would be appreciated :)
More detail (optional)
Add any other context or screenshots.
9 | import * as __require_for_vite_LxV6Rj from "../common/get-electron-binding";
10 | import * as __require_for_vite_gQPFem from "@electron/remote/main";
11 | import * as __require_for_vite_GEtNgH from "${moduleName}";
| ^
12 | import * as __require_for_vite_lMpJfA from "${moduleName}";
13 | import * as __require_for_vite_lJsWyZ from "electron";
This BUG from @originjs/vite-plugin-commonjs, I saw your code with a lot of the require. You can try use vite-require plugin. If there are similar problems, you can be in vite-require by the issues, that is I wrote :)
vite-require
That gives me
[plugin:vite-plugin-require] p is not iterable
/home/stan/projects/personal/WeakAurasCompanion/packages/renderer/src/App.vue
at /home/stan/projects/personal/WeakAurasCompanion/node_modules/@babel/parser/lib/index.js:11545:43
at Array.some (<anonymous>)
at hasPlugin (/home/stan/projects/personal/WeakAurasCompanion/node_modules/@babel/parser/lib/index.js:11541:18)
at validatePlugins (/home/stan/projects/personal/WeakAurasCompanion/node_modules/@babel/parser/lib/index.js:11580:7)
at getParser (/home/stan/projects/personal/WeakAurasCompanion/node_modules/@babel/parser/lib/index.js:16594:5)
at Object.parse (/home/stan/projects/personal/WeakAurasCompanion/node_modules/@babel/parser/lib/index.js:16565:12)
at TransformContext.<anonymous> (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:56:40)
at step (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:33:23)
at Object.next (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:14:53)
at /home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:4:12)
at TransformContext.transform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite-plugin-require/dist/index.js:48:20)
at Object.transform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:39292:53)
at async doTransform (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chu
vite-require is not vite-plugin-require
vite-requireis notvite-plugin-require
ooh my bad, sorry.
[plugin:vite-require] Unexpected token (1:0)
/home/stan/projects/personal/WeakAurasCompanion/packages/renderer/src/components/LandingPage.vue:1:0
1 | <template>
| ^
2 | <div id="wrapper">
3 | <div
at Parser.pp$4.raise (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:33561:13)
at Parser.pp$9.unexpected (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:30855:8)
at Parser.pp$5.parseExprAtom (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32936:10)
at Parser.pp$5.parseExprSubscripts (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32728:19)
at Parser.pp$5.parseMaybeUnary (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32694:17)
at Parser.pp$5.parseExprOps (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32621:19)
at Parser.pp$5.parseMaybeConditional (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32604:19)
at Parser.pp$5.parseMaybeAssign (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32571:19)
at Parser.pp$5.parseExpression (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:32534:19)
at Parser.pp$8.parseStatement (/home/stan/projects/personal/WeakAurasCompanion/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:31045:45
Put vite-require after @vitejs/plugin-vue
When using require("sharp"); this now yields
Uncaught ReferenceError: Cannot access 'resolve' before initialization
at path.js:4:26
(anonymous) @ path.js:4
in .vite-plugin-electron-renderer/path.js
When using import sharp from "sharp"; I get
Uncaught SyntaxError: The requested module '/@fs/home/stan/projects/personal/WeakAurasCompanion/node_modules/sharp/lib/index.js?v=75990b4a' does not provide an export named 'default' (at gif2tga.js:3:8)
import * as sharp from 'sharp'
import * as sharp from 'sharp'
Uncaught ReferenceError: Cannot access 'resolve' before initialization at path.js:4:26 (anonymous) @ path.js:4
I'm looking at this problem, a little wait for me, oh :)
I submitted a PR, hoping to help you.
https://github.com/WeakAuras/WeakAuras-Companion/pull/1441
I try fixed all BUG 🐞, but finally I got the problem. This seems to have nothing to do with the plugin.
Oh, you're awesome, thank you so much, will check it out!
Alright, merged it, thanks again! The error is curious since the actual code did not change in that refactor but I'll see if I can figure out what causes it.
@Stanzilla ha-ha! I saw that you are the author of cmder and I am the user of cmder. cmder is awesome. 🎉
@Stanzilla ha-ha! I saw that you are the author of
cmderand I am the user ofcmder.cmderis awesome. 🎉
Hah thank you!
@caoxiemeihao Hey there, I figured it out! It's image requires that cause this, example:
<img :src="require(`@/assets/social-icons/wago.svg`)" class="logo" title="Wago" />
<img :src="require(`@/assets/social-icons/wago.svg`)" class="logo" title="Wago" />
The require() finally convert to import and then will promotion to the top by vite-require, exmaple:
import * as __require2import__id__ from '@/assets/social-icons/wago.svg'
↓
<img :src="__require2import__id__" class="logo" title="Wago" />