Giter Club home page Giter Club logo

Comments (8)

dougwilson avatar dougwilson commented on July 24, 2024 2

@atian25 no problem :) I happened to be up and about on GitHub 👍

from nodejs-depd.

dougwilson avatar dougwilson commented on July 24, 2024

Hi @atian25 can you provide some more details? I see you're in @eggjs and so I assume you are trying to add this module to that module? Typically when you see a non-useful stack, it's because the following note was missed in the README:

[...] this module uses the calling file to get the boundary for the call stacks, so you should always create a new deprecate object in each file and not within some central file.

I can take a look to see what is happening if you have code I can try, though.

from nodejs-depd.

atian25 avatar atian25 commented on July 24, 2024

thanks, we use it at https://github.com/eggjs/egg-core/blob/master/lib/egg.js#L156

I'll read the doc again, thanks~

from nodejs-depd.

dougwilson avatar dougwilson commented on July 24, 2024

Gotcha. Yea, you cannot use this module in that way in order for the stack traces to make sense. You should always create a new deprecate object in each file you are deprecating items, because that is how the file boundary is determined. If you create it in a single, central file, then the module will latch to that file as the stack boundary and then you'll end up with useless stack traces.

from nodejs-depd.

dougwilson avatar dougwilson commented on July 24, 2024

The usage in https://github.com/eggjs/egg-core/blob/1dda9fa9d1d61a1d06913202294ac8690dbef90d/lib/loader/file_loader.js is how the module needs to be loaded: you require('depd')(namespace) at the top of the file and only ever invoke the deprecate function within that same file.

It is not clear to me where you're using the deprecate property in that file you linked to, but the essence is that you cannot centralize the creation of this module like you're doing there.

from nodejs-depd.

atian25 avatar atian25 commented on July 24, 2024

egg has plugin system, so we define a getter of app.deprecate then plugins and apps can use like this.app.deprecate()

https://github.com/eggjs/egg/blob/984d7320881adf9420e5c7e49d62d5530ad887dd/lib/egg.js#L319

from nodejs-depd.

dougwilson avatar dougwilson commented on July 24, 2024

Hi @atian25 thanks. So it's not possible to use this module in that way, as per the readme instructions. For the file https://github.com/eggjs/egg/blob/984d7320881adf9420e5c7e49d62d5530ad887dd/lib/egg.js you need to

  1. Add const deprecate = require('depd')('egg') at the top
  2. Change the line you referenced to deprecate('please use app.config.env instead')

from nodejs-depd.

atian25 avatar atian25 commented on July 24, 2024

got, thanks for reply timely.

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.