Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional / Fallback alias? #31

Open
easingthemes opened this issue Jan 26, 2015 · 6 comments
Open

Conditional / Fallback alias? #31

easingthemes opened this issue Jan 26, 2015 · 6 comments

Comments

@easingthemes
Copy link

Is it possible to configure fallback alias?

Eg.

app
  - views
    - people
      index.js
      _avatar.js
      person.js //require this if exist
  - models
    person.js // require fallback if there is no such module in original path


// _avatar.js
  var person = require('./person.js')
@joeybaker
Copy link
Owner

Remapify does not support this, and I think it's a bit out of scope. I don't know of another transform/plugin that does this either :(

FWIW, I know this seems like a good idea, but it's probably not a good path to go down. It's likely to lead to unpredictable and therefore buggy behavior.

@gja
Copy link
Contributor

gja commented Apr 19, 2015

Shucks, this seems pretty useful to have.

@joeybaker
Copy link
Owner

The problem with this idea is that it becomes really hard to predict what file you're actually loading.

@gja
Copy link
Contributor

gja commented Apr 19, 2015

While that is true, it's still a choice that is resolved at asset compile time. So assuming one has some sort of staging environment available, it's not going to be a surprise at runtime.

I guess it comes down to what sort of patterns your team is comfortable with. Providing some sort of 'classpath', where each directory is searched in sequence for a particular file, is a pattern that all developers have become familiar with

@gja
Copy link
Contributor

gja commented Apr 19, 2015

The API i would propose for this would be to accept CWD as an array of directories, and you match the JS against the first in the list.

@joeybaker
Copy link
Owner

That is an elegant API … and far be it from me to prevent a feature that now two people have asked for. PR would be welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants