Skip to content

Conversation

@arturovt
Copy link

This change introduces a compile-time vscroll_enableLogging flag to guard internal logging calls.

Previously, all logger calls (e.g., this.logger.log(...)) were evaluated at runtime, even if the logs were not needed in production. Some of these logs use lazy evaluation via closures, but the overhead of logging logic and potential string construction still existed.

By wrapping logger calls in if (vscroll_enableLogging) checks, bundlers like esbuild or Webpack can remove them entirely from production builds using dead code elimination. This reduces the bundle size and runtime cost for consumers who do not rely on internal logs.

Consumers can set the flag at build time using:

// esbuild
define: {
  vscroll_enableLogging: JSON.stringify(false)
}

// Webpack DefinePlugin
new webpack.DefinePlugin({
  vscroll_enableLogging: JSON.stringify(false)
});

This change does not affect behavior in development builds where logging is still useful.

This change introduces a compile-time `vscroll_enableLogging` flag to guard internal logging calls.

Previously, all logger calls (e.g., `this.logger.log(...)`) were evaluated at runtime, even if the logs were not needed in production. Some of these logs use lazy evaluation via closures, but the overhead of logging logic and potential string construction still existed.

By wrapping logger calls in `if (vscroll_enableLogging)` checks, bundlers like esbuild or Webpack can remove them entirely from production builds using dead code elimination. This reduces the bundle size and runtime cost for consumers who do not rely on internal logs.

Consumers can set the flag at build time using:

```js
// esbuild
define: {
  vscroll_enableLogging: JSON.stringify(false)
}

// Webpack DefinePlugin
new webpack.DefinePlugin({
  vscroll_enableLogging: JSON.stringify(false)
});
```

This change does not affect behavior in development builds where logging is still useful.
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.

1 participant