-
Notifications
You must be signed in to change notification settings - Fork 493
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
install vex with npm #141
Comments
Having some issues requiring the npm module in a file. In order to use
How would you include the CSS files? Are you expecting it to be?:
Because the above did not work. |
CSS files are normally added to the
|
@ConAntonakos |
I'm new to webpack, but this library doesn't appear to work out of the box when I try to require the vex.dialog file. window.vex = require('vex-js/js/vex.dialog'); And here's my failing webpack build log:
Looks like it's having trouble resolving it's own module. Do I need to do some sort of shim here to get things working? If I had to take a guess it seems it's looking for a module named "vex" rather than "vex-js". |
I think I found the problem... https://github.com/HubSpot/vex/blame/master/js/vex.dialog.js#L146 Changing this line from: define(['jquery', 'vex'], vexDialogFactory); To: define(['jquery', 'vex-js'], vexDialogFactory); Seems to get things working for me. Is this a bug or am I going about this wrong? |
#140 also seems to mitigate the issue I've been having. |
What @nozpheratu said worked for me (using webpack). If the |
Note that #160 proposes a new version of vex and vex dialog with some backward incompatible changes. You are encouraged to review it and see if would address your concerns here. |
Hey all! See my comment on #60 and let me know if your issue is resolved! Thanks! |
I will verify this issue later. |
The new version of vex works fine with webpack. vex version: 3.0.0-beta.1 The test code comes from demo of vex's document :
|
please add a guide to readme.md. |
Yes, the product appears abandoned. It's time for someone new to volunteer to maintain it or fork it. |
I recently ran into this trying to update an old codebase to work with require.js loading for an AWS conversion of an older filesystem based tool. Initially I set up shims and manually assigned window.vex and got vex but didn't get vex.dialog. I found out you can manually assign vex.dialog also using this method. Tracing the code, the version I have seems to check first if 'define' is a function and has the property define.amd (this is the 'if' that triggers on my system), then checks for typeof exports = object, then falls back to setting window.vex or window.vex.dialog respectively. In the first two cases, it seems to be defining vexFactory and vexDialogFactory respectively. The old code was using the global window.vex namespace access to the functionality, so I was trying to maintain that for the time being and hoped to update the dialogs later when I have more time. Problem was, that even setting up a shim for each, I wasn't getting any definitions of vexFactory or vexDialogFactory in the code. But I could pass them in and use them. So I ended up with a main require.js loader like this:
I include the conditional code on the setting of vex.dialog as I wanted some of my other code to be able to be more portable and not depend on the main code wrapper, so each of them is capable of initializing vex themselves if the global definition is not available. (similarly you could check if window.vex or just a global reference to vex to see if it is typeof object before re-assigning) In our case, we have some of our own extensions on jquery, thus the wrapper around jquery with the 'jquery.custom' shim which loads the 'extends()' code to modify the jquery with our helpers. This method seems to allow the old code to work with inline global references like: vex.dialog.alert('some message') Similarly, I didn't have the local references (inside the apps mentioned above) attach specifically to 'window.vex' but instead just use the local scoped 'vex' passed in at the top attached to the require.js wrappers. (which is why I exclude the initial condition in the example) in which case the same kind of global references work with any code in that scope. e.g....
I'm not sure (and haven't tried) if referencing vexDialog directly would have the desired results or not. I tinkered a bit with trying to access the factory definitions themselves, but even with switching the if/then/else order in the object code so the export was checked first (and thus triggered) I couldn't seem to 'see' the vexFactory or vexDialogFactory in the scope even with the 'exports' values in the shim definition. |
@scottw-finao What doe your comment have to do with the issue topic "Install vex with NPM" ? |
The scopes are very relevant if you aren't able to 'see' vex after installing with npm. |
It is wanderful,if publish the vexjs to npmjs.org
The text was updated successfully, but these errors were encountered: