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

feat: new plugin configuration #28

Merged
merged 13 commits into from
Aug 1, 2024

Conversation

zhangHongEn
Copy link
Contributor

No description provided.

@timdamen
Copy link

timdamen commented Jul 24, 2024

Looks great @zhangHongEn, the vite example is building and running fine. Only I'm not sure how to instead of console logging the remote components, display them on the screen. Could you provide an example of it?

@gioboa
Copy link
Collaborator

gioboa commented Jul 24, 2024

Thanks @zhangHongEn for your contribution.

@zhangHongEn
Copy link
Contributor Author

zhangHongEn commented Jul 24, 2024

Looks great @zhangHongEn, the vite example is building and running fine. Only I'm not sure how to instead of console logging the remote components, display them on the screen. Could you provide an example of it?
@timdamen Already ok

@gioboa
Copy link
Collaborator

gioboa commented Jul 29, 2024

That's a great piece of code 👏
I'm wondering if we can include module-federation-vite code inside the repository rather than using the dependency (see image below)

Screenshot_20240729-222117.jpg

@zhangHongEn
Copy link
Contributor Author

zhangHongEn commented Jul 30, 2024

@gioboa 6080943

Copy link
Contributor

Choose a reason for hiding this comment

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

@zhangHongEn do we need to include dist folder here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Demo output, no effect

@husayt
Copy link
Contributor

husayt commented Jul 30, 2024

@gioboa would still be good to include your original native-federation wrapper under either /module-federation/vite/packages/native-federation or /module-federation/native-federation once this merged. This repo will have best of both worlds literally then: Module Federation for vite and Native Federation for Vite.

Thank you

@gioboa
Copy link
Collaborator

gioboa commented Jul 30, 2024

@gioboa would still be good to include your original native-federation wrapper under either /module-federation/vite/packages/native-federation or /module-federation/native-federation once this merged. This repo will have best of both worlds literally then: Module Federation for vite and Native Federation for Vite.

Thank you

The current implementation is not working with the latest esbuild updates though.
Drop the old code sounds correct to me.

@gioboa
Copy link
Collaborator

gioboa commented Jul 30, 2024

@zhangHongEn thanks for rocking with this PR. I'm wondering if we can use
'@module-federation/esbuild' code in this implementation? #27 tried to implement the functionality but it's abandoned I guess

@zhangHongEn
Copy link
Contributor Author

@zhangHongEn thanks for rocking with this PR. I'm wondering if we can use '@module-federation/esbuild' code in this implementation? #27 tried to implement the functionality but it's abandoned I guess

Vite's temporary dev mode uses esbuild. I have tried configuring @module-federation/esbuild in vite.config.js optimizeDeps.esbuildOptions.plugins, but it seems to conflict with vite's pre-built

@husayt
Copy link
Contributor

husayt commented Jul 30, 2024

@zhangHongEn thanks for rocking with this PR. I'm wondering if we can use '@module-federation/esbuild' code in this implementation? #27 tried to implement the functionality but it's abandoned I guess

While it might be useful to look into https://www.npmjs.com/package/@module-federation/esbuild?activeTab=code this for reference, I would not recommend using that library as Vite wraps esbuild/rollup and tries to provide unified interface, so best approach to use vite holistically.

@zhangHongEn
Copy link
Contributor Author

@zhangHongEn thanks for rocking with this PR. I'm wondering if we can use '@module-federation/esbuild' code in this implementation? #27 tried to implement the functionality but it's abandoned I guess

While it might be useful to look into https://www.npmjs.com/package/@module-federation/esbuild?activeTab=code this for reference, I would not recommend using that library as Vite wraps esbuild/rollup and tries to provide unified interface, so best approach to use vite holistically.

Yes, the vite plugin and esbuild plugin are independent of each other

@husayt
Copy link
Contributor

husayt commented Jul 31, 2024

@gioboa is there anything else blocking this PR's merge. Will be great to get this out to keep momentum on.

