Skip to content

Commit

Permalink
fix: changed startup compilation order in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-pribilinskiy committed Sep 22, 2022
1 parent 608fa56 commit 49113a9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ changed.
Every time a `d.ts` file is downloaded, webpack recompiles the whole bundle because the watcher compares the timestamp
only, which is updated on every download.

| Package | Emitted destination | Download destination | Synchronization/[compile hooks](https://webpack.js.org/api/compiler-hooks/) |
|---------------------------------------------------|------------------------------------------------------|----------------------|----------------------------------------------------------------------------------------------------------|
| @touk/federated-types | file in <br> `node_modules/@types/__federated_types` | - | - |
| ruanyl/dts-loader | folders in <br> `.wp_federation` | - | - |
| ruanyl/webpack-remote-types-plugin | - | `types/[name]-dts` | download on `beforeRun` and `watchRun` |
| @module-federation/typescript | folders in <br> `dist/@mf-typescript` | `@mf-typescript` | compile and download on `afterCompile` (leads to double compile), <br> redo every 1 minute when idle |
| @cloudbeds/webpack-module-federation-types-plugin | file in <br> `dist/@types` | `src/@types/remotes` | download on startup, <br> compile `afterEmit`, <br> download every 1 minute or custom interval when idle |
| Package | Emitted destination | Download destination | Synchronization/[compile hooks](https://webpack.js.org/api/compiler-hooks/) |
|---------------------------------------------------|------------------------------------------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| @touk/federated-types | file in <br> `node_modules/@types/__federated_types` | - | - |
| ruanyl/dts-loader | folders in <br> `.wp_federation` | - | - |
| ruanyl/webpack-remote-types-plugin | - | `types/[name]-dts` | download on `beforeRun` and `watchRun` |
| @module-federation/typescript | folders in <br> `dist/@mf-typescript` | `@mf-typescript` | compile and download on `afterCompile` (leads to double compile), <br> redo every 1 minute when idle |
| @cloudbeds/webpack-module-federation-types-plugin | file in <br> `dist/@types` | `src/@types/remotes` | download on startup with `beforeRun` for build mode and `watchClose` after first compilation in watch mode <br> Compile `afterEmit` <br> Download every 1 minute or custom interval when idle |


4 changes: 2 additions & 2 deletions src/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function installPlugin(
beforeRun: {
tapPromise: (_, callback) => callback({} as Compiler) as unknown,
},
watchRun: {
tapPromise: (_, callback) => callback({} as Compiler) as unknown,
watchClose: {
tap: (_, callback) => callback() as unknown,
},
},
} as Compiler);
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ModuleFederationTypesPlugin implements WebpackPluginInstance {
logger.log('Downloading types on startup');
return downloadRemoteTypes();
});
compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, () => {
compiler.hooks.watchClose.tap(PLUGIN_NAME, () => {
if (!isDownloadedOnce) {
logger.log('Downloading types on startup');
return downloadRemoteTypes();
Expand Down

0 comments on commit 49113a9

Please sign in to comment.