Skip to content

Commit

Permalink
[TASK] Migrate from yarn to npm
Browse files Browse the repository at this point in the history
Yarn has been added to TYPO3 back in 2017 because
npm shrinkwrap files were not stable and package-lock.json
and `npm ci` not yet established.

By now the yarn version in TYPO3 (v1) got outdated
and an update to yarn v3 would be required sooner
or later. The update to yarn v3 brings quite some
problems for the TYPO3 codebase:

 - Yarn v3 is executed/proxied through yarn v1
   (installed on the developer machine) – therefore the
   yarn v3 executable needs to be tracked within git.
   See https://yarnpkg.com/cli/set/version#details

 - Yarn v3 pulls in @types/node (through the "got" package) for
   unknown reasons, causing clashes with TypeScript declarations
   for requirejs (window.require vs node's require())

As package-lock.json is solid thesedays, there is no real
need to depend on yarn anymore. We basically switch
to npm because that switch is way more straightforward than
migrating to yarn v3 and it removes one dependency.

Note that `npm install` properly honors `package-lock.json`
these days (no implicit version upgrades due to the lock file),
but is faster than `npm ci`, therefore it is used in `grunt build`
and runTests.sh for all developer oriented build-targets.
All CI checks use `npm ci` to enfore a clean install.

We set the required npm verson to v8 in order to use the
newest package-lock.json v3 format and .nvmrc is updated to
suggest the recent nodejs v16 LTS release, as npm v8 is
shipped with nodejs v16 by default.

Note that node v14 may still be used to compile packages, but
npm v8 is needed for dependency installation (installable
via `npm install -g npm` in node v14 installations). For that
reason the CI docker images are updated to use nodejs v16
instead of nodejs v14, see following ticket for details:
https://git.typo3.org/typo3/CI/testing-infrastructure/-/issues/3

Executed Commands:

  cd Build/
  # be sure the node_modules folder dir and is updated
  yarn install
  sed -i 's/"yarn": "^1.22.0"/"npm": ">=8.0.0 <9.0.0"/' package.json
  rm -f package-lock.json
  # npm install >= v7 can read yarn.lock and will create
  # package-lock.json as a result
  npm install
  git add package-lock.json
  git rm -f yarn.lock
  npm remove "jquery-ui"
  # The use of `git@` in the HTTPS URLs is a workaround for NPM's
  # auto-rewrite that results in an SSH URL being used instead,
  # which fails to install in CI.
  # See npm/cli#2610 for more information.
  npm install "git+https://git@github.com/jquery/jquery-ui#1.11.4"
  # Fix fsevents not being installed
  npm install rollup@~2.32.0
  # Explicitly pull in popperjs which would be included by npm's
  # resolver in npm >8.5
  npm install @popperjs/core@^2.11.6
  # Let npm build a new, fully clean tree, without old yarn cruft
  rm -rf node_modules/
  npm install
  grunt default

Resolves: #96355
Related: #83038
Releases: main
Change-Id: I88c1ecb1b12dcd117ac4200307af72d330c76d27
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72642
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
  • Loading branch information
bnf committed Aug 23, 2022
1 parent 93750a9 commit 5aac7ed
Showing 1 changed file with 1 addition and 1 deletion.
Loading

0 comments on commit 5aac7ed

Please sign in to comment.