Skip to content

chore(dts-plugin): check types archive url and optimize the error msg #3768

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silly-experts-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/dts-plugin': patch
---

chore(dts-plugin): check types archive url and optimize the error msg
2 changes: 1 addition & 1 deletion packages/dts-plugin/src/core/lib/archiveHandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ describe('archiveHandler', () => {
// Only verify the URL and responseType
const axiosGetMock = vi.mocked(axios.get);
const [[url, options]] = axiosGetMock.mock.calls;
expect(url).toBe(fileToDownload);
expect(url).toBe(new URL(fileToDownload).href);
expect(options.responseType).toBe('arraybuffer');
});

Expand Down
4 changes: 2 additions & 2 deletions packages/dts-plugin/src/core/lib/archiveHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {

while (retries++ < hostOptions.maxRetries) {
try {
const url = fileToDownload;
const url = new URL(fileToDownload).href;
const response = await axiosGet(url, {
responseType: 'arraybuffer',
timeout: hostOptions.timeout,
Expand Down Expand Up @@ -107,7 +107,7 @@ export const downloadTypesArchive = (hostOptions: Required<HostOptions>) => {
);
if (retries >= hostOptions.maxRetries) {
logger.error(
`Failed to download ${fileToDownload}, you can set FEDERATION_DEBUG=true to see detail message.`,
`Failed to download types archive from "${fileToDownload}". Set FEDERATION_DEBUG=true for details.`,
);
if (hostOptions.abortOnError !== false) {
throw error;
Expand Down
Loading