Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error while using laravel vue 3 #632

Closed
annaselh opened this issue Sep 23, 2024 · 2 comments
Closed

Getting error while using laravel vue 3 #632

annaselh opened this issue Sep 23, 2024 · 2 comments

Comments

@annaselh
Copy link

Hi,
I'm using module federation with vue 3 as remote and vue 3 (with laravel) as the host, but while the host access the remote component I get error like this

TypeError: Failed to resolve module specifier '__laravel_vite_placeholder__/node_modules/.vite/deps/vue.js?v=5d8d6ebd' at get (__x00__virtual:__federation__:14:36) at Object.get (__x00__virtual:__federation__:23:30) at we (__federation_fn_import-a6fff6c2.js:1:4445) at Ce (__federation_fn_import-a6fff6c2.js:1:3996) at __federation_expose_TestComponent-af96f67a.js:1:100

my vite configuration in remote is:

federation({ name: 'remote-app', filename: 'remoteEntry.js', exposes: { './TestComponent': 'src/components/TestComponent.vue', './TestPage': 'src/pages/TestPage.vue' }, shared: ['vue'], }),

and my vite configuration in my host:

federation({ name: 'host-app', remotes: { remote_app: 'http://remote-app.local/assets/remoteEntry.js', }, filename: 'remoteEntry.js', exposes: { }, shared: ['vue'], }),

and I access the component in host page like this:

`<script setup lang="ts">

import TestComponent from 'remote_app/TestComponent'
</script>

`

I hope you can help me with that issue, Thank you.

@SkyWalker653
Copy link

It looks like there might be a typo in the import statement. It should be:

import TestComponent from 'remote-app/TestComponent';

@annaselh
Copy link
Author

It looks like there might be a typo in the import statement. It should be:

import TestComponent from 'remote-app/TestComponent';

It still not working.

I think it because laravel-vite cannot read path from the url. I try build the remote and the host then it's working fine.

Maybe while using laravel-vue, it must build first and cannot run in development npm run dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants