wails icon indicating copy to clipboard operation
wails copied to clipboard

bindings are not generated properly

Open bit-lang opened this issue 8 months ago • 5 comments

my go func is defined as follows:

func (a *App) GetFileZip(input string) string {
  // func logic
}

the "wails dev" command outputs:

 • Generating bindings: Done.
  • Installing frontend dependencies: Done.
  • Compiling frontend:
    > [email protected] build
    > vite build

    vite v3.2.11 building for production...
    transforming...
    ✓ 7 modules transformed.

    'GetFileZip' is not exported by wailsjs/go/main/App.js, imported by src/main.js
    file: C:/Users/development/wails/readerzip/frontend/src/main.js:4:8
    2: import './app.css';
    3:
    4: import {GetFileZip} from '../wailsjs/go/main/App';
               ^
    5: import {GetEncInputs} from '../wailsjs/go/main/App';
    6: import {EventsOn} from "../wailsjs/runtime/runtime";
    error during build:
    Error: 'GetFileZip' is not exported by wailsjs/go/main/App.js, imported by src/main.js
        at error (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
        at Module.error (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
        at Module.traceVariable (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:12788:29)
        at ModuleScope.findVariable (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:11440:39)
        at FunctionScope.findVariable (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
        at ChildScope.findVariable (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
        at BlockScope.findVariable (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:6372:38)
        at Identifier.bind (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:7439:40)
        at CallExpression.bind (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:5269:23)
        at CallExpression.bind (file:///C:/Users/development/wails/readerzip/frontend/node_modules/rollup/dist/es/shared/rollup.js:8935:15)

  ERROR   exit status 1

I checked the wailsjs/go/main/App.js , there is only the original Greet() function there.

does this mean the bindings are not generated at all?

bit-lang avatar Apr 17 '25 11:04 bit-lang

What happens when you try to generate the bindings in isolation using wails generate module -v 2?

symball avatar Apr 18 '25 23:04 symball

What happens when you try to generate the bindings in isolation using wails generate module -v 2?

the command runs without further information as shown below.

C:\Users\development\wails\videocryptor>wails generate module -v 2
 ♥   If Wails is useful to you or your company, please consider sponsoring the project:
https://github.com/sponsors/leaanthony

bit-lang avatar Apr 19 '25 03:04 bit-lang

found something.

  1. after 'wails init' the following Greet func is auto generated. If the Greet() is kept in the code, the compile will succeed.
func (a *App) Greet(input string) string { return "hello" + input }
  1. if the above func is removed from the code, the Error: 'GetFileZip' is not exported will pop up again.
  2. although the app compiles and runs, it only runs in dev mode ( using 'wails dev' command ). if I run 'wails build', the built app ( the .exe file ) will not run at all - nothing is shown.

my guess is that the cause might be my go code is dealing with unzipping some .zip files?

bit-lang avatar Apr 19 '25 10:04 bit-lang

Do you have a reference to Greet in your frontend code?

leaanthony avatar Apr 20 '25 00:04 leaanthony

Do you have a reference to Greet in your frontend code?

no I don't have Greet in front end code. I kept Greet both back end and front end only for the code to compile. Remove Greet the bindings will not be generated.

The wails build now is working as well as wails dev. Previously it was my typo caused the build to fail.

bit-lang avatar Apr 20 '25 18:04 bit-lang