Giter Club home page Giter Club logo

Comments (11)

dougwilson avatar dougwilson commented on September 23, 2024

Yes, those are the easy ones :) The main pain point is how to do the repeat warning suppression and pointing to the caller, both of which are using call stack walking.

What's nice about this module is that it doesn't warn only on first call, but rather for each unique caller callsite + calle callsite. This allows the user to run their program and collect at the deprecated calls in a single go, which things like node.js core deprecate make impossible since they only warn on whatever the first call was.

Think I you are using a lib that calls a deprecated function. Then your code calls that deprecated function: since you can't change that other lib, you would like to know if your own stuff called the deprecated function.

from nodejs-depd.

dougwilson avatar dougwilson commented on September 23, 2024

So thinking of it more, there are a few main things we need to gather first:

  1. Exactly what browsers (and versions) should be supported.
  2. Determine how to set up automated testing for these
  3. Lean what browserify is and how to use it

from nodejs-depd.

bajtos avatar bajtos commented on September 23, 2024
  1. Exactly what browsers (and versions) should be supported.

From my POV, all evergreen browsers (Chrome, Firefox, Safari) and Internet Explorer 8+ (that's the difficult part).

  1. Determine how to set up automated testing for these

This should be pretty easy via https://ci.testling.com/, although I haven't used it myself yet.

  1. Lean what browserify is and how to use it

Here is a tutorial you may find useful: http://substack.net/how_I_write_tests_for_node_and_the_browser

The testling-ci docs makes me believe it should be very easy to setup the automated CI build: https://ci.testling.com/guide/mocha

from nodejs-depd.

dougwilson avatar dougwilson commented on September 23, 2024

Awesome, thank you for the information! I'll check it out. I'll likely start with just the browsers that support access to the raw JS call stack first, and then look into what is needed to actually get it to work without access to the call stack.

from nodejs-depd.

dougwilson avatar dougwilson commented on September 23, 2024

This module also requires support for Object.defineProperty and similar ES5 features, so that may limit the supported browser list.

from nodejs-depd.

bajtos avatar bajtos commented on September 23, 2024

This module also requires support for Object.defineProperty and similar ES5 features, so that may limit the supported browser list.

Is this required for all module users, or only when calling depd.property()?

I'll likely start with just the browsers that support access to the raw JS call stack first, and then look into what is needed to actually get it to work without access to the call stack.

From my POV, I would prefer an implementation that works across all browsers, even if it (initially) provided less features than the Node version.

However, since I don't have time to work on this feature myself, I should not complain either :)

from nodejs-depd.

jscissr avatar jscissr commented on September 23, 2024

There is also a problem if you use a Content Security Policy, because eval is disallowed (by default).

Angular.js for example detects an active CSP and uses a fallback in that case.
However, there seems to be no standard way to tell a module that a CSP is active. Angular.js uses a (data-)ng-csp attribute on the <html> element, but a global variable in JavaScript would also work. This part is not absolutely necessary though - it only avoids error messages caused by trying if eval works.

from nodejs-depd.

dougwilson avatar dougwilson commented on September 23, 2024

Interesting. Currently the reason for the eval is because we need to keep the function's arity intact.

from nodejs-depd.

jscissr avatar jscissr commented on September 23, 2024

Yes, I know, on stackoverflow there is no other way than eval/new Function (that supports an indefinite number of arguments).
The easier solution is just adding 'unsafe-eval' to the CSP, but of course that's not ideal.

from nodejs-depd.

dougwilson avatar dougwilson commented on September 23, 2024

@bajtos and others that are subscribed here, a new version of this module (1.1.0) is about to be released that adds support for web browsers via. Browserify/webpack by simply providing the API but in a "no-op mode". After that release, work will begin on bringing various features into the browser, but unless you really, really desire the features in the browser build of your module, you would be able to upgrade to 1.1.0 and remove any custom depd module overrides.

from nodejs-depd.

bajtos avatar bajtos commented on September 23, 2024

@dougwilson thank you for adding basic support for running the module via browserify. Since we have implemented a workaround that actually logs deprecation warnings (see browser.depd.js), I prefer to stick with that until depd prints warnings in the browser too.

from nodejs-depd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.