joeybaker / remapify

Alias directories for browserify
Other
117 stars 23 forks source link

README shows invalid setup information #34

Closed taylorhakes closed 9 years ago

taylorhakes commented 9 years ago

Readme shows

var browserify = require('browserify')
  , remapify = require('remapify')
  , b = browserify(__dirname)

b.plugin(remapify, [
  {
    src: './client/views/**/*.js' // glob for the files to remap
    , expose: 'views' // this will expose `__dirname + /client/views/home.js` as `views/home.js`
    , cwd: __dirname // defaults to process.cwd()
    , filter: function(alias, dirname, basename) { // customize file names
      return path.join(dirname, basename.replace('foo', 'bar'))
    }
  }
])

b.bundle()

That information is incorrect. It should be

b.plugin(remapify, [
  {
    src: './client/views/**/*.js' // glob for the files to remap
    , expose: 'views' // this will expose `__dirname + /client/views/home.js` as `views/client/views/home.js`
    , cwd: __dirname // defaults to process.cwd()
    , filter: function(alias, dirname, basename) { // customize file names
      return path.join(dirname, basename.replace('foo', 'bar'))
    }
  }
])

The comment on the expose parameter now reflects what actually happens.

In order to expose views/home.js it should be

b.plugin(remapify, [
  {
    src: '**/*.js' // glob for the files to remap
    , expose: 'views' // this will expose `__dirname + /client/views/home.js` as `views/client/views/home.js`
    , cwd: './client/views'
    , filter: function(alias, dirname, basename) { // customize file names
      return path.join(dirname, basename.replace('foo', 'bar'))
    }
  }
])

Notice the change to cwd and src. I am not sure what caused this change, but it took a while for me to debug the cause.

Unfortunately, there is a related issue https://github.com/joeybaker/remapify/issues/33 that causes the files to be pointing at the wrong location.

taylorhakes commented 9 years ago

Closing as duplicate of https://github.com/joeybaker/remapify/issues/23