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

Get frontend dependencies from NPM instead of vendoring them #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JulianKniephoff
Copy link
Member

Not all of the libraries we were using could be found (in the correct version) in NPM, so had to get creative with some of them.

I tried to stick to our current versions as closely as possible, except for some that were easy to update. Thus, most versions are pinned instead of using the usual ^x.y.z constraint. Only ones where we are using a current version anyway, and where minor updates should be fine use the more traditional constraint.

Here are the detailed notes about where dependencies (might have) changed:

  • vis-timeline should be in the correct version, but the NPM build is a few moments younger, and differs slightly. I hope it's just variable naming or something like that, but comparing minified JS is hard, so I'm not 100% sure.
  • jquery.colorPicker (or rather really-simple-colorpicker as the NPM package is called) is newer, because the original version isn't in NPM. Our use of it is relatively isolated, though, and it still seems to work superficially, so I'm relatively confident that this is fine.
  • jquery.appear was never actually in use, so I removed it.
  • jquery itself is updated to 1.8.2. We were on 1.8.0 which is not in NPM. 1.8.2 is, and that should be fine, but jQuery is one of these candidates that you can never really be sure about since it doesn't follow SemVer perfectly and is used so pervasively, that even checking all our usages against the changelog is basically impossible.
  • i18next-xhr-backend was replaced with (the newest version of) i18next-http-backend. The former is deprecated and not in NPM anymore, but the update here is literally a drop in replacement, apparently.
  • Our Bootstrap version (2.3.2) is so dead it's not even funny. No 2.x release is in NPM. Fortunately in this case one can just install it directly from their GitHub using the appropriate tag, but this is a bit shady and I want to get rid of it sooner rather than later. Unfortunately upgrading Bootstrap is a rather invasive step.
  • The Bootstrap slider thing we were using doesn't even have a GitHub. I replaced it with one that does, and which is based on our original one. I used the oldest release they have on GitHub, and seems to be more or less the same, still, but there have been significant code changes between the two. As with the color picker, this is a rather isolated thing, though, so we should be fine?
  • The RequireJS text plugin wasn't used anymore, so I got rid of it.
  • RequireJS domReady only has newer versions in NPM, but they seem to work fine, even though there was a major jump here.
  • moment got a minor update because the version we were using was actually incompatible with our vis-timeline version, and our own few uses should still work exactly the same. Note that this is merely a convenience to make npm install work. We are using all of these libraries pre-bundled, so vis-timeline isn't actually using the version of moment we are including, but rather comes with its own.

Fixes #138.
Fixes #457.

Not all of the libraries we were using could be found
(in the correct version) in NPM, so had to get creative
with some of them.

I tried to stick to our current versions as closely as possible,
except for some that were easy to update. Thus, most versions are
pinned instead of using the usual `^x.y.z` constraint. Only ones
where we are using a current version anyway, and where minor updates
should be fine use the more traditional constraint.

Here are the detailed notes about where dependencies (might have)
changed:

* `vis-timeline` should be in the correct version, but the NPM build
  is a few moments younger, and differs slightly. I hope it's just
  variable naming or something like that, but comparing minified JS
  is hard, so I'm not 100% sure.
* `jquery.colorPicker` (or rather `really-simple-colorpicker` as the
  NPM package is called) is newer, because the original version isn't
  in NPM. Our use of it is relatively isolated, though, and it still
  seems to work superficially, so I'm relatively confident that this
  is fine.
* `jquery.appear` was never actually in use, so I removed it.
* `jquery` itself is updated to `1.8.2`. We were on `1.8.0` which is
  not in NPM. `1.8.2` is, and that should be fine, but jQuery is one
  of these candidates that you can never really be sure about since it
  doesn't follow SemVer perfectly and is used so pervasively, that
  even checking all our usages against the changelog is basically
  impossible.
* `i18next-xhr-backend` was replaced with (the newest version of)
  `i18next-http-backend`. The former is deprecated and not in NPM
  anymore, but the update here is literally a drop in replacement,
  apparently.
* Our Bootstrap version (`2.3.2`) is so dead it's not even funny.
  No `2.x` release is in NPM. Fortunately in this case one can just
  install it directly from their GitHub using the appropriate tag,
  but this is a bit shady and I want to get rid of it sooner rather
  than later. Unfortunately upgrading Bootstrap is a rather invasive
  step.
* The Bootstrap slider thing we were using doesn't even have a GitHub.
  I replaced it with one that does, and which is based on our original
  one. I used the oldest release they have on GitHub, and seems to be
  more or less the same, still, but there have been significant code
  changes between the two. As with the color picker, this is a rather
  isolated thing, though, so we should be fine?
* The RequireJS `text` plugin wasn't used anymore, so I got rid of it.
* RequireJS `domReady` only has newer versions in NPM, but they seem
  to work fine, even though there was a major jump here.
* `moment` got a minor update because the version we were using was
  actually incompatible with our `vis-timeline` version, and our own
  few uses should still work exactly the same. Note that this is
  merely a convenience to make `npm install` work. We are using
  all of these libraries pre-bundled, so `vis-timeline` isn't actually
  using the version of `moment` we are including, but rather comes
  with its own.

Fixes opencast#138.
Fixes opencast#457.
Copy link
Member

@Arnei Arnei left a comment

Choose a reason for hiding this comment

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

Glad this is getting done. The explanations on why which npm modules were chosen sound very reasonable to me. Looking forward to updated dependencies (bootstrap) in the future.

I am running into a build error and not seeing an immediately obvious fix:

[INFO] npm ERR! npm ERR! code 1
[INFO] npm ERR! npm ERR! path /home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/phantomjs
[INFO] npm ERR! npm ERR! command failed
[INFO] npm ERR! npm ERR! command sh -c node install.js
[INFO] npm ERR! npm ERR! PhantomJS not found on PATH
[INFO] npm ERR! npm ERR! Phantom installation failed TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
[INFO] npm ERR! npm ERR!     at new NodeError (node:internal/errors:371:5)
[INFO] npm ERR! npm ERR!     at validateString (node:internal/validators:119:11)
[INFO] npm ERR! npm ERR!     at Object.join (node:path:1172:7)
[INFO] npm ERR! npm ERR!     at findSuitableTempDirectory (/home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/phantomjs/install.js:127:30)
[INFO] npm ERR! npm ERR!     at /home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/phantomjs/install.js:476:19
[INFO] npm ERR! npm ERR!     at nextTickCallback (/home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/kew/kew.js:47:28)
[INFO] npm ERR! npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:78:11) {
[INFO] npm ERR! npm ERR!   code: 'ERR_INVALID_ARG_TYPE'
[INFO] npm ERR! npm ERR! } TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
[INFO] npm ERR! npm ERR!     at new NodeError (node:internal/errors:371:5)
[INFO] npm ERR! npm ERR!     at validateString (node:internal/validators:119:11)
[INFO] npm ERR! npm ERR!     at Object.join (node:path:1172:7)
[INFO] npm ERR! npm ERR!     at findSuitableTempDirectory (/home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/phantomjs/install.js:127:30)
[INFO] npm ERR! npm ERR!     at /home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/phantomjs/install.js:476:19
[INFO] npm ERR! npm ERR!     at nextTickCallback (/home/arnewilken/.npm/_cacache/tmp/git-clonel6Eszu/node_modules/kew/kew.js:47:28)
[INFO] npm ERR! npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:78:11)
$ npm --version
9.6.7
$ node --version
v18.17.0

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

Successfully merging this pull request may close these issues.

i18next-xhr-backend is deprecated Use proper dependency management
2 participants