-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
fix(dts-plugin): lazy emit subsequent type generations #3345
Conversation
🦋 Changeset detectedLatest commit: e966cd9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
the ci error can be reproduced locally , looks like the webpack types mismatch packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts:109:15 - error TS2554: Expected 2 arguments, but got 3.
109 (err) => {
~~~~~~~~~~
110 if (err) reject(err);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
120 }
~~~~~~~~~~~~~~~~~
121 },
~~~~~~~~~~~~~~~
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
The pull request focuses on improving the behavior and performance of the dts-plugin
module in the context of Module Federation. The key changes include:
- Enhancing the
DTSManager
class to handle various scenarios more gracefully, such as multiple exposed components, empty expose maps, missing remote manifests, and download errors. - Updating the
DtsWorker
to avoid blocking the compilation seal on subsequent type generations, allowing for more efficient type processing. - Improving the handling of type definitions archives, including constructing correct file paths, creating archives, and downloading them with retry logic and error handling.
- Introducing a new
emitTypesFiles
function in theGenerateTypesPlugin
to write the generated types files to the output directory, without blocking the compilation seal.
These changes aim to improve the overall reliability, performance, and error handling of the dts-plugin
module, ensuring a more robust and efficient Module Federation setup.
File Summaries
File | Summary |
---|---|
packages/dts-plugin/src/core/lib/DTSManager.general.spec.ts | The code changes focus on improving the behavior of the DTSManager class in the dts-plugin module. The key modifications are: |
-
The
generateAPITypes
method has been updated to handle both multiple exposed components and empty expose maps, ensuring the correct generation of API types. -
The
requestRemoteManifest
method has been enhanced to handle various scenarios, including non-manifest URLs, manifest URLs with auto publicPath, manifest URLs without API types, and manifest fetch errors. -
The
consumeTargetRemotes
method has been updated to handle the case where the zipUrl is missing, throwing an appropriate error. -
The
updateTypes
method has been modified to handle missing remote options gracefully. -
The
downloadAPITypes
method has been improved to handle missing apiTypeUrl and download errors, and to correctly replace the remote alias in the downloaded content. -
The
consumeAPITypes
method has been updated to handle cases where there are no loaded remote API aliases and when there are existing API types files. |
| packages/dts-plugin/src/core/lib/DtsWorker.spec.ts | The code changes in this file focus on improving the handling of subsequent type generations in the DTS plugin. The key modifications are: -
Ensuring that the compilation seal is not blocked on followup compilations, allowing for more efficient type generation.
-
Implementing graceful handling of worker process termination, including cases where the termination process fails.
-
Introducing debug mode handling, where errors are logged when in debug mode, but not logged when in non-debug mode. |
| packages/dts-plugin/src/core/lib/archiveHandler.test.ts | The code changes in this file focus on improving the handling of type definitions archives in thedts-plugin
module. The key modifications are: -
The
retrieveTypesZipPath
andretrieveTypesArchiveDestinationPath
functions have been added to handle the construction of zip file paths and destination paths for type definitions, respectively. -
The
createTypesArchive
function has been enhanced to correctly create the type definitions archive, handling both the presence and absence of type definition files, as well as nested directory structures. -
The
downloadTypesArchive
function has been updated to handle various scenarios, including retrying on network failures, gracefully handling empty archives, cleaning up existing folders, and continuing without error whenabortOnError
is set tofalse
. |
| packages/dts-plugin/src/core/lib/consumeTypes.spec.ts | The code changes introduce a new test suite for theconsumeTypes
function, which is responsible for consuming types in the context of a module federation setup. The tests cover the creation of aDTSManager
instance with different options, as well as the handling of errors that may occur during theconsumeTypes
operation. |
| packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts | The code changes introduce a new functionemitTypesFiles
that is responsible for writing the generated types files to the output directory. This function is called when the plugin has already compiled once, to avoid blocking the compilation seal on subsequent compilations. The changes also include some additional logic to determine the correct output path for the types files based on the module federation configuration. |
.changeset/twelve-dingos-ring.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you're using Cursor, nice! Recently I've tried the "Agentic" Windsurf , but it doesn't work with Windows WSL. And then Cursor was updated with it's own version of Agents in the Composer.
John Lindquist has posted some nice vids on the subject matter:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agent does pretty good job in cursor, however llama 3.3 is getting pretty good, would be nice to try it out since unlimited tokens is a game changer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For LLama it can get more expensive if you use it via some API like Perplexity. Dunno about Amazon Bedrock.
Running it locally, an underperforming 7b model on a 4090 is probably not an option.
Buying an H100 for tens of thousands is not an option too.
Btw, Google is cooking too
./packages/typescript | ||
./packages/native-* | ||
./apps | ||
packages/storybook-addon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder why these remain with ./
prefix
./tmp
./scripts
./.git
'compiledTypesFolder', | ||
); | ||
beforeEach(() => { | ||
vi.clearAllMocks(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to not put
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
clearMocks: true,
into vitest.config.ts
?
1cb9405
to
c6f2c41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incremental Review
Comments posted: 9
Configuration
Squadron Mode: essential
Commits Reviewed
8e172c84773d04a4ca25d6e50f8be41306382483...9eeaa440c4243b9b076e9f8f54afc74b1fcca081
Files Reviewed
- packages/dts-plugin/src/plugins/GenerateTypesPlugin.ts
- packages/dts-plugin/src/core/lib/archiveHandler.test.ts
- packages/dts-plugin/src/core/lib/DtsWorker.spec.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .changeset/twelve-dingos-ring.md
- .cursorignore
- apps/manifest-demo/3010-rspack-provider/rspack.config.js
- apps/react-ts-host/webpack.config.js
- apps/react-ts-nested-remote/webpack.config.js
- apps/react-ts-remote/rspack.config.js
- apps/react-ts-remote/webpack.config.js
- package.json
Description
Do not block compilation seal on followup compilations
Related Issue
#3110 (comment)
Types of changes
Checklist