GithubHelp home page GithubHelp logo

Comments (13)

viczam avatar viczam commented on June 13, 2024

or at least provide a global function (appRequire or something) to require files relative to the project root path

from mean.

amoshaviv avatar amoshaviv commented on June 13, 2024

thats interesting since paths are always a big issue, do you have any idea in mind?

from mean.

viczam avatar viczam commented on June 13, 2024

We need access to a global method that will do that require.

Either

global.appRequire = function(path) {
  return require(config.root + path);
}

or we can attach this function as a method of the app object, but then we should make app object globally accessible (and I don't see a big issue of that).

from mean.

amoshaviv avatar amoshaviv commented on June 13, 2024

I do prefer the global variable approach though, this could save the redundant requirement of the config object, will try to integrate this in the next version

from mean.

viczam avatar viczam commented on June 13, 2024

I did the same. The global variable was the app itself. I added the app.require(path) method.

from mean.

ilanbiala avatar ilanbiala commented on June 13, 2024

+1, I don't want to have to require config in every place to use API keys and app titles and things like that.

from mean.

ilanbiala avatar ilanbiala commented on June 13, 2024

Any progress on the global config?

from mean.

lirantal avatar lirantal commented on June 13, 2024

surely we can put the config object on the global variable but I'm not sure if that's a very good practice, since anyway I don't see the config parameters being changed dynamically, and its probably anyway better to explicitly require when things are needed

from mean.

ilanbiala avatar ilanbiala commented on June 13, 2024

@lirantal it doesn't change, but requiring it in 20 places adds to memory consumption and affects speed, so being able to access config.anyProperty and not have to require it into every file is much better.

from mean.

lirantal avatar lirantal commented on June 13, 2024

@ilanbiala

  1. Do you have anything to back up the memory consumption? AFAIK node is actually caching require()s so performance isn't supposed to be the main reason for doing this chnge
  2. I'm not sure if defining globals are a better way convention to use. (in Java as in many other languages for example, you still need to imports classes/libraries that are used through-out your classes) so I'm still not convinced

from mean.

ilanbiala avatar ilanbiala commented on June 13, 2024

Still code to run through, still has to check cache, so just leaving it out would be faster anyway and probably save a tiny bit of memory.

from mean.

amoshaviv avatar amoshaviv commented on June 13, 2024

After some discussion we decided to stick with the current approach in the new version

from mean.

ilanbiala avatar ilanbiala commented on June 13, 2024

Not a big deal, we will adjust as needed.

from mean.

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.