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

Can't make it work with browserify #39

Closed
heloyo opened this issue Aug 17, 2016 · 8 comments
Closed

Can't make it work with browserify #39

heloyo opened this issue Aug 17, 2016 · 8 comments

Comments

@heloyo
Copy link

heloyo commented Aug 17, 2016

Hi! I am trying to use this package with Browserify, but I can't really make it work.

The command I am running looks like:
browserify --noparse=drift-zoom example/index.js -o example/build.js -dv

Doing a console.log in browserify shows noParse: [ 'drift-zoom' ].

The error I get looks like:

> browserify --noparse=drift-zoom example/index.js -o example/build.js -dv

Error: Cannot find module './util/dom' from 'c:\x\y\z\node_modules\drift-zoom\dist'
    at c:\x\y\z\node_modules\resolve\lib\async.js:55:21
    at load (c:\x\y\z\node_modules\resolve\lib\async.js:69:43)
    at onex (c:\x\y\z\node_modules\resolve\lib\async.js:92:31)
    at c:\x\y\z\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

Any ideas?

@paulstraw
Copy link
Member

Can you send through the require statement you're using in your example/index.js?

@heloyo
Copy link
Author

heloyo commented Aug 17, 2016

It is using a Deku component I am writing, but the component looks like:

import driftZoom from 'drift-zoom';

@paulstraw
Copy link
Member

Strange. Would it be possible for you to set up a reduced test case I can play with?

@heloyo
Copy link
Author

heloyo commented Aug 17, 2016

Running npm run build with those files:

package.json:

{
  "scripts": {
    "build": "browserify --noparse=drift-zoom index.js -o test.js -dv"
  },
  "dependencies": {
    "drift-zoom": "^0.3.4"
  },
  "devDependencies": {
    "browserify": "^12.0.1"
  }
}

index.js:

var driftZoom = require('drift-zoom');

Results in this error:

Error: Cannot find module './util/throwIfMissing' from 'c:\x\y\drift-zoom-test\node_modules\drift-zoom\dist'
    at c:\x\y\drift-zoom-test\node_modules\resolve\lib\async.js:55:21
    at load (c:\x\y\drift-zoom-test\node_modules\resolve\lib\async.js:69:43)
    at onex (c:\x\y\drift-zoom-test\node_modules\resolve\lib\async.js:92:31)
    at c:\x\y\drift-zoom-test\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

@paulstraw
Copy link
Member

Perfect, I'll take a look at this tomorrow. Thanks @heloyo!

@paulstraw
Copy link
Member

Hmmm. @heloyo, I spent a fair bit of time trying to figure out what's going on here. For some reason, Browserify seems to be ignoring(?) noParse. I'm unclear why this is happening. In the meantime, you can change your require to require('drift-zoom/dist/Drift.min.js') to work around this.

@jacobsvante
Copy link

Weird bug! Changing to require('drift-zoom/dist/Drift.min.js') worked, thanks @paulstraw.

@paulstraw
Copy link
Member

@jmagnusson, I think this was happening because noParse needs the full path. Can you try it with the value of require.resolve('drift-zoom')?

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