-
Notifications
You must be signed in to change notification settings - Fork 56
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
[SDK-3975] Strip logging from modular variant of the SDK #1536
Conversation
24e32c2
to
740c29b
Compare
740c29b
to
06c0a37
Compare
06c0a37
to
32dd188
Compare
32dd188
to
72875fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the solution of actually building the syntax tree using babel, and then stripping the logs based on found expression.
This is way more reliable than relying on regular expressions to parse strings to find lines of code that are related to the Logger calls - our initial idea.
Also check my code comments
72875fd
to
d0f28a2
Compare
d0f28a2
to
0f1fe78
Compare
0f1fe78
to
f23eb92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Let's wait for @owenpearson to take a look at logs that are preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we ought to add some logging to the platform http clients in order to properly add tracing for http requests - there are a few places where we call methods directly on the http client rather than using the Resource
methods so currently this wont catch anything (same kinda goes for protocol.send
because we call transport.send
directly in one place but that will change once we remove upgrade so it's fine to keep it as is).
f23eb92
to
c0eca61
Compare
c0eca61
to
0dda975
Compare
0dda975
to
b0001e2
Compare
Need this in order to use esbuild plugins.
In order to reduce bundle size further, we’ve decided to strip all logging from the modular variant of the SDK, except for errors and certain network events. (We also considered providing a separate tree-shakable module with all of this logging code so that a user of the modular variant of the library can opt in to it, but decided against it for now; we might add it in later. This does mean that there is currently no version of the SDK that allows you to use both deltas and verbose logging on web.) I couldn’t find any out-of-the-box esbuild functionality that let us do this. The only stuff I could find related to stripping code was: - the `pure` option, but that code only gets stripped if you minify the code (and even in that case I couldn’t actually get it to be stripped, perhaps would have been able to with further trying though), but minifying our generated modules bundle causes the bundle size of those who use it (as tested by our modulereport script) to increase considerably (for reasons I’m not sure of) - the `drop` option, but that only lets you remove calls to `console` or `debugger` So instead I’ve implemented it as an esbuild plugin. Resolves #1526.
b0001e2
to
c5935d8
Compare
Sure — I've done this in #1581, on top of which the current PR is now based. |
@VeskeR would you mind resolving your comments please? |
@lawrence-forooghian Resolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good now 👍
Note: This PR is based on top of #1581; please review that one first.
In order to reduce bundle size further, we’ve decided to strip all logging from the modular variant of the SDK, except for errors and certain network events. See commit messages for more details.
I'd welcome feedback on whether the logs that I’ve chosen to preserve (i.e. the calls to
logActionNoStrip
) are the right ones.Resolves #1526.