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

Introduce sourcemapIgnoreList config predicate #4848

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

bmeurer
Copy link
Contributor

@bmeurer bmeurer commented Feb 8, 2023

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

List any relevant issue numbers:

#4847

Description

This PR updates rollup to leverage the initial x_google_ignoreList support in magic-string, and introduces a sourcemapIgnoreList config predicate that works similar to the existing sourcemapPathTransform, and can be provided to mark certain source files as ignore-listed when generating source maps.

This is useful for libraries and frameworks that provide code that is not relevant to the debugging experience of the customer. Chrome DevTools already supports this new x_google_ignoreList field in the source maps1.

Doc: https://goo.gle/devtools-ignoreList-adoption

Footnotes

  1. https://developer.chrome.com/blog/devtools-better-angular-debugging

@netlify
Copy link

netlify bot commented Feb 8, 2023

Deploy Preview for rollupjs ready!

Name Link
🔨 Latest commit 9c3eb9a
🔍 Latest deploy log https://app.netlify.com/sites/rollupjs/deploys/63ec7e9fa0ff2f0008fb0380
😎 Deploy Preview https://deploy-preview-4848--rollupjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bmeurer bmeurer changed the title Feat/x google ignore list Introduce sourcemapIgnoreList config predicate Feb 8, 2023
@bmeurer bmeurer force-pushed the feat/x_google_ignoreList branch from e997865 to d768a18 Compare February 14, 2023 10:50
@bmeurer
Copy link
Contributor Author

bmeurer commented Feb 14, 2023

I rebased this on the magic-string update. This is ready for review now.

@codecov
Copy link

codecov bot commented Feb 14, 2023

Codecov Report

Merging #4848 (9c3eb9a) into master (3154ca7) will decrease coverage by 0.02%.
The diff coverage is 94.44%.

@@            Coverage Diff             @@
##           master    #4848      +/-   ##
==========================================
- Coverage   98.99%   98.98%   -0.02%     
==========================================
  Files         219      219              
  Lines        7888     7898      +10     
  Branches     2184     2189       +5     
==========================================
+ Hits         7809     7818       +9     
  Misses         26       26              
- Partials       53       54       +1     
Impacted Files Coverage Δ
src/utils/options/normalizeOutputOptions.ts 100.00% <ø> (ø)
src/utils/renderChunks.ts 99.11% <94.11%> (-0.89%) ⬇️
src/utils/options/mergeOptions.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@bmeurer bmeurer force-pushed the feat/x_google_ignoreList branch from d768a18 to 3c6f36a Compare February 14, 2023 13:45
Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Great stuff! Especially considering there was virtually not feedback loop you picked up nicely how to write Rollup tests etc ;)

Only minor point for me is that the tests never look at the second argument of the sourcemapIgnoreList function, and only vaguely at the first one. Considering these are direct parts of the API, it would be nice at least at one point to assert what is passed here to avoid breaking changes if we should ever refactor here.

Otherwise, you got nearly 100% coverage :) The only thing missing is the else case for if (!map.x_google_ignoreList.includes(sourcesIndex)) {, but if I understand correctly, this is probably close to impossible to encounter while on the other side it would be foolish not to handle this case explicitly to avoid future regressions. So this is fine from my side.

}
}
map.sources[sourcesIndex] = normalize(sourcePath);
}
Copy link
Member

Choose a reason for hiding this comment

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

That looks like it should definitely not hurt performance, thanks a lot!

@bmeurer bmeurer force-pushed the feat/x_google_ignoreList branch from 3c6f36a to 4595731 Compare February 15, 2023 06:26
@bmeurer
Copy link
Contributor Author

bmeurer commented Feb 15, 2023

Only minor point for me is that the tests never look at the second argument of the sourcemapIgnoreList function, and only vaguely at the first one. Considering these are direct parts of the API, it would be nice at least at one point to assert what is passed here to avoid breaking changes if we should ever refactor here.

I added a trivial test case that also sanity checks the second parameter.

Otherwise, you got nearly 100% coverage :) The only thing missing is the else case for if (!map.x_google_ignoreList.includes(sourcesIndex)) {, but if I understand correctly, this is probably close to impossible to encounter while on the other side it would be foolish not to handle this case explicitly to avoid future regressions. So this is fine from my side.

I'm planning to test this, once rollup preserves x_google_ignoreList from input source maps.

@bmeurer bmeurer force-pushed the feat/x_google_ignoreList branch from 4595731 to 071c272 Compare February 15, 2023 06:28
This adds a new `sourcemapIgnoreList` config predicate that works
similar to the existing `sourcemapPathTransform`, and can be provided to
mark certain source files as ignore-listed when generating source maps.

This is useful for libraries and frameworks that provide code that is
not relevant to the debugging experience of the customer. Chrome
DevTools already supports this new `x_google_ignoreList` field in the
source maps[^1].

Doc: https://goo.gle/devtools-ignoreList-adoption

[^1]: https://developer.chrome.com/blog/devtools-better-angular-debugging
@bmeurer bmeurer force-pushed the feat/x_google_ignoreList branch from 071c272 to 9c3eb9a Compare February 15, 2023 06:41
@lukastaegert lukastaegert merged commit 1ba8d4e into rollup:master Feb 16, 2023
@bmeurer bmeurer deleted the feat/x_google_ignoreList branch February 17, 2023 05:39
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.16.0. You can test it via npm install rollup.

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.

3 participants