Skip to content

Adjust imports in scripts and webpack directories - #4739

Open
alanorth wants to merge 13 commits into
DSpace:mainfrom
alanorth:node-prefix-imports
Open

Adjust imports in scripts and webpack directories#4739
alanorth wants to merge 13 commits into
DSpace:mainfrom
alanorth:node-prefix-imports

Conversation

@alanorth

@alanorth alanorth commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Related

Description

A handful of import- and console.log-related fixes were missed in the scripts and webpack directories due to the lint configuration in angular.json not considering them.

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:

  • First, update lint configuration in angular.json to consider scripts and webpack directories
  • Second, run npm run lint-fix to automatically fix as many errors as possible
  • Third, add node: prefix to several imports of internal Node.js APIs (fs and path) and scope to methods we use
  • Fourth, disable eslint for copy-webpack-plugin because it doesn't support ES Module imports
  • Fifth, remove unused sass and lodash imports
  • Sixth, rework JSON5, commander, and cli-progress imports to use scoped ES Module imports
  • Seventh, use scoped imports for lodash modules
  • Eighth, replace console.log() usage with console.info()

Include guidance for how to test or review your PR. This may include: steps to reproduce a bug, screenshots or description of a new feature, or reasons behind specific changes.

Make sure the dev and prod builds are successful.

Make sure i18n scripts work:

$ npm run merge-i18n -- -s src/themes/custom/assets/i18n
$ npm run sync-i18n

Make sure all tests in CI pass.

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 code task 1 APPROVAL pull request only requires a single approval to merge port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release labels Sep 30, 2025
@alanorth alanorth added this to the 10.0 milestone Sep 30, 2025
@alanorth alanorth added the dependencies Pull requests that update a dependency file label Sep 30, 2025
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Sep 30, 2025
@alanorth
alanorth force-pushed the node-prefix-imports branch 2 times, most recently from d76f3da to 0f1295b Compare October 1, 2025 10:05
@alanorth
alanorth force-pushed the node-prefix-imports branch from 0f1295b to 254ea5b Compare November 10, 2025 12:09
@tdonohue
tdonohue self-requested a review November 10, 2025 15:46
@github-actions

Copy link
Copy Markdown

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

@nwoodward

Copy link
Copy Markdown
Contributor

@alanorth I'm sorry I didn't look at this sooner. It's mainly formatting and prefixes. Can you fix the conflicts and I'll review it?

@nwoodward
nwoodward self-requested a review January 23, 2026 22:51

@alexandrevryghem alexandrevryghem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thnx @alanorth for this PR! I already took a quick look at the changed files and it looks great. I did add one small inline suggestion, but I will do a full review once those conflicts are resolved

Comment thread webpack/helpers.ts Outdated
@github-project-automation github-project-automation Bot moved this from 🙋 Needs Reviewers Assigned to 👀 Under Review in DSpace 10.0 Release Apr 3, 2026
Comment thread webpack/webpack.mirador.config.ts Outdated
@alanorth

Copy link
Copy Markdown
Contributor Author

The scope of this PR has changed because main updated the linting rules. Now there are more things to fix in the scripts and webpack directories. I am working on it.

@alanorth alanorth changed the title Add node: prefix to internal imports Adjust imports in scripts and webpack directories Apr 17, 2026
@alanorth
alanorth force-pushed the node-prefix-imports branch from cce3c97 to 452f0e2 Compare April 17, 2026 19:16
@alanorth

alanorth commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure why the lodash import rule is triggering, since we are importing individual methods:

import {
  isEmpty,
  isEqual,
} from 'lodash';

Must be something subtle about the plugin's configuration? @alexandrevryghem?

@alexandrevryghem

Copy link
Copy Markdown
Member

@alanorth: It's part of the lodash/import-scope rule. The correct usage is:

import isEmpty from 'lodash/isEmpty';
import isEqual from 'lodash/isEqual';

@MMilosz MMilosz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, I was reading article about replacing lodash with lodash-es and found this PR in a result. The failing e2e tests looked suspicious until I ran them locally, seeing i18n keys missing:

Image

I ctrl+f 'json' in the PR & found change in webpack.common.ts transform(content). @alanorth after applying the fix (see comment), all e2e tests passed locally for me

EDIT: I rebased your changes from this PR into the latest main and confirm it generally works! (except the i18n issue)

Comment thread webpack/webpack.common.ts
@alanorth
alanorth force-pushed the node-prefix-imports branch 2 times, most recently from 78b85ad to 1b3fae0 Compare August 8, 2026 07:36
@alanorth

alanorth commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your comments @MMilosz. This is now rebased on top of latest main for DSpace 11.0-SNAPSHOT and all tests in CI are passing.

@alanorth
alanorth requested a review from MMilosz August 8, 2026 08:43

@MMilosz MMilosz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Always great to see work being done to modernize the frontend tooling

I left one minor detail regarding the glob pattern in angular.json, but overall this is a great cleanup

Comment thread angular.json Outdated
@alanorth
alanorth force-pushed the node-prefix-imports branch from 1b3fae0 to 8cd62a0 Compare August 8, 2026 16:04
alanorth added 13 commits August 8, 2026 19:05
Include the scripts and webpack directories in linting.
Automatically fix most lint errors.
Don't use require-style imports and scope some imports of path and
fs so we only import methods we are using.
Disable the no-require-imports rule for copy-webpack-plugin because
it does not support ES Module style imports.
Don't use a require-style import, and only import the methods we
are actually using.
Don't use require-style imports, and only import the methods that
we actually use instead of the whole module. Also, we need to use
a different syntax to access the parsed opts after this for some
reason.
Don't use require-style imports, and scope the imports to only the
methods we are using.
Don't use require-style imports, and only import the methods that
we are actually using.
Disable eslint rule for require-style imports here since this isn't
importing a Node.js module, but a command line argument.
@alanorth
alanorth force-pushed the node-prefix-imports branch from 8cd62a0 to f991052 Compare August 8, 2026 16:12
@alanorth

alanorth commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Closing and re-opening to restart jobs.

@alanorth alanorth closed this Aug 8, 2026
@github-project-automation github-project-automation Bot moved this from 👀 Under Review to ✅ Done in DSpace 11.0 Release Aug 8, 2026
@alanorth alanorth reopened this Aug 8, 2026
@alanorth alanorth modified the milestones: 10.1, 11.0 Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge code task dependencies Pull requests that update a dependency file

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

6 participants