Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Support for deep namespaces #19

Closed
WickyNilliams opened this issue Feb 4, 2014 · 6 comments
Closed

Support for deep namespaces #19

WickyNilliams opened this issue Feb 4, 2014 · 6 comments

Comments

@WickyNilliams
Copy link

I have tried this with the grunt plugin and it seems to remove everything. I suppose it could potentially be an issue with the plugin not the lib, but I'm reporting here as I assume the plugin simply proxies to the lib.

If i have a customer logger solution:

var logger = {
  log : function() {
    console && console.log && console.log.apply(console, arguments);
  }
}

It would be great if I could supply the namespace "logger" and it remove all references to logger, that is, calls to logger.log would be stripped.

@Couto
Copy link
Owner

Couto commented Feb 4, 2014

I'm currently at work, so I'm just asking/suggesting this in hope that it's a fast way to fix your problem, or to help me debugging it later:

Have you tried to specify the namespace option?

{
    console: true,                          // Keep console logs
    debugger: true                          // Keep debugger; statements
    pragmas: ['validation', 'development'], // Keep pragmas with the following identifiers
    namespace: ['App.logger', 'App.bucket'] // Besides console also remove function calls in the given namespace,
    replace: '0'                            // For the ones who don't know how to write Javascript...
}

I believe that if you do namespace: ['logger'] it would suffice to remove all methods of that object, if it's not happening, then yes it's a bug, and I will try to take a look into it in a few hours... =)

@WickyNilliams
Copy link
Author

Yes I tried the namespaces option, but to no avail. For some reason it stripped all code from the file! It may be that it works in the general case but fails in some edge case in my code. Let me know if you observe the same. If it works for you, I'll try to create a reduced test case.

Also, there's no massive rush to fix :) using deeper namespaces such as "logger.log" is an acceptable workaround for now

@Couto
Copy link
Owner

Couto commented Feb 4, 2014

thanks for testing the option, I'll try to replicate the bug and patch it as soon as I can :)

@WickyNilliams
Copy link
Author

Update: I just tested and it does seem to work as you expected on a much simpler file. I'll try to narrow down it down to the offending code

@WickyNilliams
Copy link
Author

I don't know what's going on, it seems to be working perfectly now. I tested and re-tested before posting this issue, but alas I must have made a mistake somewhere along the way :) I'll close this now, apologies for wasting your time.

Thanks for the great work by the way, just what I needed!

@Couto
Copy link
Owner

Couto commented Feb 4, 2014

Glad you could find the solution.
You didn't waste my time at all, in fact I appreciate the feedback and to know that people use the tool :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants