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

Add babel-plugin-probe-gl module #111

Closed
wants to merge 4 commits into from
Closed

Conversation

Pessimistress
Copy link
Collaborator

See README.md

@coveralls
Copy link

Coverage Status

Coverage increased (+10.8%) to 51.852% when pulling 74a6efb on x/babel-plugin into 6fa9454 on master.


Remove calls to specified logging methods. This is useful to reduce the logging system's footprint and performance impact in production environment.

The `Log` instance must be called `log` for this feature to work.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be an option that's passed in.

```json
{
"plugins": [["probe-gl", {
"removeLogs": ["log", "warn"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be hard to make this removeMethods so you can remove whatever code you want?

{
  "plugins": [["probe-gl", {
    "removeMethods": {
         "object": "myLogger",
         "methods": ["log", "warn", "myLogging"],
     },
     "patterns": ["*.glsl.js"]
   }]]
}

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

This looks very good, added some thoughts on naming and generalization.

PS - Another dev-module that should move to probe.gl is the eslint checker for "double parenthesis on probe.gl log calls" that is currently in luma.gl.

https://github.com/uber/luma.gl/tree/master/dev-modules/eslint-plugin-luma-gl-custom-rules.

I think that could be called eslint-plugin-probe-gl

"extends": "node_modules/ocular-dev-tools/templates/.nycrc"
"extends": "node_modules/ocular-dev-tools/templates/.nycrc",
"include": [
"dev-modules/**/*.js",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Worth avoiding different directory structures between modules and dev-modules?

Even if dev-modules often just have one source file, just keep the same structure to follow the principle of least surprises, and so we can move them between different modules and dev-modules directories in the future?


## Usage

### Via `.babelrc` (Recommended)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Total nit: maybe babel.config.js is more common these days...

@@ -0,0 +1,22 @@
{
"name": "babel-plugin-probe-gl",
Copy link
Collaborator

Choose a reason for hiding this comment

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

On the topic of naming,

  • Do we expect to have only one plugin for probe, possibly doing multiple things in the future, or do we want to qualify the name with what the plugin does, e.g. babel-plugin-probe.gl-strip-logs?
  • I expect it is not worth the hassle to use the probe.gl namespace on a babel plugin @probe.gl/babel-plugin-strip-logs)

Copy link
Collaborator

Choose a reason for hiding this comment

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

As for extensions to this, I am interested in having a babel-plugin-strip-assert:

  • The existing npm module for this does not seem to work or be maintained. I expect a small variant of this plugin could work for that case.
  • We could just make one plugin babel-plugin-strip-functions that handles both functions and methods.
  • The main weirdness is that generic plugin would come with probe.gl specific defaults, but we can always call it babel-plugin-probe.gl-strip-functions to get around that.

// Remove whitespace before comparing
function clean(code) {
return code
.replace('"use strict";', '')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assume babel injects this in the transpiled code?

const config = {
lint: {
paths: ['modules', 'examples', 'test'],
extensions: ['js']
},

aliases: {
// DEV MODULES
'dev-modules': resolve(__dirname, './dev-modules')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Maybe alias the actual plugin module instead?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Xiaoji Chen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ibgreen ibgreen closed this Feb 24, 2023
@ibgreen ibgreen deleted the x/babel-plugin branch February 24, 2023 12:44
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.

None yet

5 participants