README.md Show resolved Hide resolved
package.json Outdated
"build": "npx -y npm-run-all --parallel build:examples-vite build:examples-rust",
"preview": "cd packages/examples-vite && npm run preview"
},
"author": {
Copy link
Contributor

Choose a reason for hiding this comment

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

@zhangHongEn at least you should have your name under

"contributors": []

This is great effort and needs to be recognised. Thank you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your recognition

@gioboa
Copy link
Collaborator

gioboa commented Jul 31, 2024

@husayt this is a good POC, but I can't release a new version of the library with this code.
I'll try to adapt this code to and cut a new release.
I also need to convert most of the files to TypeScript because right now are in pure JavaScript.


I tried to use this code and the module-federation-vite package too in this repo vue-microfrontend-demo but I can't get it to work.
@zhangHongEn Can you open a PR in that repo to show me how replace the old code with the new one pls?

@zhangHongEn
Copy link
Contributor Author

@husayt this is a good POC, but I can't release a new version of the library with this code. I'll try to adapt this code to and cut a new release. I also need to convert most of the files to TypeScript because right now are in pure JavaScript.

I tried to use this code and the module-federation-vite package too in this repo vue-microfrontend-demo but I can't get it to work. @zhangHongEn Can you open a PR in that repo to show me how replace the old code with the new one pls?

It's a good test scenario indeed.
gioboa/vue-microfrontend-demo#8

@gioboa
Copy link
Collaborator

gioboa commented Jul 31, 2024

gioboa/vue-microfrontend-demo#8

Thanks 🚀

@zhangHongEn
Copy link
Contributor Author

zhangHongEn commented Aug 1, 2024

@gioboa
Please create a new branch and merge the code first. I have received some issues and PRs and need to synchronize the code.
Please give me permission so that I can quickly merge in the new non-trunk branch. Before the complete merge, I will publish the npm module-federation-vite package for use

zhangHongEn/module-federation-vite#4

@gioboa
Copy link
Collaborator

gioboa commented Aug 1, 2024

gioboa/vue-microfrontend-demo#8

Thanks 🚀

Thanks for your commitment.
I tested your PR in the Vue mfe example and it's not working, I have multiple errors during the build process.
I would like to have a fully working application here -> gioboa/vue-microfrontend-demo#8
before going on with this new implementation.

@zhangHongEn
Copy link
Contributor Author

gioboa/vue-microfrontend-demo#8

Thanks 🚀

Thanks for your commitment. I tested your PR in the Vue mfe example and it's not working, I have multiple errors during the build process. I would like to have a fully working application here -> gioboa/vue-microfrontend-demo#8 before going on with this new implementation.

Done, this is not a plugin issue, but I will fix it in the plugin

 manualChunks(id) {
  if (id.indexOf("/@module-federation/runtime") > -1) {
    return "mfruntime";
  }
}

@zhangHongEn
Copy link
Contributor Author

@gioboa Please create a new branch and merge the code first. I have received some issues and PRs and need to synchronize the code. Please give me permission so that I can quickly merge in the new non-trunk branch. Before the complete merge, I will publish the npm module-federation-vite package for use

zhangHongEn/module-federation-vite#4

@gioboa Can we create a new non-main branch and work together first?

@gioboa gioboa changed the base branch from main to new-config August 1, 2024 12:59
@gioboa
Copy link
Collaborator

gioboa commented Aug 1, 2024

I created a new-config branch

@gioboa gioboa changed the title implement vite feat: new plugin configuration Aug 1, 2024
@gioboa gioboa merged commit 8dfd32c into module-federation:new-config Aug 1, 2024
@husayt
Copy link
Contributor

husayt commented Aug 1, 2024

I created a new-config branch

@zhangHongEn you can create a new PR for follow up changes.

But here are some fixes which would save you time

in pnpm-workspace.yaml

packages:
  - 'examples/*'
  - '.'

Replace 'module-federation-vite' to '@module-federation/vite' everywhere

Replace import path from 'path'; to import {join} from 'path';

remove export default federation; as only named export should be there

and still I couldn't get new-config branch working for me

@zhangHongEn
Copy link
Contributor Author

@husayt #29

@luokuning
Copy link

@zhangHongEn Awesome! Do we need to publish a new version and update doc to provide the latest configuration?

@zhangHongEn
Copy link
Contributor Author

zhangHongEn commented Aug 28, 2024

@zhangHongEn Awesome! Do we need to publish a new version and update doc to provide the latest configuration?

I will solve these two important problems tonight. #66 #40
Currently still publishing @module-federation/vite@next to npm

@luokuning
Copy link

@zhangHongEn Thank you for your effort! Looking forward to the release of version 1.0.

gioboa added a commit that referenced this pull request Sep 15, 2024
* feat: new plugin configuration (#28)

* init ts (#29)

* fix: tsconfig

* fix: issues 2 3

* feat: rust demo build and preview

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* feat: support runtime plugins (#30)

Co-authored-by: Sergey Melukov <s.melukov@vk.team>

* fix: Ensure @module-federation/runtime singleton (#31)

* fix: Ensure @module-federation/runtime singleton

* fix: build preview

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* feat: add packageManager

* fix: remoteEntry support hash; format dynamic es module (#35)

* 1.0.0-alpha-7c3ba59

* fix: remove default export (#37)

* fix: remove pkg-pr-new

* chore: add PR title check

* 1.0.0-alpha-ffc6e23

* fix: #36 and dynamic import (#38)

* fix: dynamic import

* fix: #36

* 1.0.0-alpha-54ad191

* 1.0.0-alpha-80b7215

* fix: #39 #44 #45 (#46)

* fix: pre-bunding

* feat: add pre-bunding subdependencies demo

* fix: exposes .

* fix: remotes support namespace

* 1.0.0-alpha-4a73cd4

* fix: windows remoteEntry error (#48)

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* feat: updated examples (#50)

* 1.0.0-alpha-def937d

* fix updated examples (#51)

* fix: #47 (#53)

* 1.0.0-alpha-10e1f83

* improved  examples with MUI and etc (#55)

* fix: #56 #41 (#58)

* 1.0.0-alpha-6cae9ab

* mfruntime update and new examples (#62)

* fix: #61 (#63)

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* 1.0.0-alpha-51eeeb6

* feat: shared-slash (#67)

* feat: shared slash

* feat: shared slash

* feat: preview examples

* feat: remove an-empty-js-file

* fix: remove console

* optimization: reduce dev mode page reload

* Optimize code and comments

* fix: 64

* fix: only slash

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* 1.0.0-alpha-f87d7d3

* fix: nx #40 (#69)

* 1.0.0-alpha-661e052

* fix: #68 (#71)

* fix: #68

* fix: #68

* fix: windows Multi-Pack

* Optimization: Reduce file writing

* Optimization: code format

* fix: support nx monorepo

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* 1.0.0-alpha-1aa30c0

* fix: monorepo (#72)

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* feat: add Nuxt example (#75)

* Add Nuxt host example

* Gitignore generated .__mf__win folder

---------

Co-authored-by: David Sellén <david.sellen@bolagsverket.se>
Co-authored-by: David Sellén <david.sellen@gmail.com>

* chore: update module federation and more examples (#81)

* fix: #78 (#79)

* fix: #78

* Update src/utils/normalizeOptimizeDeps.ts

Co-authored-by: Sergey Melyukov <s.melukov@gmail.com>

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>
Co-authored-by: Sergey Melyukov <s.melukov@gmail.com>

* fix: #77 (#82)

* 1.0.0-alpha-2f53b4e

* docs: update Vue example link

* docs: update React example link

* docs: update README

* fix: Remote virtual module path (#84)

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

* 1.0.0-alpha-c13dc95

* feat: add improvements (#86)

* fix: Remote virtual module path

* examples: nuxt(Unfinished)

* feat: mf-manifest; Register remote on demand

* doc: roadmap

* doc: npm url

* Delete src/utils/getLocalSharedImportMap_windows.ts

---------

Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>

---------

Co-authored-by: zhn <zhang_h_n@163.com>
Co-authored-by: 张洪恩 <zhanghongen@bwcj.com>
Co-authored-by: Sergey Melyukov <s.melukov@gmail.com>
Co-authored-by: Sergey Melukov <s.melukov@vk.team>
Co-authored-by: HG <husayt@gmail.com>
Co-authored-by: David sellén <sellen.david@gmail.com>
Co-authored-by: David Sellén <david.sellen@bolagsverket.se>
Co-authored-by: David Sellén <david.sellen@gmail.com>
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

Successfully merging this pull request may close these issues.

5 participants