Skip to content
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(typescript): fix sourcemap sourcecontent referencing non-existent files #1571

Conversation

ianyong
Copy link
Contributor

@ianyong ianyong commented Aug 29, 2023

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
Copy link
Contributor Author

ianyong commented Aug 29, 2023

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

@shellscape
Copy link
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
5 checks passed
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 <[email protected]>
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