Skip to content

Conversation

@Timeless0911
Copy link
Contributor

Summary

clean declaration maps before the build starts

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 24, 2025 12:21
Copilot finished reviewing on behalf of Timeless0911 November 24, 2025 12:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for cleaning declaration map files (.d.ts.map, .d.cts.map, .d.mts.map) before the build starts, ensuring that stale declaration map files are removed along with the declaration files themselves.

  • Extended the cleanDtsFiles function to include declaration map file patterns
  • Updated the corresponding comment to reflect that both declaration files and maps are cleaned
  • Enhanced test utilities to create and verify cleanup of declaration map files

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/plugin-dts/src/utils.ts Added glob patterns for .d.ts.map, .d.cts.map, and .d.mts.map files to the cleanDtsFiles function
packages/plugin-dts/src/index.ts Updated comment to clarify that both dts files and maps are cleaned
tests/scripts/shared.ts Added creation of temporary declaration map files in the test helper to verify they are properly cleaned
Comments suppressed due to low confidence (1)

tests/scripts/shared.ts:506

  • The test should also create and verify that .d.ts.map files in the .rslib folder are cleaned during bundling. Currently, only dist-types map files are tested, but when bundle is true, map files could also be generated in the .rslib/declarations/{cjs,esm} directories. Consider adding:
const tempFileMapRslibCjs = join(tempDirRslib, 'tempFile.d.ts.map');
const tempFileMapRslibEsm = join(tempDirRslibEsm, 'tempFile.d.ts.map');

await fs.promises.writeFile(
  tempFileMapRslibCjs,
  'console.log("temp map file for rslib cjs");',
);
await fs.promises.writeFile(
  tempFileMapRslibEsm,
  'console.log("temp map file for rslib esm");',
);

checkFile.push(tempFileMapRslibCjs, tempFileMapRslibEsm);
  if (bundle) {
    const tempDirRslib = join(fixturePath, '.rslib', 'declarations', 'cjs');
    const tempDirRslibEsm = join(fixturePath, '.rslib', 'declarations', 'esm');
    const tempFileRslibCjs = join(tempDirRslib, 'tempFile.d.ts');
    const tempFileRslibEsm = join(tempDirRslibEsm, 'tempFile.d.ts');

    await fs.promises.mkdir(tempDirRslib, { recursive: true });
    await fs.promises.mkdir(tempDirRslibEsm, { recursive: true });

    await fs.promises.writeFile(
      tempFileRslibCjs,
      'console.log("temp file for cjs");',
    );
    await fs.promises.writeFile(
      tempFileRslibEsm,
      'console.log("temp file for esm");',
    );

    checkFile.push(tempFileRslibCjs, tempFileRslibEsm);
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Timeless0911 Timeless0911 merged commit 0a1fd71 into main Nov 24, 2025
23 checks passed
@Timeless0911 Timeless0911 deleted the clean-map branch November 24, 2025 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants