npm-pkgbuild 18.2.22 → 18.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/package.json +2 -2
- package/src/content/node-modules-content-provider.mjs +12 -13
- package/src/npm-shrink.mjs +20 -5
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/npm-pkgbuild)
|
|
2
2
|
[](https://spdx.org/licenses/0BSD.html)
|
|
3
3
|
[](https://typescriptlang.org)
|
|
4
|
-
[](https://packagephobia.now.sh/result?p=npm-pkgbuild@18.2.18)
|
|
5
4
|
[](https://bundlejs.com/?q=npm-pkgbuild)
|
|
6
5
|
[](https://npmjs.org/package/npm-pkgbuild)
|
|
7
6
|
[](https://github.com/arlac77/npm-pkgbuild/issues)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-pkgbuild",
|
|
3
|
-
"version": "18.2.
|
|
3
|
+
"version": "18.2.24",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": false
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"uti": "^8.9.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@types/node": "^24.
|
|
76
|
+
"@types/node": "^24.3.0",
|
|
77
77
|
"ava": "^6.4.1",
|
|
78
78
|
"c8": "^10.1.3",
|
|
79
79
|
"documentation": "^14.0.3",
|
|
@@ -109,15 +109,24 @@ export class NodeModulesContentProvider extends ContentProvider {
|
|
|
109
109
|
|
|
110
110
|
for await (const entry of glob("**/*", {
|
|
111
111
|
cwd: nodeModulesDir,
|
|
112
|
-
withFileTypes: true
|
|
113
|
-
exclude: entry =>
|
|
112
|
+
withFileTypes: true
|
|
113
|
+
/*exclude: entry =>
|
|
114
114
|
toBeSkipped.test(entry.name) ||
|
|
115
115
|
/@types|tslib|node-addon-api|node-gyp/.test(
|
|
116
116
|
entry.parentPath.substring(startPos)
|
|
117
117
|
)
|
|
118
|
+
*/
|
|
118
119
|
})) {
|
|
120
|
+
if (toBeSkipped.test(entry.name)) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
|
|
119
124
|
const name = join(entry.parentPath, entry.name).substring(startPos);
|
|
120
125
|
|
|
126
|
+
if (/@types|tslib|node-addon-api|node-gyp/.test(name)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
|
|
121
130
|
if (entry.isFile()) {
|
|
122
131
|
if (entry.name === "package.json") {
|
|
123
132
|
try {
|
|
@@ -213,21 +222,11 @@ const toBeSkipped = new RegExp(
|
|
|
213
222
|
"Copyrightnotice\\.txt",
|
|
214
223
|
"Doxyfile",
|
|
215
224
|
"Dockerfile",
|
|
216
|
-
"CODE_OF_CONDUCT(\\.md|\\.txt)?",
|
|
217
|
-
"GOVERNANCE(\\.md)?",
|
|
218
|
-
"CODEOWNERS(\\.md)?",
|
|
219
225
|
"UPGRAD(E|ING)(\\.md)?",
|
|
220
|
-
"AUTHORS(\\.md|\\.txt)?",
|
|
221
226
|
"OWNERS",
|
|
222
227
|
"CONTRIBUT(ORS|ING)(\\.md)?",
|
|
223
|
-
"CHANGELOG(\\.md)?",
|
|
224
|
-
"CHANGES(\\.md)?",
|
|
225
|
-
"HISTORY(\\.md)?",
|
|
226
|
-
"ROADMAP(\\.md)?",
|
|
227
|
-
"DOCUMENTATION(\\.md)?",
|
|
228
228
|
"LICEN[SC]E(\\-\\w+)?(\\.txt|\\.md|\\.BSD|\\.APACHE2|\\.MIT|\\.terms)?",
|
|
229
|
-
"README(.*\\.md|\\.txt)?",
|
|
230
|
-
"INSTALL(.*\\.md)?",
|
|
229
|
+
"(CODE_OF_CONDUCT|GOVERNANCE|CODEOWNERS|AUTHORS|DOCUMENTATION|CHANGES|CHANGELOG|HISTORY|ROADMAP|README|INSTALL)(.*\\.md|\\.txt)?",
|
|
231
230
|
"\\.armv6\\.node",
|
|
232
231
|
"\\.py",
|
|
233
232
|
"\\.el",
|
package/src/npm-shrink.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const nameAndVersion = ["name", "version"];
|
|
2
2
|
|
|
3
|
-
export function shrinkNPM(
|
|
3
|
+
export function shrinkNPM(
|
|
4
|
+
pkg,
|
|
5
|
+
options = { removeKeys: nameAndVersion, removeDefaults: false }
|
|
6
|
+
) {
|
|
4
7
|
const toBeRemoved = [
|
|
5
8
|
"dependencies",
|
|
6
9
|
"sideEffects",
|
|
@@ -103,9 +106,7 @@ export function shrinkNPM(pkg, options = { removeKeys: nameAndVersion, removeDef
|
|
|
103
106
|
"testling"
|
|
104
107
|
];
|
|
105
108
|
|
|
106
|
-
toBeRemoved.map(key =>
|
|
107
|
-
delete pkg[key];
|
|
108
|
-
});
|
|
109
|
+
toBeRemoved.map(key => delete pkg[key]);
|
|
109
110
|
|
|
110
111
|
if (options?.removeKeys) {
|
|
111
112
|
options.removeKeys.map(key => {
|
|
@@ -113,7 +114,7 @@ export function shrinkNPM(pkg, options = { removeKeys: nameAndVersion, removeDef
|
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
if(options.removeDefaults) {
|
|
117
|
+
if (options.removeDefaults) {
|
|
117
118
|
switch (pkg.main) {
|
|
118
119
|
case "index":
|
|
119
120
|
case "./index":
|
|
@@ -124,6 +125,8 @@ export function shrinkNPM(pkg, options = { removeKeys: nameAndVersion, removeDef
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
|
|
128
|
+
deleteKey(pkg.exports, "types");
|
|
129
|
+
|
|
127
130
|
for (const key of Object.keys(pkg)) {
|
|
128
131
|
if (key[0] === "_") {
|
|
129
132
|
delete pkg[key];
|
|
@@ -132,3 +135,15 @@ export function shrinkNPM(pkg, options = { removeKeys: nameAndVersion, removeDef
|
|
|
132
135
|
|
|
133
136
|
return Object.keys(pkg).length === 0 ? undefined : pkg;
|
|
134
137
|
}
|
|
138
|
+
|
|
139
|
+
function deleteKey(object, key) {
|
|
140
|
+
if (object) {
|
|
141
|
+
delete object[key];
|
|
142
|
+
|
|
143
|
+
for (const value of Object.values(object)) {
|
|
144
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
145
|
+
deleteKey(value, key);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|