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

Use outside of Sprockets #31

Open
jarednorman opened this Issue Jan 19, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@jarednorman
Copy link

jarednorman commented Jan 19, 2017

Versions after 0.1.0 don't seem to be able to be (reasonably) used outside of Sprockets (within other build tools, like Webpack, for example). Currently installing this package from npm seem kind of pointless since it contains Sprockets directives that don't work outside of Sprockets.

Was this a conscious decision? With Rails moving towards being friendlier to external asset tools with Webpacker and all that, it seems like this project should support that stuff. Thoughts?

@hauleth

This comment has been minimized.

Copy link
Owner

hauleth commented Jan 19, 2017

I can check this, however I was hinking about moving to ES2015 and using imports instead of Sprockets.

@prem-prakash

This comment has been minimized.

Copy link

prem-prakash commented Jun 1, 2017

tried to use as node package + webpack import

import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/polyfills.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/confirm.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/csrf.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/disable.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/form.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/liteajax.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/method.js';

but it does not work

it says matches as not defined

@jarednorman

This comment has been minimized.

Copy link

jarednorman commented Jun 1, 2017

Now that rails-ujs exists with no dep on jQuery, I just use that. I'm unfollowing this issue, but not closing it since other people seem to want this feature. ❤️

@quentindemetz

This comment has been minimized.

Copy link

quentindemetz commented Feb 4, 2018

I managed to use this with with webpacker using the following code:

 window.matches = (function(doc) {
   return doc.matchesSelector ||
     doc.webkitMatchesSelector ||
     doc.mozMatchesSelector ||
     doc.oMatchesSelector ||
     doc.msMatchesSelector;
 })(document.documentElement);

import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/polyfills.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/confirm.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/csrf.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/disable.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/form.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/liteajax.js';
import 'vanilla-ujs/lib/assets/javascripts/vanilla-ujs/method.js';

UPDATE: This works for some features (confirm) but not for others (LiteAjax is not plublicly exposed...)

@AlfonsoUceda

This comment has been minimized.

Copy link

AlfonsoUceda commented Apr 17, 2018

I'm going to take advantage of this issue and ask if there is a chance to remove railsties gem and make this gem agnostic.

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