
Show HN: Wavy – use a tilde in require and import calls - kolodny
https://github.com/kolodny/wavy
======
pedalpete
this sounds like a bit of a bad idea, but I'm willing to be open minded and
convinced. I develop on Windows, I know I'm in the minority, but I recently
took over a project which was absolutely littered with symlinks which made no
sense (like pointing script tags to a folder which symlinked to another
folder).

If your app is structured in such a way as you are traversing many levels of
directories to include scripts, I think you've got a fairly basic issue with
your app, this band aid may make it worse.

I also 'think' this could make it very easy to end up with circular references
as you aren't really tracking where the files you're requiring are coming
from.

Keen to hear about why you thought this was important.

~~~
nathancahill
Indeed. You'd be much better off using webpack (or similar) to set the search
paths, and then just require('foo').

~~~
mbrock
Lazy question because I seem to remember not finding this in the Webpack
documentation:

Can I configure Webpack so that

    
    
        require("app/foo")
    

imports `foo` from my project root, even if my project root folder isn't named
`app` (it's something like `src`)?

I mean, I want a namespace prefix for my stuff, but I don't want to set the
search path to ".." or whatever.

~~~
clooth
Yep, you can do this via the webpack alias config object. I personally have
"root" pointing to the root directory of my app that is called app. :)

------
adnanh
Interesting, I wasn't the only one who had this issue. I wrote a similar
browserify transform [1] that lets you use absolute path in import and require
statements (basically rewrites / to the appropriate ../ combination)

[1]
[https://github.com/adnanh/detachkify](https://github.com/adnanh/detachkify)

