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

Use eirslett/frontend-maven-plugin#1157 #9772

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

basil
Copy link
Member

@basil basil commented Sep 22, 2024

Decrease the maintenance burden in this repository by replacing our custom Ant (!) based code to bootstrap Yarn Berry using Yarn 1.x with Corepack as implemented in eirslett/frontend-maven-plugin#1157.

Testing done

Introduced stylelint and eslint failures in both CI and local builds. In both cases, verified that the error message was readable: in local builds, on the CLI; and in CI builds, in the Jenkins UI.

For the local builds, tested without path modifications on my local machine with Node LTS installed as well as with path modifications inside of a Docker container with no existing Node/NPM installation, thus exercising both supported paths as documented in CONTRIBUTING.md.

Proposed changelog entries

N/A

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

@basil basil added the skip-changelog Should not be shown in the changelog label Sep 22, 2024
@@ -65,9 +65,7 @@ junit.xml

# Yarn
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.pnp.*
Copy link
Member Author

Choose a reason for hiding this comment

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

See the comments to .yarnrc.yml below for explanation.

.yarn/*
.yarnrc.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously automatically generated on the fly by our custom Ant-based logic. This Ant-based logic is now deleted, and instead this file is checked into Git. This removes a layer of indirection and makes the code simpler, since the file that is used is now static rather than dynamically generated.

@@ -78,7 +76,4 @@ node/
node_modules/

# Generated JavaScript Bundles
jsbundles
Copy link
Member Author

Choose a reason for hiding this comment

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

Using a more specific path to jsbundles, since there is only a single such directory.

Comment on lines -83 to -84
# In case someone accidentally runs npm install instead of yarn install
package-lock.json
Copy link
Member Author

Choose a reason for hiding this comment

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

Using NPM is not supported, and having code in the source tree to handle an unsupported configuration by silently ignoring it (rather than failing fast) violates the principle of least surprise.

@@ -7,8 +7,6 @@ node/

.git

.yarnrc.yml
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer automatically generated, so we can adhere to Prettier formatting rules now.

Comment on lines +1 to +2
enableGlobalCache: false
nodeLinker: node-modules
Copy link
Member Author

Choose a reason for hiding this comment

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

As recommended in https://github.com/eirslett/frontend-maven-plugin/blob/4a501a10677716a0e6676b603e3b93bc6bf319f1/frontend-maven-plugin/src/it/corepack-provided-integration/.yarnrc.yml. Note that without the nodeLinker line eirslett/frontend-maven-plugin#1157 does not actually work, instead complaining about corepack not being listed in package.json. I filed for another day any latent curiosity about why this might be the case (probably a deficiency in frontend-maven-plugin documentation at the very least).

@@ -53,12 +53,12 @@ MAVEN_OPTS='--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/ja
### Running the Yarn frontend build

> [!TIP]
> If you already have Node.js installed, you do not need to change your path. Start using `yarn` by enabling [Corepack](https://yarnpkg.com/corepack) with `corepack enable`, if it isn't already; this will add the `yarn` binary to your PATH.
> If you already have Node.js 20.x LTS installed, you do not need to change your path. Start using Yarn by enabling [Corepack](https://yarnpkg.com/corepack) with `corepack enable`, if it isn't already; this will add the `yarn` binary to your path.
Copy link
Member Author

Choose a reason for hiding this comment

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

Clarifying that we only support Node.js 20.x LTS.

I changed the first occurence of "yarn" to "Yarn" because this is a reference to the Yarn project, not the yarn binary. Even though we later use "yarn binary" in the same sentence, this is not inconsistent because the first usage refers to the project and the second usage refers to the binary.

Elsewhere in the sentence we replace "PATH" with "path" for consistency with the beginning of the sentence and the rest of the document. While both "PATH" (as a particular variable name) or "path" (referring to the general concept of a search path) would be correct here, this document generally uses the latter, so be consistent with usage elsewhere in this sentence and in this document.

To run the Yarn frontend build, after [building the WAR file](#building-the-war-file), add the downloaded versions of Node and Yarn to your path:

```sh
export PATH=$PWD/node:$PWD/node/yarn/dist/bin:$PATH
export PATH=$PWD/node:$PWD/node/node_modules/corepack/shims:$PATH
Copy link
Member Author

Choose a reason for hiding this comment

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

Adapting to the changes in pom.xml below.

@@ -1,20 +0,0 @@
work
Copy link
Member Author

Choose a reason for hiding this comment

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

Unneeded now that the corresponding entries are in the root directory's .gitignore file.

Comment on lines -102 to -103
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. -->
<yarn.version>1.22.19</yarn.version>
Copy link
Member Author

Choose a reason for hiding this comment

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

Yarn 1.x is now no longer needed to bootstrap Yarn Berry, since we now use Corepack for this purpose.

Comment on lines -104 to -106
<!-- maven-antrun-plugin will download this Yarn version. -->
<yarn-berry.version>4.5.0</yarn-berry.version>
<yarn-berry.sha256sum>cc00dce5de4f68d11450519a0f69eadf2a1cbe5cc0d8e740bfac817a31d76874</yarn-berry.sha256sum>
Copy link
Member Author

Choose a reason for hiding this comment

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

This duplicate information is no longer needed, as this information is consumed from package.json via Corepack.

@basil basil marked this pull request as ready for review September 22, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant