Comments (11)
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.
So thinking of it more, there are a few main things we need to gather first:
- Exactly what browsers (and versions) should be supported.
- Determine how to set up automated testing for these
- Lean what browserify is and how to use it
from nodejs-depd.
- 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).
- 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.
- 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.
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.
This module also requires support for Object.defineProperty
and similar ES5 features, so that may limit the supported browser list.
from nodejs-depd.
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.
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 try
ing if eval
works.
from nodejs-depd.
Interesting. Currently the reason for the eval
is because we need to keep the function's arity intact.
from nodejs-depd.
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.
@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.
@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)
- Stack trace api differences when in strict mode causing TypeErrors HOT 25
- Fail gracefully in unsupported browsers HOT 15
- Drop eval usage HOT 21
- line info is not help HOT 8
- Cannot redefine property: callSiteToString HOT 2
- Call-site calculation does not fail gracefully when Stack information is unavailable HOT 14
- Call site calculation fails when importing an esm'ed package that imports sequelize internally HOT 14
- Respect --no-deprecation and process.noDeprecation HOT 17
- TypeError: eval is not a function HOT 8
- Why is this library overwriting Error type? HOT 5
- Turkish Language Problem HOT 2
- Incopatibile with --enable-source-maps node 12 option HOT 7
- (!) Use of eval is strongly discouraged, rollup HOT 1
- compatibility with Node.js' source-map implementation HOT 12
- please rewrite nodejs-depd with modern syntax HOT 1
- Compatibility with --disallow-code-generation-from-strings HOT 9
- Use of eval() is strongly discouraged, as it poses security risks HOT 9
- Calling `process.cwd()` from index.js can be problematic HOT 4
- callSite.getFileName() is not Function HOT 5
- `callSite.getFileName` is not a function HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-depd.