Skip to content

Replace dependencies providing AMD and CommonJS modules with those providing ES modules #4619

@alanorth

Description

@alanorth

Describe the bug

DSpace uses several dependencies that are packaged as AMD or CommonJS modules, which leads to several warnings during the build process. For example:

Warning: dspace-angular/src/app/core/services/client-cookie.service.ts depends on 'js-cookie'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.dev/tools/cli/build#configuring-commonjs-dependencies

This can lead to sub-optimal tree shaking in Webpack. Using ES Module (ESM) versions of these dependencies where possible allows Webpack to eliminate unused code, reducing bundle size and improving performance.

The list of dependencies causing these warnings is currently:

  • js-cookie
  • orejime/dist/orejime
  • leaflet
  • leaflet-providers
  • leaflet.markercluster
  • date-fns-tz

Some of these may have drop-in replacements, while others may require code changes.

Related work

Part of the work was completed for DSpace 9 in #4098. There is also more discussion in #4095.

Metadata

Metadata

Assignees

No one assigned

    Labels

    code taskdependenciesPull requests that update a dependency filehelp wantedNeeds a volunteer to claim to move forward

    Type

    Projects

    Status

    📋 To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions