opentip icon indicating copy to clipboard operation
opentip copied to clipboard

Browserify support

Open franciscolourenco opened this issue 10 years ago • 2 comments

path.js:313
        throw new TypeError('Arguments to path.resolve must be strings');
        ^
TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:97:37
    at fs.js:272:14
    at Object.oncomplete (fs.js:108:15)

franciscolourenco avatar Jan 21 '15 14:01 franciscolourenco

Same issue for me too.

dottodot avatar Jan 12 '16 10:01 dottodot

I was able to overcome it by fixing package.json's main field (set it to just "./lib/opentip.js"). But that's not all if you want to use native adapter. The thing is, the native adapter automatically tries to attach itself to opentip at the end of the file. The workaround is to create /opentip.js (relative to document root) of the following content:

/opentip.js:

var Opentip = require('./node_modules/opentip/lib/opentip.js');
<here goes contents of /lib/adapter-native.js>
module.exports = Opentip;

Then you can do the following:

/index.html:

<!doctype html>
<html>
<head>
    <link href="/opentip.css" rel="stylesheet" type="text/css">
</head>
<body>
    <input id="i1" type="text">
    <script src="/bundle.js"></script>
</body>
</html>

/index.js:

var Opentip = require('./opentip.js');
new Opentip('#i1', 'Optional content', {
    target: document.getElementById('i1')
    , targetJoint: 'right'
    , tipJoint: 'left'
    , showOn: 'focus'
    , hideOn: 'blur'
    , style: 'alert'
    , fixed: true
})
$ browserify index.js -o bundle.js

Looking forward to a better workaround...

x-yuri avatar Jan 29 '16 22:01 x-yuri