DEV: Enable patch-package in production and in javascripts/discourse (#21078)

When running `yarn install` in a yarn workspace, the lifecycle hooks in the root package.json are not triggered. https://github.com/yarnpkg/yarn/issues/5790

As a workaround, we can additionally run `patch-package` from the `javascripts/discourse/package.json` `postinstall` hook. `patch-package` is idempotent, so it doesn't matter if it is triggered multiple times.

Longer term we intend to move to pnpm, which has built-in patch support.
This commit is contained in:
David Taylor 2023-04-12 13:15:53 +01:00 committed by GitHub
parent 7d34ba38a2
commit a328153ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -13,7 +13,8 @@
"scripts": {
"build": "ember build",
"start": "ember serve",
"test": "ember test"
"test": "ember test",
"postinstall": "yarn --silent --cwd .. patch-package"
},
"dependencies": {
"@babel/core": "^7.21.4",

View File

@ -22,9 +22,9 @@
"resolutions": {
"**/babel-plugin-debug-macros": "npm:@discourse/babel-plugin-debug-macros@0.4.0-pre1"
},
"devDependencies": {
"devDependencies": {},
"dependencies": {
"patch-package": "^6.5.1",
"postinstall-postinstall": "^2.1.0"
},
"dependencies": {}
}
}

View File

@ -58,7 +58,7 @@
"lttf:ignore": "lint-to-the-future ignore",
"lttf:output": "lint-to-the-future output -o ./lint-progress/",
"lint-progress": "yarn lttf:output && npx html-pages ./lint-progress --no-cache",
"postinstall": "yarn --cwd app/assets/javascripts/discourse $(node -e 'if(JSON.parse(process.env.npm_config_argv).original.includes(`--frozen-lockfile`)){console.log(`--frozen-lockfile`)}')"
"postinstall": "yarn --cwd app/assets/javascripts $(node -e 'if(JSON.parse(process.env.npm_config_argv).original.includes(`--frozen-lockfile`)){console.log(`--frozen-lockfile`)}')"
},
"engines": {
"node": "16.* || >= 18",