Coder Social home page Coder Social logo

Comments (8)

petetronic avatar petetronic commented on July 19, 2024

Do you think people are going to want to deal with a UI to set this? Is there some "project" file whose presence could be sought out to define this?

Also, the Brackets-only brackets.getModule() API in extensions is a further annoyance. It seems like a hack to handle this API name explicitly... maybe a "project" file could define places to search for modules? We could also just not support it for now.

from brackets.

njx avatar njx commented on July 19, 2024

Yeah, I think getModule() is too Brackets-specific--not sure we should worry about it now (although it would be good to figure out some way we could hack it to work for our own purposes).

For configuring require paths in general, we don't currently have a preferences UI, though we do have some infrastructure for storing per-project preferences in local storage. However, I think you could argue that for this kind of thing you might really want a metadata file in the project itself. We don't yet have a mechanism/policy for this since we haven't had any features up till now that needed it, but I think we're probably going to have other features that would need that going forward, so it's worth discussing. If we do go that route, then we could just make it so you have to manually write that config file for now, and then worry about making a UI later (if ever).

from brackets.

eztierney avatar eztierney commented on July 19, 2024

Yeah, I wasn't thrilled with only searching from the project root. I wasn't sure if there was some sort of convention for where js source files go, and maybe we could search those as well? I've seen some open source projects put their code in 'src' or 'lib' but don't know how common that is.

Another thought I had would be to search the project for any files whose path ended with the module name. So for

var PerfUtils = require("utils/PerfUtils");

we could look for any files that ended with "utils/PerfUtils.js". We'd have to come up with some way to break ties, maybe pick the "closest" file to the file the require is in or something like that. This could eliminate the need for configuration, and may even work when users have specified different baseUrls for requirejs.

from brackets.

TomMalbran avatar TomMalbran commented on July 19, 2024

Would it be possible to just use the requireJs baseUrl configuration value? http://requirejs.org/docs/api.html#config-baseUrl

from brackets.

peterflynn avatar peterflynn commented on July 19, 2024

The question is how would we know what the baseUrl was set to? Remember, we just have the text of the source -- we're not running inside the user's project. We could search all files in the project for one containing baseUrl: ... but that seems a little sketchy.

from brackets.

TomMalbran avatar TomMalbran commented on July 19, 2024

Right, I forgot that it just reading the files and not running them. Searching for the baseUrl might not be the best. It might not even be defined and yet not the be project source and gets defined by the location of the html file that loads require or the data-main attribute in it.

for using the path, i think it might be better to search for more paths to break a tie since you might get an unique file or several in the same folder, that could break the tie. Once the base url is found, this can be saved since it shouldn't change.

from brackets.

eztierney avatar eztierney commented on July 19, 2024

Yeah, baseUrl could be useful when we can determine it. But I was also trying to make things work when we don't have baseUrl, or the project root is not the web root (such as when you open the entire brackets folder, rather the the /src folder).

I was thinking that solution might also make custom baseUrls mostly work (without special baseUrl analysis), though I'm sure there are cases where the tiebreaking code could be wrong, but hopefully those cases would be rare.

from brackets.

petetronic avatar petetronic commented on July 19, 2024

Moved to adobe#3560

from brackets.

Related Issues (19)

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.