[Package] Exclude unused dependencies when building package.json files#3232
[Package] Exclude unused dependencies when building package.json files#3232
package.json files#3232Conversation
|
@adamziel "dependencies": {
"express": "4.22.0",
"ini": "4.1.2",
"wasm-feature-detect": "1.8.0",
"ws": "8.18.3",
"yargs": "17.7.2",
"@php-wasm/universal": "3.0.46",
"@php-wasm/util": "3.0.46",
"@php-wasm/logger": "3.0.46"
},I can reliably say That is expected since I only indicate which dependency should be ignored. Two solutions : - "excludedDependencies": ["@php-wasm/node"]
+ "excludedDependencies": ["@php-wasm/node", "express", "ini", "wasm-feature-detect", "ws", "yargs"]Or we should find another way to ignore these subdependencies. Maybe this :
- if (!packageJson.dependencies) {
packageJson.dependencies = {};
- }
for (const dep of monorepoDependencies) {
packageJson.dependencies[dep.name] = dep.version;
}I expect having to clean each |
|
I may have a better suggestion here. Instead of For example "dependencies": {
- "express": "4.22.0",
- "ini": "4.1.2",
- "wasm-feature-detect": "1.8.0",
- "ws": "8.18.3",
- "yargs": "17.7.2",
"@php-wasm/universal": "3.0.46",
"@php-wasm/util": "3.0.46",
"@php-wasm/logger": "3.0.46"
- "@php-wasm/node": "3.0.46"
},So "filteredDependencies": ["@php-wasm/universal", "@php-wasm/util", "@php-wasm/logger"]Same with "dependencies": {
- "ini": "4.1.2",
"wasm-feature-detect": "1.8.0",
- "ws": "8.18.3",
"@php-wasm/universal": "3.0.46"
},So : "filteredDependencies": ["@php-wasm/universal", "wasm-feature-detect"]
|
Motivation for the change, related issues
This is based on this issue
While working on #3093, I found out
@php-wasm/nodewas installed alongside@php-wasm/web. While looking deeper into it, I found in thepackage-lock.jsonfile thatfs-journalhad@php-wasm/nodeas an unused dependency, since it was only used infs-journaltest files.Implementation details
Adding a new
excludedDependenciesoption inbuild:package-jsontarget insideproject.jsonfiles.Testing Instructions (or ideally a Blueprint)
CI
🧪
test-built-npm-packages/commonjs-and-jest/tests/php-wasm.spec.ts🧪
test-built-npm-packages/es-modules-and-vitest/tests/php-wasm.spec.ts