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

@module-federation/typescript 2.0.3 cause html-webpack-plugin throw Error: Child compilation has already started #455

Closed
liaoyu opened this issue Dec 25, 2022 · 4 comments · Fixed by #492
Labels
area: Typescript Plugin 🐞 bug Something isn't working good first issue Good for newcomers released on @canary Typescript Typescript package identifier

Comments

@liaoyu
Copy link

liaoyu commented Dec 25, 2022

html-webpack-plugin throw:

[webpack-cli] Error: Child compilation has already started

app1/node_modules/html-webpack-plugin/lib/cached-child-compiler.js:186:27
    at Hook.eval [as callAsync] (eval at create (app1/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)

Only when remotes have multi app will cause this error,If remotes only has app2 it works.

new FederatedTypesPlugin({
  federationConfig: {
    name: 'app1',
    remotes: {
      app2: 'app2@http://localhost:3002/remoteEntry.js',
      app3: 'app2@http://localhost:3003/remoteEntry.js'
    },
    shared: ['react', 'react-dom'],
  }
})

Analysis of causes

Child compilation has already started ref: https://github.com/jantimon/html-webpack-plugin/blob/d5ce5a8f2d12a2450a65ec51c285dd54e36cd921/lib/cached-child-compiler.js#L182-L187

Possibly reason is webpack callback invoked many times.

https://github.com/module-federation/universe/blob/d97d764ded8d3cb1b5e04829eaf226f0c5a3baa3/packages/typescript/src/plugins/FederatedTypesPlugin.ts#L204-L207

Reappearance Env

  • node v16.0.0
  • webpack 5.72.1
  • html-webpack-plugin 5.5.0
  • @module-federation/typescript 2.0.3

Reappearance demo: https://github.com/liaoyu/module-federation-typescript-v2-issue-reappearance

@pavandv pavandv added 🐞 bug Something isn't working Typescript Typescript package identifier area: Typescript Plugin good first issue Good for newcomers labels Dec 26, 2022
@ilteoood
Copy link
Contributor

ilteoood commented Jan 4, 2023

Hey @liaoyu, I'm developing a plugin for this that is bundler-agnostic: https://github.com/ilteoood/native-federation-typescript

If you have some time, would you like to test it?

@dmcgoughpax8
Copy link
Contributor

👀 I'm also running into this issue

@ilteoood
Copy link
Contributor

ilteoood commented Jan 10, 2023

@dmcgoughpax8 may I ask you to test my plugin too? More details in previous comments

@pavandv pavandv linked a pull request Jan 11, 2023 that will close this issue
ScriptedAlchemy added a commit that referenced this issue Jan 12, 2023
* Remove module side effects

* Remove var

* fix(typescript): generated types doesn't get included in types index (#487)

* fix(typescript): defined exposes declaration files now consumable
* fix(typescript): generateTypesStats now accounts for absolute paths when setting filename

* fix: [node] build error when no remotes are used (#500)

* fix(federatedtypesplugin): modify remote url used to import remote types (#496)

url derived from remote components urls previously failed when fetching types when package has an
organization scope. by taking the split index and taking a substring of the remote url at that index
fixes this issue

fix #495

Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>

* feat: [node] build error when no remotes are used

* chore(node): release version 0.10.0

* chore(nextjs-mf): release version 6.0.2

* fix(typescript): unable to download types from multiple remotes (#492)

fixes #455

* Utilities - add license information (#491)

* add license information to utilities

* Utilities - Add LICENSE file

Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>

* Regen lock file

* fix(federatedtypesplugin): modify remote url used to import remote types (#496)

url derived from remote components urls previously failed when fetching types when package has an
organization scope. by taking the split index and taking a substring of the remote url at that index
fixes this issue

fix #495

Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>

Co-authored-by: dmcgoughpax8 <dmcgough@pax8.com>
Co-authored-by: Zack Jackson <zackary.l.jackson@gmail.com>
Co-authored-by: Austin Howard <ahoward@austinhoward.tech>
Co-authored-by: GitHub Bot <gituser@example.com>
Co-authored-by: jon <jonathanceddy@gmail.com>
Copy link
Contributor

🎉 This issue has been resolved in version 1.0.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Typescript Plugin 🐞 bug Something isn't working good first issue Good for newcomers released on @canary Typescript Typescript package identifier
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants