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

Better support for Browserify #28

Closed
slorber opened this issue Dec 16, 2014 · 15 comments
Closed

Better support for Browserify #28

slorber opened this issue Dec 16, 2014 · 15 comments

Comments

@slorber
Copy link

slorber commented Dec 16, 2014

Hi,

I tried to use Tooltip from Browserify (see #27) and got an error.

The problem is that when you do var Tooltip = require("tether-tooltip/tooltip"); it does not export Tooltip constructor but Tether constructor.

Also it would be nice to have an main/index.js entry point for the lib so that we can simply call var Tooltip = require("tether-tooltip");

It is still possible to use this lib with Browserify by accessing the global variable Tooltip. What I did in a TetherTooltip.js file:

require("tether-tooltip/tooltip");
module.exports = Tooltip;
@geekjuice
Copy link
Contributor

Hi again! You may have seen the other comment as well, but Tooltip now has UMD support and fixed bower.json and package.json files, so you should be able to use browserify properly and using the expected require('tether-tooltip') import. Feel free to let me know if you run into any issues though and I'll be happy to help out 😸

@slorber
Copy link
Author

slorber commented May 15, 2015

Thanks will try to integrate the new version soon. It seems you have also fixed the "destory" method name :p

@geekjuice
Copy link
Contributor

Yup! 😅 No more silly hacks like:

typeof drop.destroy === 'undefined' ? drop.destroy() : drop.destory();

@slorber
Copy link
Author

slorber commented May 15, 2015

@geekjuice just tried and the integration did not work for me:

[15:29:15] gulp-notify: [Compile Error] Error: Cannot find module 'drop' from 
'/home/sebastien/Desktop/Stample-react/node_modules/tether-tooltip/dist/js'

@geekjuice
Copy link
Contributor

Ah... it might be because it's still using the older drop name rather than the new tether-drop. Could you try replacing drop in this line and see if that works. I've been using System.JS to test most of the module functionalities and not browserify, so that might have been an issue.

Update: The other thing is make sure you install drop (now called tether-drop on npm) and tether and require them as well as they are not bundled into tooltip anymore and must be required separately.

@slorber
Copy link
Author

slorber commented May 15, 2015

yes thanks @geekjuice it works :) waiting for a new release :)

@geekjuice
Copy link
Contributor

Cool. Just for reference what fixed the issue (so I know what exactly to fix)

@slorber
Copy link
Author

slorber commented May 15, 2015

module.exports = factory(require('tether-drop'), require('tether'));

this works.

tether and tether-drop were already correctly installed automatically as they are transitive dependencies declared in package.json

@geekjuice
Copy link
Contributor

Perfect 👍. I'll make sure to test browserify/Common.JS properly and release an update soon.

@slorber
Copy link
Author

slorber commented May 15, 2015

thanks tell me when it's ready :)

@geekjuice
Copy link
Contributor

Published v1.0.4 with the fixes aa44a3b

@slorber
Copy link
Author

slorber commented May 15, 2015

thanks it works fine for me

@slorber
Copy link
Author

slorber commented May 19, 2015

@geekjuice is it absolutely required to use Bower? It seems that requiring tether tooltip requires our devs to install bower first

npm WARN package.json Stample@0.0.4 No repository field.
npm WARN package.json offline-js@0.7.11 No repository field.
npm WARN package.json bounded-cache@0.0.0 No repository field.

> tether-drop@1.0.4 install /home/ubuntu/Stample-react/node_modules/tether-tooltip/node_modules/tether-drop
> bower install

sh: 1: bower: not found
npm ERR! Error: ENOENT, lstat '/home/ubuntu/Stample-react/node_modules/tether-tooltip/node_modules/tether/js/tether.js'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Linux 3.11.0-20-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/ubuntu/Stample-react
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path /home/ubuntu/Stample-react/node_modules/tether-tooltip/node_modules/tether/js/tether.js
npm ERR! fstream_path /home/ubuntu/Stample-react/node_modules/tether-tooltip/node_modules/tether/js/tether.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! tether-drop@1.0.4 install: `bower install`
npm ERR! Exit status 127
npm ERR! 
npm ERR! Failed at the tether-drop@1.0.4 install script.
npm ERR! This is most likely a problem with the tether-drop package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install
npm ERR! You can get their info via:
npm ERR!     npm owner ls tether-drop
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-20-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/ubuntu/Stample-react
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! code ELIFECYCLE

@geekjuice
Copy link
Contributor

Hmm, I guess not. It would be nice if most would, but I guess that won't be the case. I can remove the install script in package.json that forces the bower install when running npm install.

Update: v1.0.5 removes that post-install step f0e351f.

@slorber
Copy link
Author

slorber commented May 19, 2015

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants