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

Importing a component from one application into another application #329

Closed
veeral-patel opened this issue Aug 6, 2019 · 3 comments
Closed

Comments

@veeral-patel
Copy link

veeral-patel commented Aug 6, 2019

First of all, thank you for this great framework!

So say I have two Vue.js applications, A and B, that I'm combining using single-spa. Application A has a toast component that I'd like to use in application B.

This page indicates two things I can do:

  1. Import/export components
  2. Use single-spa parcels

I would prefer to import/export components over using parcels -- would something like this work?

Application A

spa/src/A/components/MyToast.vue

class MyToast extends Vue {
...
}

export default MyToast;

Application B

spa/src/B/components/FancyButton.vue

import MyToast from 'spa/src/A/components/MyToast'

class FancyButton extends Vue {
// use MyToast component here
}

Do you see any issues with doing something like this? Thanks again for your help!

@frehner
Copy link
Member

frehner commented Aug 6, 2019

That's exactly correct.

If you are using the recommended setup then it will all happen at run-time in the browser and you can deploy AppA and AppB independently.

If not, then you're probably in a position where they have to be bundled into the same package, so it may not get you much in the end.

👍

@joeldenning
Copy link
Member

Also, see related single-spa/single-spa-vue#14 which will make using parcels in Vue a lot easier. If you'd be interested in collaborating on that, I'd be happy to show you were we could get started on it.

@veeral-patel
Copy link
Author

veeral-patel commented Aug 7, 2019

Thank you @frehner @joeldenning! I haven't tried out either method yet, but I'll do that and raise another issue if I have any problems.

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

No branches or pull requests

3 participants