Add tree shakable path for trace instrumentation#9730
Add tree shakable path for trace instrumentation#9730MaesterChestnut wants to merge 3 commits intocrashlytics-tracingfrom
Conversation
|
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the tree-shaking capabilities of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces tree-shakable entry points for fetch and XHR trace instrumentations, which is a great improvement for bundle size optimization. The changes involve updating package.json with new exports, adding rollup configurations for the new entry points, and moving the instrumentation registration logic to be opt-in. My feedback focuses on reducing code duplication in the build configuration to improve maintainability.
| { | ||
| input: 'fetch.ts', | ||
| output: [ | ||
| { | ||
| file: pkg.exports['./fetch'].browser.require, | ||
| format: 'cjs', | ||
| sourcemap: true | ||
| }, | ||
| { | ||
| file: pkg.exports['./fetch'].browser.import, | ||
| format: 'es', | ||
| sourcemap: true | ||
| } | ||
| ], | ||
| plugins: buildPlugins, | ||
| external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
| }, | ||
| { | ||
| input: 'xhr.ts', | ||
| output: [ | ||
| { | ||
| file: pkg.exports['./xhr'].browser.require, | ||
| format: 'cjs', | ||
| sourcemap: true | ||
| }, | ||
| { | ||
| file: pkg.exports['./xhr'].browser.import, | ||
| format: 'es', | ||
| sourcemap: true | ||
| } | ||
| ], | ||
| plugins: buildPlugins, | ||
| external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
| } |
There was a problem hiding this comment.
To improve maintainability and reduce code duplication, you could generate these almost identical build configurations for fetch and xhr using a loop or a map function. This would make it easier to add more instrumentation entry points in the future.
...['fetch', 'xhr'].map(name => ({
input: `${name}.ts`,
output: [
{
file: pkg.exports[`./${name}`].browser.require,
format: 'cjs',
sourcemap: true
},
{
file: pkg.exports[`./${name}`].browser.import,
format: 'es',
sourcemap: true
}
],
plugins: buildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}))| { | ||
| input: 'fetch.ts', | ||
| output: [ | ||
| { | ||
| file: pkg.exports['./fetch'].node.default, | ||
| format: 'cjs', | ||
| sourcemap: true | ||
| }, | ||
| { | ||
| file: pkg.exports['./fetch'].node.import, | ||
| format: 'es', | ||
| sourcemap: true | ||
| } | ||
| ], | ||
| plugins: buildPlugins, | ||
| external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
| }, | ||
| { | ||
| input: 'xhr.ts', | ||
| output: [ | ||
| { | ||
| file: pkg.exports['./xhr'].node.default, | ||
| format: 'cjs', | ||
| sourcemap: true | ||
| }, | ||
| { | ||
| file: pkg.exports['./xhr'].node.import, | ||
| format: 'es', | ||
| sourcemap: true | ||
| } | ||
| ], | ||
| plugins: buildPlugins, | ||
| external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) | ||
| } |
There was a problem hiding this comment.
Similar to the browser builds, you can refactor this duplicated configuration for node builds to improve maintainability by generating them programmatically.
...['fetch', 'xhr'].map(name => ({
input: `${name}.ts`,
output: [
{
file: pkg.exports[`./${name}`].node.default,
format: 'cjs',
sourcemap: true
},
{
file: pkg.exports[`./${name}`].node.import,
format: 'es',
sourcemap: true
}
],
plugins: buildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
}))
andrewbrook
left a comment
There was a problem hiding this comment.
Why would someone enable instrumentation for one method but not the other? Do you expect to add more options in the future?
Yea, we will add quite a few more instrumentation libraries and I think clients will only want to pull in ones they plan on needing support for. I think we'll also want to provide an option for them to pull in all instrumentation options if they don't know what they need. |
No description provided.