-
Notifications
You must be signed in to change notification settings - Fork 172
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
Update Nix and Node JS versions #3549
Conversation
Job #5649: Bundle Size — 49.78MiB (+0.41%).
Metrics (9 changes)
Total size by type (2 changes)
View job #5649 report View chore/update-nix-node branch activity |
@@ -1,7 +1,7 @@ | |||
diff --git a/node_modules/@emotion/react/dist/emotion-react.browser.cjs.js b/node_modules/@emotion/react/dist/emotion-react.browser.cjs.js | |||
diff --git a/dist/emotion-react.browser.cjs.js b/dist/emotion-react.browser.cjs.js |
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.
All of the patches are file renames (to match the style used by pnpm's native patching support to make updating the patches later easier), and the removal of /node_modules/<package_name>
from the file paths used in the diffs (like has happened here), so you can ignore the patch diffs
@@ -116,7 +116,7 @@ module.exports = { | |||
'\\.[jt]sx?$': 'babel-jest', | |||
}, | |||
roots: ['src', 'node_modules', '<rootDir>/node_modules'], | |||
transformIgnorePatterns: ['/node_modules/(?!utopia-api)'], // this lets ts-jest work on `/node_modules/utopia-api` which is a simlink to `../utopia-api`. | |||
transformIgnorePatterns: ['<rootDir>/node_modules/.pnpm/(?!file+..+)'], |
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.
I'm honestly not sure how this hadn't broken before, but it seems like we were on the edge of this breaking since we first switched to pnpm
"lint": "pnpx eslint \"src/**/*.{js,ts,tsx}\" --quiet", | ||
"lint-loud": "pnpx eslint \"src/**/*.{js,ts,tsx}\"", | ||
"check-code": "tsc --version && tsc --noEmit && pnpm run lint && pnpm run check-dependency-cruiser && pnpm run prettier-check", | ||
"lint": "eslint \"src/**/*.{js,ts,tsx}\" --quiet", |
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.
pnpx
had been changed over a year ago to become an alias for pnpm dlx
, which downloads and runs the latest version of a package, rather than using the locally installed version
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.
wow, good to know!
if (filePath.includes('node_modules')) { | ||
// We need to use the ts-loader to load the utopia-api module, | ||
// but nothing else from node_modules | ||
return filePath.includes('/utopia-api/') |
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.
Again, it seems like we have been on the verge of this breaking since we made the switch to pnpm
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.
I didn't know you can write a function here instead of a regex. this makes it much easier to maintain! bonus points for the comments!
(pkgs.writeScriptBin "install-utopia-api" '' | ||
#!/usr/bin/env bash | ||
set -e | ||
cd $(${pkgs.git}/bin/git rev-parse --show-toplevel)/utopia-api | ||
pnpm install | ||
pnpm run build | ||
'') |
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.
This was added to replace the script previously living in the editor's package.json
, which was causing build issues
pnpm = node.pkgs.pnpm; | ||
yarn = pkgs.yarn; | ||
|
||
pnpmPkg = pkgs.nodePackages_latest.pnpm.override { | ||
nativeBuildInputs = [ pkgs.makeWrapper ]; | ||
|
||
preRebuild = '' | ||
sed 's/"link:/"file:/g' --in-place package.json | ||
''; | ||
|
||
postInstall = let | ||
pnpmLibPath = pkgs.lib.makeBinPath [ | ||
node.passthru.python | ||
node | ||
]; | ||
in '' | ||
for prog in $out/lib/node_modules/pnpm/bin/*; do | ||
wrapProgram "$prog" --prefix PATH : ${pnpmLibPath} | ||
done | ||
''; | ||
}; | ||
pnpm = "${pnpmPkg}/lib/node_modules/pnpm/bin/pnpm.cjs"; | ||
pnpx = "${pnpmPkg}/lib/node_modules/pnpm/bin/pnpx.cjs"; | ||
|
||
yarn = "${pkgs.nodePackages_latest.yarn}/lib/node_modules/yarn/bin/yarn.js"; | ||
nodePackages = [ | ||
node | ||
pnpm | ||
(yarn.override { nodejs = node; }) | ||
]; |
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.
This is synching up the version of node used by pnpm and yarn
FWIW
|
"eslint-check": "eslint --quiet --ignore-path ./.eslintignore --config ./.eslintrc.js --ext .ts --ext .tsx src ../utopia-api/src ../utopia-vscode-extension/src ../utopia-vscode-common/src ../puppeteer-tests/src ../website-next/", | ||
"prettier-check": "prettier --ignore-path ../.prettierignore --config ../prettier.config.js --check src/** ../utopia-api/src/**/* ../utopia-vscode-common/src/** ../utopia-vscode-extension/src/** ../puppeteer-tests/src/** ../website-next/pages/** ../website-next/components/**", | ||
"parse-print-analysis": "npx -s sh ts-node --require ignore-styles --transpile-only ./src/scripts/parse-print-analysis.ts", | ||
"parse-debug": "npx -s sh ts-node --pretty --require ignore-styles --transpile-only ./src/scripts/parse-debug.ts", | ||
"fetch-tailwind-classes": "npx -s sh ts-node --pretty --require ignore-styles --transpile-only ./src/scripts/fetch-and-parse-tailwind-classes.ts && npx prettier --write ./src/core/third-party/tailwind-defaults.ts", | ||
"lint-editor": "lint-staged", | ||
"dev-fast": "APP_ENV=development REACT_APP_ENVIRONMENT_CONFIG=development REACT_APP_AUTH0_CLIENT_ID=$AUTH0_CLIENT_ID REACT_APP_AUTH0_ENDPOINT=$AUTH0_ENDPOINT REACT_APP_AUTH0_REDIRECT_URI=$AUTH0_REDIRECT_URI REACT_APP_COMMIT_HASH=`git rev-parse HEAD` vite --force", | ||
"vite-build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite build -- -DEBUG" | ||
"vite-build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite build -- -DEBUG", | ||
"watch-tsc": "tsc --watch && NODE_OPTIONS='--max_old_space_size=4096 --openssl-legacy-provider'" |
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.
I think this will also make iTerm 2's cmd + click to open VSCode work properly!
"staging-print-json": "pnpm run staging -- --json=lib/staging-stats.json", | ||
"install-utopia-api": "cd ../utopia-api && pnpm install && pnpm run build && pnpm run dts-bundle", | ||
"preinstall": "npx only-allow pnpm && pnpm run install-utopia-api", | ||
"postinstall": "patch-package", |
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.
nice!
Problem:
The version of node.js we have been using is old and needed updating in order to build the latest version of VS Code.
Fix:
Update the node.js version to v16.18.1, and update nix to the latest stable version (22.11).
The reason for the nix update is because the previous version of node we were using was the latest v16 version available on the older nix release.
Updating nix revealed that a package we were using on the server for the AWS API (amazonka) had been effectively abandoned and marked as broken, so that has been replaced with a new package (aws). Whilst we were there we also updated the version of the haskell compiler so that we could continue to pull cached builds from hydra as part of the server build (without that we'd have to build every single package in the dependency chain, making the build very long and painful).
Updating Node introduced / flagged the following issues that are resolved in this PR:
Error: error:0308010C:digital envelope routines::unsupported
is thrown by webpack builds due to its use of a crypto function now considered to be legacy. The workaround for this is to use the node flag--openssl-legacy-provider
pretty much everywhere. Further details here.exclude
rule with an explicitinclude
rule in the editor's webpack config file for that loader. I'm not entirely sure why this only affects the dependency onutopia-api
and notutopia-vscode-common
.pnpx tsc
in places we were using a different version oftsc
to the one coming from thetypescript
package specified in thepackage.json
, so those cases have been replaced with an explicit node script instead.patch-package
was causing issues with pnpm, and is no longer necessary as pnpm has native support for patching, so the patches andpackage.json
have been updated to reflect that.utopia-api
were not only unnecessary, but were actively causing issues during the build, so those have been removed now and replaced with an install and build step in theinstall-editor
script used everywhere.