Skip to content

What are jQuery entries in webpack.client.base.config module: loaders section needed for? #185

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

Closed
thewoolleyman opened this issue Dec 22, 2015 · 6 comments

Comments

@thewoolleyman
Copy link
Contributor

If I comment out all the jquery references in the webpack base "module: loaders" section, nothing breaks (i.e. running rake ci has no failures and app works via both express and rails):

{ test: require.resolve('jquery-ujs'), loader: 'imports?jQuery=jquery' },

What are these entries necessary to support? I'm trying to understand in order to know if this should be required in my app, which doesn't use jquery directly at all, but needs it as a bootstrap-sass dependency.

Thanks,
-- Chad

@justin808
Copy link
Member

This needs to change in the generators. Thanks for pointing this out @thewoolleyman.

I've updated the https://github.com/shakacode/react-webpack-rails-tutorial/ with the correct config.

Note, you should not be loading jquery-rails from your application.js.

@justin808
Copy link
Member

@thewoolleyman You are correct. react_on_rails has no dependency on jQuery. However, turbolinks does. If you don't use TurboLinks, feel free to remove these jQuery references. Let us know how that goes.

@thewoolleyman
Copy link
Contributor Author

@justin808

Actually, it turns out I ended up needing all three of these entries in my app (except the Bootstrap 4 one, which I'm not using).

This is even though I'm not using Jquery directly anywhere, nor am I using turbo links.

These two seem required to avoid jquery errors in dev mode (although it may have only started showing up when I started using certain react-bootstrap components?):

      { test: require.resolve('jquery'), loader: 'expose?jQuery' },
      { test: require.resolve('jquery'), loader: 'expose?$' },

...and this was required when running the app in production mode (although I'm not positive on this since I also have config.assets.compile = true in my production.rb to work around shakacode/react_on_rails#170):

{ test: /bootstrap-sass\/assets\/javascripts\//, loader: 'imports?jQuery=jquery' },

@justin808
Copy link
Member

@thewoolleyman We're moving to a new way of handling bootstrap, so it should be possible to configure all the JS to be off in bootstrap. Then you won't need jQuery. We'll have some docs on this shortly. In the meantime, here's the main config file: https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/.bootstraprc#L111

You can disable the bootstrap scripts there.

@thewoolleyman
Copy link
Contributor Author

@justin808 OK, thanks. I do want to use bootstrap for now, though, so I'll leave jquery enabled until the changes to not need it are available.

@justin808
Copy link
Member

BTW, I did make this PR: #163. The Webpack Dev Server didn't need jquery-ujs.

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

No branches or pull requests

2 participants