Problem/Motivation
In #3051352: [Plan] Remove unused jQuery UI components and replace with a suite of contrib packages for the continuous upgrade path, we established a plan to reduce the amount of jQuery UI code shipped in Drupal 9 core and exposed as core libraries, since jQuery UI is no longer maintained and no longer received security coverage. When we discussed this issue with the JavaScript maintainers, frontend framework managers, and release managers, we agreed that:
- jQuery UI components not used by core would be deprecated in 8.8.x and removed before 9.0.0: #3067251: Deprecate unused jQuery UI components in favour of a suite of contrib modules
- We would use July, August, and September 2019 to research and prototype potential replacement libraries for the six components core itself actually uses.
- If we found any such libraries that had consensus from JavaScript, frontend framework, and release managers as good core dependencies for Drupal 9, we'd try to replace usage of the equivalent jQuery UI library in 8.8.x, and if this could be done in a backwards-compatible and non-disruptive way, the jQuery UI library would be deprecated in favor of the replacement dependency.
- For riskier jQuery UI components (especially Dialog which is used extensively by core and has significant accessibility requirements), we'd still develop the replacement as far as possible against 8.8, but target the deprecation of the jQuery UI library for a Drupal 9 minor release instead.
- Finally, for any libraries still used by core as of 8.8.0, those libraries would be forked into the Drupal 9 core codebase (so that we could more easily maintain them ourselves in case of any security issues between now and Drupal 9's end-of-life), with the goal of deprecating them all for complete removal prior to 10.0.0
As of the 8.8.0-alpha1 commit deadline, the following jQuery UI issues require either too much work or too much risk to replace before 8.8.0-beta1:
- #2158943: Add a native dialog element to deprecate the jQuery UI dialog
- #3079748: Deprecate jquery.ui.draggable (This library is required by Draggable.)
- #3076171: Provide a new library to replace jQuery UI autocomplete (This replacement will be provided as an experimental module with independent product value, and @catch and I agreed that, unlike most experimental modules, this could still be added in 8.8's alpha phase or even 8.9, because it is simultaneously feature and security hardening. However, the module needs to be stable for core to deprecate the old solution, and that's not going to happen in time for the 8.8.0-beta1 deadline, so the library itself will still need to be provided in 9.0.0.)
- Furthermore, #3074267: Replace jQuery UI position() with PopperJS did not fully deprecate Position, because it is also required by Dialog.
Meanwhile, the following issues are still on track to be completed in time for 8.8.0-beta1:
- #3074267: Replace jQuery UI position() with PopperJS
- #3064049: Replace jQuery UI sortable with Sortable js
- #3072906: Deprecate and remove jQuery UI datepicker
Proposed resolution
Remove all the libraries that are deprecated in 8.8, and any unused files.
- jquery.ui.accordion
jquery.ui.checkboxradio(required by jquery.ui.button)jquery.ui.controlgroup(required by jquery.ui.button)- jquery.ui.droppable
- jquery.ui.effects (all effects, core, blind, bounce, clip, drop, explode, fade, fold, highlight, puff, pulsate, scale, shake, size, slide, transfer)
- jquery.ui.progressbar
- jquery.ui.selectable
- jquery.ui.selectmenu
- jquery.ui.slider
- jquery.ui.spinner
- jquery.ui.tooltip
The following libraries may be removed if their deprecation issues are completed by 8.8.0-beta
- jquery.ui.datepicker — success as of #32!
- jquery.ui.sortable — success as of #35!
- jquery.ui.touch-punch — success as of #35!
Fork the remaining jQuery UI source code into Drupal 9 core and provide a script to minify the javascript files.
List of files to be minified in core/assets/jquery.ui/ui
:
i18n(full directory was removed with datepicker, see #32)- widgets/autocomplete-min.js
- widgets/button-min.js
- widgets/checkboxradio-min.js
- widgets/controlgroup-min.js
- widgets/datepicker-min.js
- widgets/dialog-min.js
- widgets/draggable-min.js
- widgets/menu-min.js
- widgets/mouse-min.js
- widgets/resizable-min.js
- widgets/sortable-min.js
- data-min.js
- disable-selection-min.js
- escape-selector-min.js
- focusable-min.js
- form-min.js
- form-reset-mixin-min.js
- ie-min.js
- jquery-1-7-min.js
- keycode-min.js
- labels-min.js
- plugin-min.js
- position-min.js
- safe-active-element-min.js
- safe-blur-min.js
- scroll-parent-min.js
- tabbable-min.js (used by dialog)
- unique-id-min.js
- version-min.js
- widget-min.js
About the patch in #55
Remove deprecated jQuery UI libraries:
git rm core/assets/vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.js core/assets/vendor/jquery.ui/README.md core/assets/vendor/jquery.ui/package.json core/assets/vendor/jquery.ui/themes/base/accordion.css core/assets/vendor/jquery.ui/themes/base/all.css core/assets/vendor/jquery.ui/themes/base/base.css core/assets/vendor/jquery.ui/themes/base/progressbar.css core/assets/vendor/jquery.ui/themes/base/selectable.css core/assets/vendor/jquery.ui/themes/base/selectmenu.css core/assets/vendor/jquery.ui/themes/base/slider.css core/assets/vendor/jquery.ui/themes/base/sortable.css core/assets/vendor/jquery.ui/themes/base/spinner.css core/assets/vendor/jquery.ui/themes/base/tabs.css core/assets/vendor/jquery.ui/themes/base/tooltip.css core/assets/vendor/jquery.ui/ui/core-min.js core/assets/vendor/jquery.ui/ui/effect-min.js core/assets/vendor/jquery.ui/ui/effects/effect-blind-min.js core/assets/vendor/jquery.ui/ui/effects/effect-bounce-min.js core/assets/vendor/jquery.ui/ui/effects/effect-clip-min.js core/assets/vendor/jquery.ui/ui/effects/effect-drop-min.js core/assets/vendor/jquery.ui/ui/effects/effect-explode-min.js core/assets/vendor/jquery.ui/ui/effects/effect-fade-min.js core/assets/vendor/jquery.ui/ui/effects/effect-fold-min.js core/assets/vendor/jquery.ui/ui/effects/effect-highlight-min.js core/assets/vendor/jquery.ui/ui/effects/effect-puff-min.js core/assets/vendor/jquery.ui/ui/effects/effect-pulsate-min.js core/assets/vendor/jquery.ui/ui/effects/effect-scale-min.js core/assets/vendor/jquery.ui/ui/effects/effect-shake-min.js core/assets/vendor/jquery.ui/ui/effects/effect-size-min.js core/assets/vendor/jquery.ui/ui/effects/effect-slide-min.js core/assets/vendor/jquery.ui/ui/effects/effect-transfer-min.js core/assets/vendor/jquery.ui/ui/widgets/accordion-min.js core/assets/vendor/jquery.ui/ui/widgets/droppable-min.js core/assets/vendor/jquery.ui/ui/widgets/progressbar-min.js core/assets/vendor/jquery.ui/ui/widgets/selectable-min.js core/assets/vendor/jquery.ui/ui/widgets/selectmenu-min.js core/assets/vendor/jquery.ui/ui/widgets/slider-min.js core/assets/vendor/jquery.ui/ui/widgets/sortable-min.js core/assets/vendor/jquery.ui/ui/widgets/spinner-min.js core/assets/vendor/jquery.ui/ui/widgets/tabs-min.js core/assets/vendor/jquery.ui/ui/widgets/tooltip-min.js
Clone https://github.com/jquery/jquery-ui/tree/1.12.1 and copy source files to Drupal:
cd ../
git clone git@github.com:jquery/jquery-ui.git --branch 1.12.1
cd jquery-ui
cp ui/data.js ui/disable-selection.js ui/escape-selector.js ui/focusable.js ui/form.js ui/form-reset-mixin.js ui/ie.js ui/jquery-1-7.js ui/keycode.js ui/labels.js ui/plugin.js ui/position.js ui/safe-active-element.js ui/safe-blur.js ui/scroll-parent.js ui/tabbable.js ui/unique-id.js ui/version.js ui/widget.js ../drupal/core/assets/vendor/jquery.ui/ui
cp ui/widgets/autocomplete.js ui/widgets/button.js ui/widgets/checkboxradio.js ui/widgets/controlgroup.js ui/widgets/dialog.js ui/widgets/draggable.js ui/widgets/menu.js ui/widgets/mouse.js ui/widgets/resizable.js ../drupal/core/assets/vendor/jquery.ui/ui/widgets
Minified files re-generated using yarn build:jqueryui
.
Additional files changed in this patch:
- core/core.libraries.yml
- core/package.json
- core/tests/Drupal/KernelTests/Core/Asset/LegacyLibraryDiscoveryTest.php
- core/yarn.lock
- core/scripts/js/jqueryui-build.js
- core/scripts/js/jqueryui-terser.js
Patch created with command: git diff 9.0.x HEAD > 3087685-55.patch
Dependency Evaluation
Terser was selected to minify the jQuery UI source. It is a modern, popular and well-maintained project for minifying JavaScript.
- Maintainership of the package: Terser has multiple maintainers, in the past month 6 authors have pushed 44 commits. Only one person is listed as a maintainer, however there are several active contributors Terser is used by 1.3 million other packages. Terser is used by Webpack, Rollup, Next.js and CKEditor is a supporting sponsor.
- Security policies of the package: Not found. This library is only used in by core developers in development environments.
- Expected release and support cycles: There have been 3 major releases in the last 7 years. Minor releases are tagged every few days for at least the past year. Changelog is regularly updated.
- Code quality: Well documented API with examples, test coverage using mocha and custom tests for compressor
- Other dependencies it would add, if any: Everything in the list of additional dependencies is actually already used for our JavaScript ES6 transpilation, just in different versions, so we are not actually adding new packages. (This is a feature yarn supports.) We could do selective dependency resolution to flatten our dev dependency tree, but in this case it's probably not worth that since this is our dev dependency toolchain.
Remaining tasks
This issue was originally postponed on the following two issues (now completed):
- #3064049: Replace jQuery UI sortable with Sortable js
- #3072906: Deprecate and remove jQuery UI datepicker
- Review the patch
- Review the issue on d8githooks
Put instructions for re-minifying the libraries somewhere that's easily discoverable as well as referenced in the core codebase, in case we need to fix any security issues for the retained libraries during Drupal 9's security coverage.(added in https://www.drupal.org/docs/8/frontend-developer-tools-for-drupal-core)
User interface changes
None from this issue in itself, but the blockers may introduce some.
API changes
Most jQuery UI libraries are removed from Drupal core.
Data model changes
N/A
Release notes snippet
Unused jQuery UI components were deprecated in Drupal 8.8 and removed in Drupal 9.0. The libraries which could not be removed for 8.8.0 were forked into Drupal 9 core to make them maintainable in case of any security issues before Drupal 9 end-of-life, with the goal of deprecating them all for complete removal prior to 10.0.0.
Comment | File | Size | Author |
---|---|---|---|
#74 | 3087685-74.patch | 616.09 KB | bnjmnm |
#74 | interdiff_72-74.txt | 1.23 KB | bnjmnm |
#72 | interdiff_71-72.txt | 4.7 KB | zrpnr |
#72 | 3087685-72.patch | 617.17 KB | zrpnr |
#71 | interdiff_66-71.txt | 626 bytes | zrpnr |
Comments
Comment #2
xjmComment #3
xjmComment #4
zrpnrAssuming #3064049: Replace jQuery UI sortable with Sortable js and #3072906: Deprecate and remove jQuery UI datepicker land, the jQuery UI asset libraries still needed in D9 would be:
core/jquery.ui
core/jquery.ui.autocomplete
core/jquery.ui.draggable
core/jquery.ui.dialog
core/jquery.ui.menu
core/jquery.ui.position
see: #3078116: Deprecate jquery.ui.positioncore/jquery.ui.resizable
core/jquery.ui.widget
The forked source code can be limited to this list.
The
core/jquery.ui
includes many files used by the other asset libraries, some of these are no longer needed.form-reset-mixin-min.jsThe core asset library can be trimmed down to just files that the remaining asset libraries require.
Edit: form-reset-mixin-min.js can be removed but it's not in core/jquery.ui - I'll check the folder for other files that are only used by deprecated asset libraries.
Edit: added jquery.ui.menu which was not deprecated and is required by autocomplete
Comment #5
xjm👍Thanks @zrpnr!
Comment #6
zrpnrI began working on this by removing everything jquery.ui in
core.libraries.yml
that was marked deprecated, including datepicker, sortable, touch-punch, checkboxradio and controlgroup.However since those are (currently) still dependencies in core I kept them in this patch.
I also removed the dependency property from checkboxradio and controlgroup because they are specific dependents of button- which is a dependent of dialog.
In #4 I listed
form-reset-mixin-min.js
as a file which could be removed but it is a dependency of checkboxradio.The big change in this patch is adding jQuery UI source files into the core/assets/vendor/jquery.ui folder in core.
These files come from the latest version, 12.1.1
https://github.com/jquery/jquery-ui/tree/1.12.1
I did some research on JavaScript minification, there are some open core issues:
#1490312: [META] Improving CSS and JS preprocessing
#119441: Compress JS aggregation
#1537198: Add a Production/Development Toggle To Core
#2258313: Add license information to aggregated assets
This requirement seems different for a few reasons:
Uglify was a standard for many years but after some research I landed on Terser.
Terser also has support for ES6 so it could be potentially used in a broader application in the future.
It is used by many large js projects, and has 3.6k stars on Github.
I added a build script to package.json so that you can run
yarn build:jqueryui
It globs for any non
-min
.js files and outputs the min file.The datepicker i18n files are an exception, they don't end in
-min
. I left them intact and "ignored" that directory in the glob.This folder would be removed entirely if datepicker gets deprecated so I didn't want to spend extra time on this for now.
It is difficult to compare minified files but if you look at smaller ones like data-min.js you can see the only code difference is the letter used for variable names.
The other big change from the current minified files is the license, which now is copied from the source files and so the wording is slightly different than what was currently in Drupal core.
I manually checked dialogs, autocomplete etc and checked several tests that involve jQuery UI components, such as:
EntityReferenceAutocompleteWidgetTest
CKEditorIntegrationTest
LayoutBuilderTest
If this patch passes all the testbot tests that will also be a good indicator there is no functional change to these minified files.
Comment #8
zrpnrComment #9
zrpnrThe previous patch failed due to tests for deprecation warnings on the removed libraries.
Removed the tests for the deleted asset libraries and restored a deprecation message for checkboxradio and controlgroup (maybe this should say "removed in 10.0" now?)
Comment #10
Wim Leerscore/assets/vendor/jquery.ui/package.json
?core/assets/vendor/jquery.ui/AUTHORS.txt
?core/assets/vendor/jquery.ui/README.md
.core/assets/vendor/jquery.ui/themes/base/accordion.css
. Similar observation fortooltip
and others.core/assets/vendor/jquery.ui/effects/*
.The served JS file remains fundamentally the same: slightly different minification, functionally the same. Still no comments in the minified code.
The source file is added.
That's exactly what we're doing everywhere 👍
👍 A new command for this, excellent!
🤔 But shouldn't we also run this automatically as part of the
yarn build
command? It being too slow is not a reason not to do it, becauseyarn build:jqueryui
only takes 1.3–2.3 seconds (on my machine). The entirety ofyarn build:js
takes about 3 seconds.Adding it to
build:js
still won't slow downwatch:js
, so live core development will not be slowed down.Curious about your thoughts!
Note that if we don't do this, then we need to update https://github.com/alexpott/d8githooks.
⚠️ This is a new dependency. We still need to do the necessary vetting of this package then, just like we did for example for
postcss
in #3060153: Use PostCSS in core, initially only for Claro or forjustinrainbow/json-schema
in #2843147: Add JSON:API to core as a stable module.Tagging
for this.🔎🐛
build:jquery
vsbuild:jqueryui
🥳
⚠️ The dependencies of
terser
also need to be vetted.Comment #11
zrpnrThanks @Wim Leers, I'll fix the mistakes you caught and update the patch.
#10.2 I agree! That would be a nice outcome of this work.
#10.3,4,5 I think you're right these 3 files can be removed.
#10.6, 7
My codebase looked correct but when I applied the patch to 9.0.x I saw the problems you found,
Somehow git was interpreting the removal as a rename and put code in the wrong file name in several places. I'll try to get this sorted out.
#10.9 I considered adding it to the build command, but I also thought these files will very rarely change, and, if they do, both the source and minified files would be committed. I hadn't considered the githooks change though.
Your suggestion to add
build:jqueryui
to thebuild
task should be a low-cost way to solve this question.#10.10, 13 I'll research this and update the IS.
Comment #12
zrpnr#10.6 My git diff
--find-renames
setting was too fuzzy 😅This patch now has the correct deletions.
Removed the additional jquery ui files:
and some css files which weren't being loaded:
Added the build command to
yarn build
,fixed the comment and removed 2 unnecessary requirements from jqueryui-terser.jsComment #13
zrpnrThese 3 dependencies were already in yarn.lock:
commander was introduced in #2869825: Leverage JS for JS testing (using nightwatch) as a dependency of nightwatch / mocha-nightwatch and is currently a dependency of mocha.
source-map is a dependency of Babel, added in #2815077: Adopt airbnb javascript style guide v14.1 as new baseline javascript coding standards for Drupal 8 core and contrib
and PostCSS #3060153: Use PostCSS in core, initially only for Claro
source-map-support is a dependency of babel-register,
also added in #2815077: Adopt airbnb javascript style guide v14.1 as new baseline javascript coding standards for Drupal 8 core and contrib
I made a start on this in the IS, I wasn't able to find any security policy on their github or website but I can open an issue there if necessary.
Comment #14
xjmyarn.lock
.AUTHORS.txt
. All those people are still the authors of the code, and I think this will help us in terms of the copyright information. See #3087886: [policy, maybe patch] core/COPYRIGHT.txt is inconsistent in which libraries or copyrights are mentioned.Tagging for all the reviews.
Comment #15
Wim Leers#13: like @xjm in #14, I'm confused then why it shows up in
package.json
if we were already using those dependencies. I do see that they are not being added tocore/package.json
, but they are being added tocore/yarn.lock
. How is it possible that these were previously not in ouryarn.lock
file?That's part of the reason I raised #10.9. As of #12,
yarn build
is all you need to do.But! https://github.com/alexpott/d8githooks/blob/master/pre-commit-8-4 does not run
yarn build
, it doesyarn build:js
on JS files specifically.In #10.9, I actually suggested to add it to
yarn build:js
, not toyarn build
, but I see that I worded it in a very confusing way — sorry about that 🤦♂️Comment #16
xjm@Wim Leers, I think it needs to be documented in the handbook and maybe even in the codebase, not just in an issue comment. (The ES6 transpilation should also have been documented in such a way but I don't think it was. If it was, we could document it in the same place.)
Comment #17
Wim LeersWhere in the handbook?
Comment #18
zrpnrIt looks like they were using a grunt task to minify using UglifyJS,
see: https://github.com/jquery/jquery-ui/blob/master/Gruntfile.js#L53
and: https://github.com/jquery/jquery-ui/blob/master/package.json#L67
https://github.com/gruntjs/grunt-contrib-uglify
I could swap out Terser for Uglify, it is still an active project and remains very popular.
Uglify has similar dependencies:
https://github.com/mishoo/UglifyJS2/blob/master/package.json#L25
Webpack switched to using Terser from Uglify last year, https://github.com/webpack/webpack/pull/8036
These are certainly new entries but they are for specific versions of those packages.
For example, this patch adds an entry for commander@^2.20.0 but there was already commander@2.15.1 and commander@^2.11.0 in the yarn.lock.
Those 3 packages: commander, source-map and source-map-support are also dependencies of mocha and babel which have been part of our dev dependencies for some time.
#14.3 I didn't post an interdiff because there were big problems with the previous match (my own config was set incorrectly so many deleted files were instead renamed).
#14.4 I can restore the AUTHORS.txt
#14.6 This is the page we'd worked on for PostCSS, adding the new yarn commands:
https://www.drupal.org/docs/8/frontend-developer-tools-for-drupal-core
Would that be a good place to add some information - once this is finalized?
I'd added it to yarn build because it was already a "grouping" of other yarn commands-
"build": "yarn build:css & yarn build:js & yarn build:jqueryui",
vs
"build:js": "cross-env BABEL_ENV=legacy node ./scripts/js/babel-es6-build.js & yarn build:jqueryui"
where
build:js
is a specific command to run the es6 transpilation.I'm happy to make that change if you think adding it in
build:js
makes more sense.Comment #19
xjmThanks @zrpnr and @Wim Leers.
I'm unsure which of Uglify or Terser would be best given this; there seem to be cases for both. Webpack switching to Terser is a strong case. But maybe we could get a JS maintainer's feedback/recommendation to confirm using it?
Oh blarg, hoisting whatever whatever. Thanks for clarifying. 👍
I think adding it to
yarn build
makes sense based on that explanation. I think it doesn't need to run on every commit so I don't think it needs to go in the committer pre-commit hook; we only need to run it if we actually change these files, which should be something that happens very rarely (or maybe never).https://www.drupal.org/docs/8/frontend-developer-tools-for-drupal-core also seems like a good place to add docs.
Comment #20
zrpnrReverted the removal.
It would be great to have a +1 for Terser from a JavaScript reviewer, especially if it seems like a good candidate for minifying other js files in core.
I added a change record and release notes in the IS
Comment #21
Wim LeersAll the latest comments by both @xjm and @zrpnr make sense to me. I've clarified the change record slightly and fixed nits in the issue summary. Added docs to https://www.drupal.org/docs/8/frontend-developer-tools-for-drupal-core (see diff). I've re-applied the patch locally and verified that my remarks from #10 have been addressed.
P.S.: I'm not sure
is truly necessary here, because it's still the exact same JS. This is a pure release management decision. Still, I totally agree it would be great to have explicit sign-off from a Drupal core JavaScript maintainer. But I propose we timebox it to at most two weeks (that would mean November 6).Comment #22
xjmI do think JS maintainer review is necessary since they are the ones who created the plan we're trying to implement. :) Thanks!
Comment #23
Wim LeersHah, right! 🤓 Thanks for confirming. Removed tag.
That means this is down to reviews that @lauriii and release manager(s) need to do.
Comment #24
zrpnrUpdated issue title to include removing deprecated code.
Comment #25
catchIs this definitely postponed on #3064049: Replace jQuery UI sortable with Sortable js and #3072906: Deprecate and remove jQuery UI datepicker? Those are pretty close so it probably doesn't matter too much, but trying to understand the dependency. I realise we'll have to fork those two if they don't just get deprecated, but removing the already-deprecated libraries and forking the ones we have to seems independent.
Comment #26
Wim LeersI agree they're independent. And so does @zrpnr. From Slack last night:
IOW: if this lands before those two land, we'll just need to create follow-up issues to remove them separately, instead of as part of this issue. But I think there is merit to landing this first, despite those two having landed, because this does the bulk of the work; those follow-ups would be trivial.
Comment #27
xjmThis tag is here for the JS maintainers to review this issue.
Comment #28
xjmIf we commit the patches separately, we'll have to re-minify the JS and remove sources we added. That's the only dependency. So it's not a hard blocker, just more work if we do it in two steps, and we can't tag 9.0.0-alpha1 until ether 8.8.0-beta1 is released or Sortable and Datepicker are committed to HEAD.
Comment #29
Wim Leers#27: ehm … that tag just got removed based on your comment in #22.
Comment #30
xjmI said:
Not sure why that means untagging it?
Comment #31
xjmComment #32
zrpnrRe-rolled now that #3072906: Deprecate and remove jQuery UI datepicker is in 9.0.x
That issue removed datepicker so this patch is now updated without adding datepicker.js source and re-minifying datepicker-min.js.
The interdiff has a glitch around base.css which changed between these patches, however just like #20, base.css is still removed in this patch.
Comment #33
nod_Reviewed the patch,
First yay for deleting code :)
Looking forward to the other issues replacing jquery ui :)
Comment #34
catchComment #35
xjm#3064049: Replace jQuery UI sortable with Sortable js is in now (sweet!) so one more.
Comment #36
xjmOne more reroll, that is.
Comment #37
zrpnrRe-rolled against 9.0.x, really exciting to be able to remove jQuery UI sortable now too!
The jQuery UI touch-punch library was only attached in CKeditor in core, now it has no other core dependents and can be removed too.
Removed:
Removed
core/jquery.ui.sortable
andcore/jquery.ui.touch-punch
from core.libraries.ymlThe source for jquery.ui.sortable is not added in 37.
For reference, since this is a huge patch, the diff in the
lsdiff
between 32 and 37:Comment #38
Wim LeersThe #37 looks good.
Since this is a highly atypical patch, let's look at it from a high level for a moment.
#32:
#37:
Great!
The patch in #37 is smaller, deletes more, inserts less, because it no longer needs to fork
jquery.ui.sortable
🥳Moving back to RTBC 👍
Comment #39
xjmThis is amazing!!
Comment #40
xjmUpdating the IS to clarify that we already use (different versions) of the dependencies for transpilation tools.
Comment #41
xjmOh, one followup we should do is post an issue in the committer tools to check the full build if any files in
core/assets/vendor/jquery.ui
and check the result. Is anyone available to do that? https://github.com/alexpott/d8githooks/issuesComment #42
xjmFor #41. Also tagging for docs updates to add Terser to https://www.drupal.org/core/dependencies#dev.
Comment #43
lauriiiShould we replace this with our own README.md? It would be great if we could mention why we have copied the files and how to generate the minified files.
What is
NODE_ENV=develop
? Shouldn't this beNODE_ENV=development
?What should we do with the version numbers?
Comment #44
catchI think we should keep the version numbers as is. It's very unlikely but not impossible that jQuery UI could get a new release, so it's good to have an easy record of where we forked from. We should probably open a follow-up to decide if we keep them and if we'd change them if we make our own changes though.
Comment #45
Wim Leers#44++
Comment #46
catchOn #43.3 I think we could handle the tests in a follow-up - i.e. as a pre-requisite to making changes, but not to doing the initial fork.
Comment #47
Wim Leers#46: What if we document how to run jQuery UI tests in this issue (including verifying that that's actually possible), and then file a follow-up to check if it's at all feasible to make DrupalCI run those tests for us?
(@xjm gave a thumbs up to this proposal in chat.)
Comment #48
zrpnrIn the current jQuery UI repo, they use grunt to run the qunit tests,
https://github.com/jquery/jquery-ui/blob/master/Gruntfile.js#L217
This uses grunt-contrib-qunit
https://github.com/jquery/jquery-ui/blob/master/Gruntfile.js#L217
which spins up a phantomJS instance for each of the named html pages in the folders in tests/unit
For example, button.html has the markup for the qunit test as well as the jQuery UI component, it loads files from the external folder such as jquery-simulate or requirejs. The tests are run by bootstrap.js.
That file requires many more external files and fires off PhantomJS.
I didn't think adding in all these old requirements would be a good thing, and untangling the qunit tests from phantomJS and grunt seemed like a lot of work. Nightwatch seemed like an excellent alternative, the qunit tests themselves are not complicated, mostly just running some javascript and checking for classes, focus, page elements etc.
There are a lot of qunit tests however, I got through button and most of autocomplete but I thought I should post a work in progress before I spend too much more time on this in case it doesn't seem like a good direction or is better for a follow-up.
I picked Nightwatch over FunctionalJavascript testing with Selenium because it is much easier to execute arbitrary javascript and then make assertions on the page.
This patch has the new nightwatch tests and a test module for providing the markup and pages.
Comment #49
xjmThe 8.8.0 release notes are covered already in the blocking issues, so this one can just go in the 9.0.0 list for alpha1 and etc.
Comment #50
catchIf we're reworking the tests in another issue I think that leaves #43.1 to address. For me it would also be fine to do that in a follow-up to be honest although we should link to it from here.
Comment #51
catchOK I've opened three follow-ups - for the nighwatch tests, for replacing the README (which should include information about the Nightwatch tests), and for figuring out a future version numbering system for if we need it.
#3093173: Improve README for forked jQuery UI components
#3093172: Test coverage for forked jQuery UI components
#3093175: Document version numbering system for forked jQuery UI components
IMO these are all non-blocking issues - the patch as it stands does not introduce any new technical debt, but moves technical debt from jQuery to us, and the follow-up issues show the extent of that technical debt - however all three follow-up issues only become a problem if we have to change these files. If we it turns out we don't need to backport any jQuery UI security releases before we're able to fully replace the components, we actually won't miss test coverage, a version numbering system, and better docs on how to make changes.
(edit, to clarify I re-RTBCed #37. #48 is the draft test coverage which has been uploaded to the spin-off.
Comment #52
lauriiiMoving my earlier feedback to follow-up issues seems fine. Since Drupal 9 doesn't have security coverage before Drupal 9.0.0, we probably don't have to make changes to these files in a while which will give us some time to work on the follow-ups.
Another question that I was thinking was which coding standards should the forked code be following? Should they follow Drupal coding standards, jQuery UI coding standards or no coding standards at all? Also, how are we going to enforce these? If we are planning to follow jQuery UI coding standards, should we at least find where jQuery UI coding standards are documented and see if there's some predefined tooling for linting?
Comment #53
Wim LeersIMHO we shouldn't change a single character in their code right now because it's not materially relevant. We can bikeshed that in a follow-up issue.
Furthermore, there is a strong argument to never deviate from whatever coding standards they were using, because it would complicate porting any security patches from upstream.
Comment #54
lauriii+1 to a follow-up.
I agree. I think we just need to agree on something so that if we have to work on a security issue, we already know what these policies are. Maybe it would be fine if we say we don't care about coding standards on the jQuery UI forked code but then it means we don't accept any feedback on coding standards because otherwise, it leaves the door open to everyone give feedback on random coding standard related matters.
Comment #55
zrpnr#43.2
That's right, the env var isn't used in the new script but it should certainly be consistent with the others. This patch makes the change in package.json.
Since the testing work is moved to a follow-up issue I based this change off the previous patch in #37 which catch RTBC'd in #51.
+1 for keeping the source identical to what is currently in their github, and not apply Drupal coding standards to it.
This is tricky, it looks like the entire vendor folder isn't checked by testbot for coding standards now.
Although this is now "forked" into Drupal there is still a chance of upstream updates. Any patches from this community could get feedback about matching the existing formatting.
Comment #56
zrpnrI accidentally named the interdiff as a .patch in the previous comment
Comment #57
Wim LeersI think that makes it not tricky, because that means this requirement is already taken care of in HEAD :) The contents of
core/.eslintignore
confirm this:Hence Backbone, CKEditor, jQuery, and so on, including jQuery UI. jQuery UI continues to live in
core/assets/vendor/jquery.ui
. This is semantically not 100% correct: a forked dependency in principle should live incore/assets/
, not incore/assets/vendor
. But no JS lives there; all of the JS owned by Drupal core lives incore/misc
, which is hardly better. Arguably, this is semantically still vendor JS, it's just that we're now signing up for maintenance if and only if security patches need to occur that the jQuery UI team does not provide. Continuing to consider it as vendor JS seems appropriate then. This also addresses @lauriii's feedback that we should not accept any feedback on coding standards about this code: we already never accept such feedback about vendor code.Per #53, #54 and #55, we don't need a follow-up for coding standards anymore.
But I still can't remove #41 is why that tag was added originally, and that has not yet been addressed. Could you tackle that too, @zrpnr?
becauseComment #58
lauriiiThis sort of does address my concerns but I'm not sure whether it fully does. I'd like to clarify that I'm not concerned about what coding standards the code is using at the moment. Even more so when it comes to making improvements to the coding standards of the existing code. What I'm actually concerned about is, whether we know and understand the coding standards we're supposed to follow when we make security fixes or some other critical changes. We could say it's up to the person working on the code to decide how the code gets styled if we're okay with that.
Comment #59
zrpnrI updated the docs for Terser: https://www.drupal.org/core/dependencies#terser per #42
and created an issue to check the jquery.ui folder with d8githooks: https://github.com/alexpott/d8githooks/issues/28 per #41
Comment #60
xjmWRT coding standards, I think our policy can be that we don't need to enforce the coding standards, except the ES6 vs. ES5 problem. Since the forked files are already ES5 and in
/core/assets/vendor
, transpilation presumably isn't run on them and there are no corresponding ES6 source files. So if we do have to fix a security issue, we just need to be mindful of the fact that the changes need to be ES5-compatible or at least transpiled to something ES5-compatible. That's the only thing that I think we need to take into account for the coding standards of these files.Comment #61
zrpnrI created #3094226: Determine what coding standards to apply to jquery ui source code to address the concerns about coding standards for the jQuery UI source code.
Updated the issue summary with a full list of the files removed/added/changed in this patch for comparison.
Comment #62
lauriiiI re-formatted the commands in the issue summary so that they are easier to run if anyone needs to regenerate the patch. I confirmed with these steps that the patch has been generated according to these steps. There was a minor difference in the formatting of one file which we might want to consider fixing still. Interdiff attached.
Comment #63
lauriiiShould we remove the deprecation from
jquery.ui.checkboxradio
andjquery.ui.controlgroup
given that they are still used, and won't be removed from Drupal 9.0.0?Comment #64
lauriiiform-min.js
even though it seems to be used byform-reset-mixin.js
?labels-min.js
andescape-selector-min.js
even though those seem to be used byselectmenu.js
andcheckboxradio.js
?Comment #65
zrpnrThanks for going over this in detail @lauriii, and improving the patch commands in the IS.
#62
Looking at this now I'm surprised it is only 1 file, I think my IDE was converting tabs to spaces?
The other source files in the jQuery UI github also seems to be using tabs as well. Since we agreed to keep the source formatting identical, I should probably re-add all of these source files using the step in the IS.
#63 I wondered if we could remove checkboxradio and controlgroup as a follow-up rather than removing the deprecation notice, those 2 are only used by button and are marked deprecated.
It could be a good first change to the jQuery UI codebase to remove that usage from button.
https://github.com/jquery/jquery-ui/blob/1.12.1/ui/widgets/button.js#L344
https://github.com/jquery/jquery-ui/blob/1.12.1/ui/widgets/button.js#L364
In the qunit tests everything related to checkboxradio and controlgroup for button are in a separate "deprecated" file.
If that doesn't seem likely then yes unfortunately maybe we should remove the deprecation warning in Drupal 9.
#64.1 The form module is defined in https://github.com/jquery/jquery-ui/blob/1.12.1/ui/form-reset-mixin.js#L21 but I don't see where it is explicitly used so it doesn't look like it would trigger an error message. It seems to be for IE8 support, https://github.com/jquery/jquery-ui/blob/1.12.1/ui/form.js so it could probably be removed safely.
#64.2 selectmenu is removed as part of this patch so that dependency isn't a problem, however labels and escape-selector are both requried by checkboxradio. Labels also isn't called directly but if escape-selector is missing there will be an error in the console, see #2926155: Follow-up to #2809427: update from jQuery UI 1.11.4 to 1.12.1 forgot to list some new JS files in *.libraries.yml
In general is it better to do this kind of cleanup here or in a follow-up?
Any of these removals would require changes to the source files- at minimum to remove from the AMD define functions.
Comment #66
zrpnr#62
Fixed the spacing by copying the file directly.
#41
Opened https://github.com/alexpott/d8githooks/issues/28 and created a PR.
Working on d8githooks I realized this needs a
--check
option for thatpre-commit
to work, added an additional js file that matches the check for es6 files. It returns an error if the compiled code does not match the existing file.Comment #67
zrpnrComment #68
randomyao22 CreditAttribution: randomyao22 as a volunteer commentedI have done a test with patch in #66.
The dialog and autocomplete are all works for me.
Testing video is attached.
Comment #69
lauriiiWe might want to consider adding a watch command for this but I don't think this is needed for getting this patch in ✅
Dependency evaluation has been added to the issue summary for the new dependency ✅
Should this also have a > in the closing tag? 🔬👁
Comment #70
xjmThanks @randomyao22 for helping manually test this!
Saving reviewer credit.
Comment #71
zrpnrIt looks like the only thing left is to fix the comment in #69.5
#69.6 I created #3098489: Remove deprecated jQuery UI library definitions to address the removal of the files in #64and #65
With these source files in core they can be modified to trim even more unused code without causing any errors.
Comment #72
zrpnrI misunderstood #64, those files should not have been removed here since they are depended on by remaining files.
Restored those 3 minified files: labels-min.js, form-min.js, escape-selector-min.js,
then added the source: labels.js, form.js, escape-selector.js and re-minified.
Also updated the IS for those 3.
Comment #73
lauriiiShould we revert these changes too?
Comment #74
bnjmnmRe: #73 This reverts the includes for
jquery.ui:
, those should be there since the files are not being removed. I don't believejquery.ui.selectmenu:
needs reverting as it's still among the libraries being removed and I did a quick grep in jQueryUI to confirm it's not a dependency anywhere that may have not been defined in core.libraries.yml.Comment #75
zrpnrThanks for catching those @lauriii and for updating the patch @bnjmnm !
You're right that selectmenu was not on the list to revert, it was marked deprecated and didn't have any dependents so it is safe to leave it removed.
These 3 files added back in #72 are the only ones that needed to be restored in core.libraries.yml
Comment #76
lauriiiThanks for pointing out that! You're right, we can remove
jquery.ui.selectmenu
. 👍I think we're done here, let's move on to working on the follow-ups. 🎉Comment #78
catchCommitted 75ac95e and pushed to 9.0.x. Thanks!