gobblejs / gobble-browserify

Bundle CommonJS modules with gobble and Browserify
4 stars 9 forks source link

Error finding module #12

Open joshwils82 opened 8 years ago

joshwils82 commented 8 years ago

I am attempting to use this with gobble-ractive and am running into problems finding the ractive component that was previously transformed into js.

My project structure looks like this:

src/scripts/component/login.html
src/scripts/routing.js

routing.js includes the following require:

require('./components/login')

by gobblefile contains:

gobble('src/scripts')
        .transform('ractive', {type: 'cjs'})
        .transform('browserify', {
            entries: './routing.js',
            dest: 'bundle.js'
        })

package.json

  "devDependencies": {
    "gobble": "^0.11.3",
    "gobble-browserify": "^13.0.0",
    "gobble-less": "^0.3.0",
    "gobble-ractive": "^0.2.0"
  }

The error I am receiving is

Cannot find module './components/login' from '/home/jwilson/Development/myproject/src/scripts'

It appears it is trying to resolve the login module from the original source directory instead of the gobble build cache.

From what I can tell, it appears this is due to the fact the gobble is using symlinks in the .gobble-build folder and when routing.js is resolved, browserify resolves it to the real path instead of the .gobble-build directory. This then causes the the require of the login component to fail.

It appears there is an issue with this component since browserify is actually resolving the gobble symlinks to real paths with is breaking the relative requires that have previously been transform (ractive components).

Does this sound right? Any possible work arounds to this problem. Thanks!

joshwils82 commented 8 years ago

One other thought, would it be possible to add the inputDirectory to the options.paths when running browserify? That was I could just use require('components/login') to resolve the ractive module.