wails icon indicating copy to clipboard operation
wails copied to clipboard

Add import aliases to every framework template

Open SheetJSDev opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe.

Referencing the bindings is cumbersome and a deep structure might involve an import like

import { Greet } from '../../../../../wailsjs/go/main/App'

Describe the solution you'd like

For each template that uses a framework with imports, create import aliases for the core paths / files that frontend will import.

  1. wailsjs/go/main/App can be aliased to something like #wails/bindings:
import { Greet } from '#wails/bindings';
  1. wailsjs/go/runtime/runtime can be aliased to something like #wails/runtime:
import { Quit } from '#wails/runtime';
  1. wailsjs/go/models can be aliased to something like #wails/models:
import { main } from '#wails/models';

The import has to be changed in multiple places including package.json, vite.config.js (if applicable), tsconfig.json (if applicable)

Describe alternatives you've considered

No response

Additional context

The VueJS template has an alias @ for the frontend/src folder, so import aliases are already used

SheetJSDev avatar Sep 03 '22 02:09 SheetJSDev

Did you know you can set the directory of the generated bindings using the wailsjsdir project config option?

leaanthony avatar Sep 03 '22 04:09 leaanthony

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 02 '22 02:11 stale[bot]

@SheetJSDev - was there anything more you felt needed to happen with this?

leaanthony avatar Nov 02 '22 08:11 leaanthony