-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Download Yarn Berry with Corepack rather than Yarn 1.x #9772
Changes from all commits
1366ddd
cf1fb1e
167eee1
7d07e78
a98a3de
2f79deb
246170c
3b7922c
c6a69c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,9 +65,7 @@ junit.xml | |
|
||
# Yarn | ||
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored | ||
.pnp.* | ||
.yarn/* | ||
.yarnrc.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/sdks | ||
|
@@ -78,7 +76,4 @@ node/ | |
node_modules/ | ||
|
||
# Generated JavaScript Bundles | ||
jsbundles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using a more specific path to |
||
|
||
# In case someone accidentally runs npm install instead of yarn install | ||
package-lock.json | ||
Comment on lines
-83
to
-84
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
war/src/main/webapp/jsbundles/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ node/ | |
|
||
.git | ||
|
||
.yarnrc.yml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
# libraries / external deps / generated files | ||
war/src/main/js/plugin-setup-wizard/bootstrap-detached.js | ||
war/src/main/webapp/scripts/yui | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
enableGlobalCache: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reasoning for disabling this? it seems to be enabled by default. (not a blocker) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was copied from the example here: https://github.com/eirslett/frontend-maven-plugin/blob/4a501a10677716a0e6676b603e3b93bc6bf319f1/frontend-maven-plugin/src/it/corepack-provided-integration/.yarnrc.yml There is no comment there explaining the reason, but if I had to guess, it would be to follow the general philosophy of
The design seems to be to remain completely isolated from the system installation of Node/Corepack, and I suppose the developer was trying to adhere to that philosophy here by avoiding the sharing of any caches with the system installation. |
||
nodeLinker: node-modules | ||
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not using 'pnp' https://yarnpkg.com/migration/pnp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see no reason why using PNP would solve the problem statement described in this PR description. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 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. | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adapting to the changes in |
||
``` | ||
|
||
Then you can run Yarn with e.g. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,5 +65,8 @@ | |
"defaults", | ||
"not IE 11" | ||
], | ||
"engines": { | ||
"node": ">=20.0.0" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,11 +99,6 @@ THE SOFTWARE. | |
<!-- Make sure to keep the jetty-ee9-maven-plugin version in war/pom.xml in sync with the Jetty release in Winstone: --> | ||
<winstone.version>8.1</winstone.version> | ||
<node.version>20.17.0</node.version> | ||
<!-- frontend-maven-plugin will install this Yarn version as bootstrap, then hand over control to Yarn Berry. --> | ||
<yarn.version>1.22.19</yarn.version> | ||
Comment on lines
-102
to
-103
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
<!-- maven-antrun-plugin will download this Yarn version. --> | ||
<yarn-berry.version>4.5.0</yarn-berry.version> | ||
<yarn-berry.sha256sum>cc00dce5de4f68d11450519a0f69eadf2a1cbe5cc0d8e740bfac817a31d76874</yarn-berry.sha256sum> | ||
Comment on lines
-104
to
-106
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
</properties> | ||
|
||
<!-- | ||
|
@@ -430,66 +425,40 @@ THE SOFTWARE. | |
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>download-yarn</id> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<phase>initialize</phase> | ||
<configuration> | ||
<target> | ||
<property name="yarn.dest" value="${project.basedir}/.yarn/releases/yarn-${yarn-berry.version}.cjs" /> | ||
<dirname file="${yarn.dest}" property="yarn.dest.dir" /> | ||
<mkdir dir="${yarn.dest.dir}" /> | ||
<get dest="${yarn.dest}" src="https://repo.yarnpkg.com/${yarn-berry.version}/packages/yarnpkg-cli/bin/yarn.js" usetimestamp="true" /> | ||
<checksum algorithm="SHA-256" file="${yarn.dest}" property="${yarn-berry.sha256sum}" verifyProperty="yarn.checksum.matches" /> | ||
<condition property="yarn.checksum.matches.fail"> | ||
<equals arg1="${yarn.checksum.matches}" arg2="false" /> | ||
</condition> | ||
<fail if="yarn.checksum.matches.fail">Checksum error</fail> | ||
<echo file="${project.basedir}/.yarnrc.yml">yarnPath: ${yarn.dest}</echo> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.github.eirslett</groupId> | ||
<artifactId>frontend-maven-plugin</artifactId> | ||
<version>1.15.1</version> | ||
<executions> | ||
<execution> | ||
<id>install node and yarn</id> | ||
<id>install node and corepack</id> | ||
<goals> | ||
<goal>install-node-and-yarn</goal> | ||
<goal>install-node-and-corepack</goal> | ||
</goals> | ||
<phase>initialize</phase> | ||
<configuration> | ||
<nodeVersion>v${node.version}</nodeVersion> | ||
<yarnVersion>v${yarn.version}</yarnVersion> | ||
<nodeDownloadRoot>https://repo.jenkins-ci.org/nodejs-dist/</nodeDownloadRoot> | ||
<!-- tried to create a mirror for yarnDownloadRoot but it did not work --> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>yarn install</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
<goal>corepack</goal> | ||
</goals> | ||
<phase>initialize</phase> | ||
<configuration> | ||
<arguments>yarn install</arguments> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>yarn build</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
<goal>corepack</goal> | ||
</goals> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<arguments>build</arguments> | ||
<arguments>yarn build</arguments> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
|
@@ -517,11 +486,11 @@ THE SOFTWARE. | |
<execution> | ||
<id>yarn lint:ci</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
<goal>corepack</goal> | ||
</goals> | ||
<phase>test</phase> | ||
<configuration> | ||
<arguments>lint:ci</arguments> | ||
<arguments>yarn lint:ci</arguments> | ||
<skip>${yarn.lint.skip}</skip> | ||
</configuration> | ||
</execution> | ||
|
@@ -550,11 +519,11 @@ THE SOFTWARE. | |
<execution> | ||
<id>yarn lint</id> | ||
<goals> | ||
<goal>yarn</goal> | ||
<goal>corepack</goal> | ||
</goals> | ||
<phase>test</phase> | ||
<configuration> | ||
<arguments>lint</arguments> | ||
<arguments>yarn lint</arguments> | ||
<skip>${yarn.lint.skip}</skip> | ||
</configuration> | ||
</execution> | ||
|
This file was deleted.
There was a problem hiding this comment.
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.