Import module error in spa.tsx when running react microfrontend #193
-
Describe the bugI created a root config and application using the single-spa CLI tool and all works fine. I followed the guidelines in their docs (https://single-spa.js.org/docs/ecosystem-vite#micro-frontend-projects), as well as your readme, for adding an application for vite react ts. I'm getting the error below inside the Project type: [ ] Root Config [x] Micro-frontend/parcel |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
You're most likely using SystemJS modules in the root config project. Did you make the change to ES modules? |
Beta Was this translation helpful? Give feedback.
-
I see in the docs they mention that using their root config approach is recommended. Is there a way to mix their approach with SystemJS for root configs and your approach for Vite apps? Or do I have to use your Vite root config approach to get this working? |
Beta Was this translation helpful? Give feedback.
-
I have never tested my plug-in with SystemJS modules. Feel free to do so. Once a guy told me that works just fine. This is set in Vite options, completely outside my plug-in. It is a rollup option (the output format). Look the setting up, and set it to Now, having said that, maybe you should follow the instructions of creating a root config project using my plug-in. Then you'll be working with ES modules, HMR will probably work for you, and overall things will be simpler. |
Beta Was this translation helpful? Give feedback.
-
Thanks so much for the feedback, this is really helpful! Just one last question, I don't see any mention of managing layouts with your root config approach (although I may have missed it). In my case I'd use a react implementation of Vite for my root config. Would I then use something like react router for handling layout instead of the single-spa layout engine? |
Beta Was this translation helpful? Give feedback.
-
I don't find single-spa's layout engine helpful. I never use it. I always do I am converting this to a discussion. I encourage you to come back to this discussion and post your findings around this React-specific topics, so others can benefit from your experience. |
Beta Was this translation helpful? Give feedback.
I have never tested my plug-in with SystemJS modules. Feel free to do so. Once a guy told me that works just fine. This is set in Vite options, completely outside my plug-in. It is a rollup option (the output format). Look the setting up, and set it to
'system'
. Note, however, that Vite is incapable of serving SystemJS modules while in serve mode (npm run dev
). If you do SystemJS, you can only work locally with built projects. Forget HMR.Now, having said that, maybe you should follow the instructions of creating a root config project using my plug-in. Then you'll be working with ES modules, HMR will probably work for you, and overall things will be simpler.