How to handle Vite's base
config while importing utility modules in serve
mode?
#170
-
I have root project which has The above works fine if I don't add the Note: I have referred this link (single-spa-and-vite-fast-forward-to-vite-plugin-single-spa) but was not able to figure out still Code Snippets I have root project which has
It's usage
Declaration
It's config
Thanks in advance 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
Review the resulting HTML (the rendered page) in developer tools. The HEAD element: What do you have there in terms of scripts and order of scripts? Because your problem seems to be that the import map is not taking. |
Beta Was this translation helpful? Give feedback.
-
Focusing on import-maps
Here is the entire Head element
|
Beta Was this translation helpful? Give feedback.
-
You refer to the module as: import { nameLogger } from '@org/utility' The key part: @org. However, the import map says: "@kd/utility": "http://localhost:9003/src/utility.jsx", The key part: @kd. No matching entry in the import map. |
Beta Was this translation helpful? Give feedback.
-
I modified code so that it would be easier to understand 😮💨 . Anyways, updated the question with the code as is. The issue still persist |
Beta Was this translation helpful? Give feedback.
-
I would require access to a repository that reproduces the problem to help further. I think that maybe what's happening is that Vite is resolving the module name as What I'm saying is: Provide a reproduction that I can access to play with, if possible. If not possible, investigate further on your own, I suppose. I'll try to experiment on my side whenever I have the time, but I don't think I'll have time any time soon (3 weeks). |
Beta Was this translation helpful? Give feedback.
-
There are a few things wrong in your files. For example, the shared import map should not have paths that point to things in the /src folder. Those belong in the DEV import map. Then you have the origin set to localhost on port 9010, don't know why since the project is running from port 9000. Then in the utility project, you're setting the server port, but that's unnecessary as Anyway, your problem comes from how In the end, you can make it work if your import map changes the key BTW, you can also delete the proxy settings in the root config project. Not needed. |
Beta Was this translation helpful? Give feedback.
-
@Khodidas-withLoveKD New version of vite-plugin-externalize-dependencies plugin has been released, with a fix for correctly handling base paths. |
Beta Was this translation helpful? Give feedback.
There are a few things wrong in your files. For example, the shared import map should not have paths that point to things in the /src folder. Those belong in the DEV import map. Then you have the origin set to localhost on port 9010, don't know why since the project is running from port 9000.
Then in the utility project, you're setting the server port, but that's unnecessary as
vite-plugin-single-spa
sets it for you. What's the point of asking the developer to specify the port in two places, right? My plug-in takes care of the preview and server ports for you, as well asserver.origin
.Anyway, your problem comes from how
vite-plugin-externalize-dependencies
work, plus how Vite works. The …