joeybaker / remapify

Alias directories for browserify
Other
117 stars 23 forks source link

problem with aliasify #33

Closed melbarra88 closed 9 years ago

melbarra88 commented 9 years ago

Hi, I am facing some troubles using remapify with grunt from a folder different from my src folder. I have a root folder where I put all my build files. This root folder is structured as follows :

What I am trying to do is to aliasify file.js with simply "ui/file.js" and generate a bundled file in the build folder. Here is my grunt remapify configuration :

          options: {
                preBundleCB: function (browserify) {
                    browserify.require("./js/src/ui/ui.js",  {expose: "ui/ui.js"});
                    browserify.plugin(remapify,
                        {
                            src: './**/*.js',
                            cwd : './js/src'
                        }
                    );
                }
            }

However aliasify is replacing my alias ui\file.js with ./....\src\js\src\ui\file.js and that causes my build process to stop because browserify doesn't find this file. By debugging remapify and aliasify, I found the source of the problem.

replacement = path.resolve(configDir, replacement);

the variable configDir is equal to my cwd, which is not my config dir. I managed to temporarily resolve the problem by initializing aliasify with process.cwd() instead of pattern.cwd here :

b.transform(aliasify.configure({
        aliases: expandedAliases
        , configDir: pattern.cwd
      }))

Do you have a more clean way to resolve this issue? Thank you.

PS. I really like this library. I think it's very useful and I am willing to contribute.

taylorhakes commented 9 years ago

I am having the exact same issue. There is a bug with configDir option here.

b.transform(aliasify.configure({
        aliases: expandedAliases
        , configDir: pattern.cwd
      }))

If I change it to

b.transform(aliasify.configure({
        aliases: expandedAliases
      }))

everything works fine. I am not sure the reason for adding that parameter.

joeybaker commented 9 years ago

v2 was just released. Please give that a try and see if that solves your issue!

joeybaker commented 9 years ago

@taylorhakes @melbarra88 have either of you had the chance to try v2?

taylorhakes commented 9 years ago

v2 solved the above issue, but introduced a new issue with transforms. I am using remapify with babelify (for ES6 code) and it is not running the transform on the remapified files. It is throwing errors on all my ES6 code.

Edit: I will try to figure out the cause when I have some time. I will have to stick with v1 for the time being.

melbarra88 commented 9 years ago

@joeybaker, I am sorry for not having had time to give you a feedback. I have tested V2, and it works very well for me. Thank you.

joeybaker commented 9 years ago

Cool. Closing then :)