Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Use browserify to "require" jQuery? #22

Open
anttih opened this issue Jul 10, 2015 · 1 comment
Open

Use browserify to "require" jQuery? #22

anttih opened this issue Jul 10, 2015 · 1 comment

Comments

@anttih
Copy link
Contributor

anttih commented Jul 10, 2015

The FFI code relies on the jQuery global var which makes it difficult to bundle all the deps with browserify. If one of your dependencies has require('jquery') in there and you use browserify to bundle those deps, you will end up with two jquerys on the page: one included with a script tag (to have jQuery available as a global) and one in the bundle. There may be hacks to get around this (setting jQuery as global somewhere at the top level), but I wouldn't want to do that. I think this day and age, one should bundle all the deps anyway.

So, what I suggest is we add var jQuery = require('jquery') in the FFI code.

@colehaus
Copy link

One workaround is to add the jQuery require in whichever application relies on jQuery. For example:

Main.ps

foreign import jQuery :: Foreign

...

Main.js

"use strict";

var jQuery = require('jquery');
window.jQuery = jQuery;
exports.jQuery = jQuery;

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

No branches or pull requests

2 participants