Working example #138
Replies: 1 comment 2 replies
-
Hello, Carl. I have not had time to create a comprehensive example. I do have one in the works, but it is not presentable yet. In the meantime, you should scout this project's dependents to see if anything there fits what you're looking for. Regardless of what you find, you are welcome to try things out for yourself and post any questions or requests for help here in the Discussions section. I reply within 24 hours, as it is in my best interest for people to try the plug-in out and report bugs back to me. This makes my life easier, and it is fun for me, since I enjoy programming very much. Getting StartedYou say you want a Vite root config. No problem. I don't have one ready but any Vite + XXX project created with ParcelsParcels are also super easy: Create a Vite + <Framework of choice>, add Single Export File, Multiple ParcelsThis way would involve having, say, Here's a Svelte sample (I love Svelte): import MyParcelA from './lib/MyParcelA.svelte';
import MyParcelB from './lib/MyParcelB.svelte';
import MyParcelC from './lib/MyParcelC.svelte';
import { cssLifecycleFactory } from 'vite-plugin-single-spa/ex';
// @ts-expect-error
import singleSpaSvelte from 'single-spa-svelte';
const cssLc = cssLifecycleFactory('spa');
export function ParcelAFactory() {
const lc = singleSpaSvelte({ component: MyParcelA });
return {
bootstrap: [cssLc.bootstrap, lc.bootstrap],
mount: [cssLc.mount, lc.mount],
unmount: [cssLc.unmount, lc.unmount],
update: lc.update
};
};
// Similar factories for MyParcelB and MyParcelC How to ConsumeNormally, the Multiple Export Files, One Parcel per Export FileThe other way one can export parcels from a project is to creating multiple entry point files. You could create import MyParcelA from './lib/MyParcelA.svelte';
import { cssLifecycleFactory } from 'vite-plugin-single-spa/ex';
// @ts-expect-error
import singleSpaSvelte from 'single-spa-svelte';
const cssLc = cssLifecycleFactory('parcelA');
// Since there will only be one export in this file, you could opt to change the below to "export default function() {... }" instead.
export function ParcelAFactory() {
const lc = singleSpaSvelte({ component: MyParcelA });
return {
bootstrap: [cssLc.bootstrap, lc.bootstrap],
mount: [cssLc.mount, lc.mount],
unmount: [cssLc.unmount, lc.unmount],
update: lc.update
};
}; Then you create the other entry points for parcels B and C. For this approach then we must deviate from the plug-in's default configuration: Now we have 3 entry points that must be specified in ...
return defineConfig({
plugins: [svelte(), vitePluginSingleSpa({
serverPort: 4111,
spaEntryPoints: ['src/parcelA.ts', 'src/parcelB.ts', 'src/parcelC.ts']
}],
... Differences?As far as recommending one or the other, I probably couldn't. I'll just state this fact: Multiple entry points will most likely create more JS and CSS splits during bundling. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a working example with a vite root config and vite parcel. I am looking for an example that includes routing and parcel integrations if possible.
Beta Was this translation helpful? Give feedback.
All reactions