Closed bradleybernard closed 2 years ago
Looks like same issue as here: https://github.com/antfu/unplugin-auto-import/issues/162
I worked around this by creating a local JS file to import then re-export things to make unplugin-auto-import
happy:
ziggyjs.js
import route from 'ziggy-js';
export { route };
In my vite.config.js
under the imports
key:
imports: [
'@/ziggyjs': [['route', 'route']],
]
This seems to work!
Hi there, I'm trying to use the auto import feature to import Ziggy.js (https://www.npmjs.com/package/ziggy-js) which is a popular package used to expose app routes to JavaScript for Laravel projects.
My setup:
I'm using Vite as the bundler/dev-server and using the AutoImport plugin to try to achieve this. I've had success auto importing
axios
andlodash
but not as much luck withziggy.js
.The import that works manually in my Vue SFCs:
So I tried to set that up in
vite.config.js
:However the generated file:
auto-imports.d.ts
shows:Highlighting the errors in PHPStorm lines:
When I take a look at the file for definitions (powered by DefinitelyTyped), I see (direct link to it: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/549b5a3cf3c34a7639d711e08747688ec6bbb889/types/ziggy-js/index.d.ts#L99):
So I'm trying to understand how I can use
unplugin-auto-import
to achieve an import that looks like:Given the configuration, it seems to always produce imports along the lines of:
Any advice here would be greatly appreciated!