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

Add vite-plugin-single-spa to Vite Ecosystem #591

Merged
merged 1 commit into from Aug 22, 2023

Conversation

webJose
Copy link
Contributor

@webJose webJose commented Aug 15, 2023

I have created a new Vite plug-in to broaden the possibilities of single-spa in the Vite ecosystem. I have quickly described it here. Thank you.

Copy link
Member

@joeldenning joeldenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have enough time to properly review this, so I'm just going to go ahead and merge it. Thanks for your help with it. I may come back and review it later.

@joeldenning joeldenning merged commit 678e9f3 into single-spa:master Aug 22, 2023
1 check passed
@joeldenning
Copy link
Member

Here was my main hesitation and problem with Vite back when I was trying to get it to work with SystemJS modules. Is that still the case with Vite? I'm hoping to go all native ES modules in production in upcoming single-spa work.

image

https://single-spa.slack.com/archives/C9JV40F7V/p1692667453176669?thread_ts=1692129494.902899&cid=C9JV40F7V

@joeldenning
Copy link
Member

Also see #592 for an update regarding single-spa maintenance

@webJose
Copy link
Contributor Author

webJose commented Aug 23, 2023

Hi. I don't seem to have access to that Slack URL. Anyway, I will be more than glad to chat with you about the plug-in and the problems I have experienced so far as well as the victories on the road so far.

In a nutshell: Vite + XXX projects work. While in serve mode, you can't see assets, though. I tracked the problem in Vite's source code and opened this issue. I don't have much information about how Vite's base property affects other things, so I am unaware if my proposal is enough.

Furthermore, I raised this other issue for Vite's React plug-in. It pertains to an HMR error when the HTML page wasn't produced by this plug-in (because your page is not a Vite project, or because is a Vite project using some other framework than React).

@webJose
Copy link
Contributor Author

webJose commented Aug 23, 2023

Regarding ES modules: They work. The caniuse website says most browsers fully support them. The Chromium browsers (at least) present a bug when the IMO package tries to override maps of type importmap. However, this is overcome by setting the type overridable-importmap. This the plug-in's default map type when used to create root config projects.

I can verify to you that so far, overridable-importmap works perfectly well. All mife's are loaded with ES' dynamic import() and all looks good in the single-spa world.

Ah, yes, one more detail: Vite, while in serve mode (npm run dev) injects a script (@vite/client) that messes up the overriding function of IMO. I overcame this with the plug-in by running a post HTML transformation that injects the import maps and the IMO script at the top.

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

Successfully merging this pull request may close these issues.

None yet

2 participants