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 microfrontend support to vue. #16880

Merged
merged 30 commits into from
Nov 17, 2021
Merged

Conversation

mshima
Copy link
Member

@mshima mshima commented Oct 30, 2021

Vue modularization for microservice:

  • Implement entities component. Declare every entity service here instead of at main.
  • Implement entities menu component. So gateway will not need to add menus when adding entities.
  • Move global variables to declarations.d.ts

Webpack:

  • Don’t set custom names. Defaults are optimized for features like cachings.
  • Remove additional entry points. They are not required and conflicts with module federation.
  • Remove custom chunks definitions.
  • Don’t add HotModulePlugin. Added automatically by webpack when hot is true.
  • Don’t add NoEmitOnErrorPlugin. A missing page seems worse than a broken page.
  • Remove fallback config. Not required anymore. Node features are not exported by webpack anymore.
  • Migrate from deprecated url-loader to assets module.
  • Move devServer config to common, so it's possible to webpack serve --mode production

Microfrontend details:

  • Microfrontends needs to be started and functional, remote is loaded eagerly.
    I've tried different approaches to lazy load without success.
  • Gateway doesn't need to be regenerated when adding new entities.
  • Entity page is using microservice/entity instead of just entity. Example http://localhost:8080/blog/post.

Closes #16276.


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@mshima
Copy link
Member Author

mshima commented Oct 30, 2021

Just missing entities-menu test.

@mshima mshima requested a review from mraible October 30, 2021 15:39
@mshima mshima mentioned this pull request Oct 30, 2021
6 tasks
@mraible
Copy link
Contributor

mraible commented Oct 30, 2021

I'll look into this as soon as I can. It might take until Monday.

@pascalgrimaud
Copy link
Member

@mshima @mraible : it looks like a really complex PR. Keep in mind, we should not introduce breaking change in existing v7. If it's the case, it should be done on v8 branch

@mshima
Copy link
Member Author

mshima commented Nov 1, 2021

@pascalgrimaud I think this is not a breaking change.
IMO it's much less disruptive than a minor spring release or bootstrap 5 or dropping java 1.8 support.
The PR is big but most of the changes are new implementations or prettier.
Some adjusts to the build stack like removing deprecated webpack plugins and cleanup.

Anyway, if you want I can try to make more changes optional to microfrontend.

IMO breaking changes to JHipster should be jdl, the generators and some generated source features, not the source itself.
It's quite easy to keep old code with .yo-resove:

src/main/webapp skip
src/test/javascript skip

@mshima
Copy link
Member Author

mshima commented Nov 2, 2021

@mraible I've always used reused https://github.com/mshima/generator-jhipster/blob/main/test-integration/jdl-samples/blog-store/blog-store.jdl and used --client-framework vue.
I didn't realized the jdl is removing clientFramework and setting the default afterwards. So it needs change:

delete options[CLIENT_FRAMEWORK];
delete options[CLIENT_THEME];
delete options[CLIENT_THEME_VARIANT];
delete options[SKIP_SERVER];
delete options[WITH_ADMIN_UI];

@mshima mshima marked this pull request as ready for review November 9, 2021 19:34
@mshima
Copy link
Member Author

mshima commented Nov 9, 2021

@mraible jdl should be fixed now.

@mraible
Copy link
Contributor

mraible commented Nov 11, 2021

I tried it again a few minutes ago. If I just start the gateway and store, the gateway UI fails because it can't find blog. Is that expected? I think it'd be nice if you could just start the gateway + the microservice you want to work on.

Screen Shot 2021-11-11 at 12 48 17 PM

If I start the blog app, everything works fine. However, the blog's i18n translations don't seem to come through. They work fine on the product entity.

Screen Shot 2021-11-11 at 12 52 31 PM

@mshima
Copy link
Member Author

mshima commented Nov 11, 2021

I tried it again a few minutes ago. If I just start the gateway and store, the gateway UI fails because it can't find blog. Is that expected? I think it'd be nice if you could just start the gateway + the microservice you want to work on.

You can start the gateway and use the microservice frontend standalone.
I couldn't find a way to make vue gateway happy with the missing remote. Probably we would need vue3 suspense component https://v3.vuejs.org/guide/migration/suspense.html.
I have tried various approaches.

If I start the blog app, everything works fine. However, the blog's i18n translations don't seem to come through. They work fine on the product entity.

That's weird, if store app (product) works, blog app should work too.

@mshima
Copy link
Member Author

mshima commented Nov 12, 2021

I tried it again a few minutes ago. If I just start the gateway and store, the gateway UI fails because it can't find blog. Is that expected? I think it'd be nice if you could just start the gateway + the microservice you want to work on.

Did another try, and I've managed to workaround the missing remote.

If I start the blog app, everything works fine. However, the blog's i18n translations don't seem to come through. They work fine on the product entity.

Indeed, microservice translations of one app was been loaded before the gateway and been overridden.

@mraible
Copy link
Contributor

mraible commented Nov 15, 2021

I'm testing this again with the latest changes.

Copy link
Contributor

@mraible mraible left a comment

Choose a reason for hiding this comment

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

I tested this again today and things seem to work well. I did notice a couple of minor issues:

  1. The UI seems to need a bit more padding. The buttons and alerts stretch to the edge of the screen.

Screen Shot 2021-11-15 at 2 20 42 PM

  1. The view screen shows everything jumbled together instead of stacked neatly.

Screen Shot 2021-11-15 at 2 23 28 PM

@mraible
Copy link
Contributor

mraible commented Nov 15, 2021

I couldn't find where the index.html message is set, but I think we should change it from:

Microfrontends packages don't provide a stand-alone front-end. Packaged microfrontend should be accessed through a JHipster gateway.

To:

JHipster's microfrontends implementation doesn't provide a stand-alone UI. Packaged microfrontends should be accessed through a JHipster gateway.

@mshima
Copy link
Member Author

mshima commented Nov 15, 2021

Ought I've removed global.scss in some rebase.

@mraible mraible mentioned this pull request Nov 16, 2021
1 task
@pascalgrimaud
Copy link
Member

@mraible @mshima : plz, don't forget to add some documentation. See #17016

We have a lot of new features the last months, but no documentation at all :-(

@mshima mshima merged commit 20d26f4 into jhipster:main Nov 17, 2021
@mshima mshima deleted the skip_ci-microfrontend_vue branch November 17, 2021 01:37
@pascalgrimaud pascalgrimaud added this to the 7.4.0 milestone Nov 19, 2021
@DanielFran DanielFran mentioned this pull request Mar 22, 2022
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Micro Frontend support to Vue
4 participants