Closed hector-jaraba-NWSE closed 10 months ago
Hello! I haven't tested with Vite v5 yet. If you can reproduce this with Vite v4.5.0, then I'll have a look. Otherwise, I would conclude this is a Vite v5 problem that will be addressed once I upgrade this package for it. Sounds good?
Sure! I downgraded to vite 4.5.0 and I still getting the same issue.
Ok, then. I'll have a look at night. I am planning on doing npm create vite@latest
, choose React + TS + SWC and then make a micro-frontend out of it. Let me know if this is not enough to reproduce the issue. Otherwise, I'll come back with the results.
Ok, as promised, I looked. Spoiler: Could not reproduce.
My Test
npm create vite@latest
. Select React + TS + SWC. I got Vite v5.0.3.npm i
.single-spa
packages to make the project a micro-frontend project: npm i vite-plugin-single-spa single-spa-react --force
. The --force
switch is needed because this plug-in is not yet tested with Vite v5. This makes npm
reject installation unless this switch is used.vite.config.ts
. See below for code.src/spa.tsx
. See below for code.npm run build
. Success. See below for the result.// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import vitePluginSingleSpa from 'vite-plugin-single-spa'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), vitePluginSingleSpa({
serverPort: 4555,
spaEntryPoints: "src/spa.tsx"
})],
})
// src/spa.tsx
import React from 'react';
import ReactDOMClient from 'react-dom/client';
import App from './App';
// @ts-expect-error
import singleSpaReact from 'single-spa-react';
export const { bootstrap, mount, unmount } = singleSpaReact({
React,
ReactDOMClient,
rootComponent: App,
errorBoundary(err: any, _info: any, _props: any) {
return <div>Error!<br />{err}</div>
}
});
PS C:\...\VpssBugTest> npm run build
> vpssbugtest@0.0.0 build
> tsc && vite build
vite v5.0.3 building for production...
✓ 32 modules transformed.
dist/assets/react-h3aPdYU7.svg 4.13 kB │ gzip: 2.14 kB
dist/assets/vpss(vpssbugtest)spa-cfVfczdt.css 0.48 kB │ gzip: 0.31 kB
dist/spa.js 149.92 kB │ gzip: 47.84 kB
✓ built in 559ms
If you can provide a project that reproduces the issue, it is welcome.
Thanks for the quick reply! I will try to create the same POC as yours and add all the plugins and the vite config that I'm using to try to reproduce the issue, I will let you know!
There you go: https://github.com/hector-jaraba/mfe-example
I created this repo with the bug, if you run yarn build
you should be able to reproduce it
Hello, I'll try it out, but I don't use yarn. I guess I should ask repro's with npm.
Fixed in v0.5.2.
Hello, first of all thanks for this incredible work!
I'm having issues with the version 0.4.0
I'm getting the following error when building,
I'm using:
and also styled components, any idea?
Thanks!