Skip to content
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 esbuild instead of webpacker #1957

Merged
merged 24 commits into from
Apr 26, 2022
Merged

Use esbuild instead of webpacker #1957

merged 24 commits into from
Apr 26, 2022

Conversation

johrstrom
Copy link
Contributor

@johrstrom johrstrom commented Apr 15, 2022

Fixes #1825 to move to esbuild instead of webpacker.

I think it offers a few things

  • simplicity. You see all the config files (along with dependencies) I removed for babel, postcss and webpack and webpacker.
    image
  • Long term support - see the original ticket on moving to Shakapacker and so on.

I believe this is ready for review. There is one drawback here where webpacker would automatically rebuild the assets whenever you modified them. This is no longer the case. Rails provides a simple foreman mechanism, but I haven't gotten it to work within OOD, so that's something we'll need to look into. I've provided bin/recompile_js as a helper to do what's required and tests automatically do what's required.

┆Issue is synchronized with this Asana task by Unito

Comment on lines -201 to -205
render: function (data, type, row, meta) {
var api = new $.fn.dataTable.Api(meta.settings);
let selected = api.rows(meta.row, { selected: true }).count() > 0;
return `<input type="checkbox" ${selected ? 'checked' : ''}> ${selected ? 'checked' : ''}`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is ever used or is useful. plus it adds the text checked to the innerHtml?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files app test fine with this removed, so we should be good.

Comment on lines +31 to +32
// FIXME: confim modals don't work in esbuild.
// import 'data-confirm-modal';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may actually be OK because it's buggy: #665.

@johrstrom johrstrom marked this pull request as ready for review April 22, 2022 22:14
Copy link
Contributor

@gbyrket gbyrket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments.

window.$ = $;
import jQuery from 'jquery';
import 'jquery-ujs';
import datatables from 'datatables.net';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're trying to decouple. Why move the datatables here? if there is a piece of functionality that needs datatable access, shouldn't we do the same as we did in the files app?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought, by adding datatables import here, we're loading datatables even on pages that do not use datatables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but jquery plugins don't play nice when jquery has a conflict (i.e., some other definition of jquery). #1846 is an example of this. Indeed - tooltip is a global jquery plugin. Along with poppers that we have installed everywhere.

I figure if we buy in on jquery, we buy in on it's plugins too.

I can try to fix this but it didn't work easily so i'll bet we have to use jquery's noConflict.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to fix. I was just asking the question.


import '../images/OpenOnDemand_powered_by_RGB.svg';
import '../images/OpenOnDemand_stack_RGB.svg';
datatables(window, jQuery);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more coupling? Now, we're having to pass window and jQuery to the datatable. Seems counter-productive to the goal of decoupling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserves a comment which I'll give it, but this is here to initialize these plugins. They don't directly initialize just by being imported (because of javascript toolchain compilations and how old it is and how it's being invoked).

So I had to initialize them to tie them to this jquery otherwise they never invoke.

Comment on lines -201 to -205
render: function (data, type, row, meta) {
var api = new $.fn.dataTable.Api(meta.settings);
let selected = api.rows(meta.row, { selected: true }).count() > 0;
return `<input type="checkbox" ${selected ? 'checked' : ''}> ${selected ? 'checked' : ''}`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

files app test fine with this removed, so we should be good.

Copy link
Contributor

@gbyrket gbyrket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

webpacker and rails jsbundling
3 participants