Skip to content

fix(typescript): fix sourcemap sourcecontent referencing non-existent files - #1571

Merged
shellscape merged 3 commits into
rollup:masterfrom
ianyong:fix-sourcemap-sourcecontent-referencing-non-existent-files
Sep 25, 2023
Merged

shellscape merged 3 commits into
rollup:masterfrom
ianyong:fix-sourcemap-sourcecontent-referencing-non-existent-files

Conversation

@ianyong

@ianyong ianyong commented Aug 29, 2023

Copy link
Copy Markdown
Contributor

Rollup Plugin Name: @rollup/plugin-typescript

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

In #1555, I changed:

/**
* Checks if the given OutputFile represents some source map
*/
function isMapOutputFile(name: string): boolean {
return name.endsWith('.map');
}

to:

/**
* Checks if the given OutputFile represents some source map
*/
export function isMapOutputFile(name: string): boolean {
return name.endsWith('ts.map');
}

It turns out that this was a mistake (oops!) because isMapOutputFile is also used in the load build hook to determine the map file for every code file. With the change made above, .js.map files were incorrectly being treated as declaration files instead of map files.

To resolve this issue, I have split the predicate functions:

/**
 * Checks if the given OutputFile represents some source map
 */
export function isMapOutputFile(name: string): boolean {
  return name.endsWith('.map');
}

/**
 * Checks if the given OutputFile represents some TypeScript source map
 */
export function isTypeScriptMapOutputFile(name: string): boolean {
  return name.endsWith('ts.map');
}

isMapOutputFile is used to determine if a file is a map file for use in the load build hook while isTypeScriptMapOutputFile is used to determine if a file is a TypeScript map file for emitting.

@ianyong
ianyong requested a review from shellscape as a code owner August 29, 2023 15:31
@ianyong

ianyong commented Aug 29, 2023 •

Copy link
Copy Markdown
Contributor Author

It seems that pnpm 8 has dropped support for Node.js 14. The CI pipeline will need to be updated after 0278630.

@jerome-benoit jerome-benoit mentioned this pull request Sep 5, 2023
3 of 9 tasks
@shellscape

Copy link
Copy Markdown
Collaborator

@ianyong please update your branch from upstream so we can run the latest CI

@shellscape
shellscape merged commit 902fb3d into rollup:master Sep 25, 2023
shellscape pushed a commit that referenced this pull request Sep 25, 2023
… files (#1571)

* test(typescript): add test case for incorrect `sourceContent`

* fix(typescript): fix .js.map files being treated as declarations
shellscape pushed a commit that referenced this pull request Sep 25, 2023
* fix(typescript): fix sourcemap sourcecontent referencing non-existent files (#1571)

* test(typescript): add test case for incorrect `sourceContent`

* fix(typescript): fix .js.map files being treated as declarations

* fix(dsv): type of processRow

* test(dsv): update test for processRow types

---------

Co-authored-by: Ian Yong <ianyongyc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@rollup/plugin-typescript] Source map's sourceMappingURL references a non-existent file

2 participants