Skip to content

Update dependencies to use versions supporting ES modules#4098

Merged
tdonohue merged 2 commits intoDSpace:mainfrom
alanorth:update-es-deps
Apr 9, 2025
Merged

Update dependencies to use versions supporting ES modules#4098
tdonohue merged 2 commits intoDSpace:mainfrom
alanorth:update-es-deps

Conversation

@alanorth
Copy link
Contributor

@alanorth alanorth commented Mar 19, 2025

References

Add references/links to any related issues or PRs. These may include:

Description

Several dependencies are imported as CommonJS modules, which do not support tree shaking by bundlers like Webpack. This leads to warnings like this during build:

Warning: /home/aorth/src/git/dspace-angular/src/app/core/services/client-cookie.service.ts depends on 'js-cookie'. CommonJS or AMD dependencies can cause optimization bailouts.

In theory this should allow Webpack to create smaller bundles due to removing unused code.

Instructions for Reviewers

Please add a more detailed description of the changes made by your PR. At a minimum, providing a bulleted list of changes in your PR is helpful to reviewers.

List of changes in this PR:

  • Update filesize dependency to version that supports ES modules
  • Use lodash-es instead of lodash, which supports ES modules

TODO (help wanted), which will require code changes:

  • Update js-cookie to v3.0.0, requires code changes
  • Update orejime to v3.0.0, requires code changes
  • Replace date-fns-tz with @date-fns/tz or @date-fns/utc from the date-fns project, requires code changes

Include guidance for how to test or review your PR.

To test this PR, run npm run build after applying the patch and make sure the warnings for filesize and lodash are gone.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You do not need to complete this checklist prior creating your PR (draft PRs are always welcome).
However, reviewers may request that you complete any actions in this list if you have not done so. If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

@alanorth alanorth added dependencies Pull requests that update a dependency file performance / caching Related to performance, caching or embedded objects code task labels Mar 19, 2025
@alanorth alanorth marked this pull request as draft March 19, 2025 15:19
@alanorth
Copy link
Contributor Author

alanorth commented Mar 19, 2025

Submitting a draft version of the PR to update some dependencies to newer versions supporting ES modules. I would appreciate some help if anyone has ideas about, or time to work on, the TODO dependencies.

Also, I want to see if the existing dependencies I've updated break anything in CI.

@alanorth alanorth requested a review from saschaszott March 19, 2025 15:21
@alanorth alanorth changed the title Update filesize.js dependency Update dependencies to use versions supporting ES modules Mar 19, 2025
@alanorth alanorth force-pushed the update-es-deps branch 2 times, most recently from cc17907 to 37e3634 Compare March 19, 2025 17:55
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 9.0 Release Mar 24, 2025
@github-actions
Copy link

Hi @alanorth,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Newer releases support ES modules. Also remove unneccessary eslint
skip hint.
@alanorth alanorth marked this pull request as ready for review April 1, 2025 08:46
@alanorth
Copy link
Contributor Author

alanorth commented Apr 1, 2025

The remaining dependencies require code changes to implement and I don't have time to look into those. I suggest reviewing and merging the proposed changes for two dependencies so we can get rid of those two warnings.

@saschaszott
Copy link
Contributor

saschaszott commented Apr 1, 2025

@alanorth , should we better replace "@types/lodash": "^4.17.15", by "@types/lodash-es": "^4.17.12", in package.json?

@saschaszott
Copy link
Contributor

I've cherry-picked the proposed changes. The warnings regarding filesize and lodash are gone. Thanks, @alanorth .

lodash-es supports ES modules.
@alanorth
Copy link
Contributor Author

alanorth commented Apr 1, 2025

@alanorth , should we better replace "@types/lodash": "^4.17.15", by "@types/lodash-es": "^4.17.12", in package.json?

@saschaszott oh yes! I didn't even think to look for types. I've updated the types for lodash-es. Thanks.

@github-project-automation github-project-automation bot moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 9.0 Release Apr 1, 2025
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @alanorth ! I gave this a quick verification test today and noticed no differences in behavior. The changes look good too

@tdonohue tdonohue added this to the 9.0 milestone Apr 9, 2025
@tdonohue tdonohue merged commit 7795d96 into DSpace:main Apr 9, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 9.0 Release Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code task dependencies Pull requests that update a dependency file performance / caching Related to performance, caching or embedded objects

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants