@yao-pkg/pkg 6.13.1 → 6.14.0
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 +2 -2
- package/lib-es5/detector.js +0 -1
- package/lib-es5/esm-transformer.js +2 -5
- package/lib-es5/fabricator.js +0 -4
- package/lib-es5/follow.js +1 -1
- package/lib-es5/help.js +1 -2
- package/lib-es5/index.js +1 -5
- package/lib-es5/packer.js +0 -1
- package/lib-es5/resolver.js +1 -1
- package/lib-es5/walker.js +2 -4
- package/package.json +29 -18
- package/prelude/bootstrap.js +0 -6
- package/prelude/diagnostic.js +0 -2
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ After installing it, run `pkg --help` without arguments to see list of options:
|
|
|
53
53
|
– Makes executable for particular target machine
|
|
54
54
|
$ pkg -t node14-win-arm64 index.js
|
|
55
55
|
– Makes executables for target machines of your choice
|
|
56
|
-
$ pkg -t
|
|
56
|
+
$ pkg -t node20-linux,node22-linux,node22-win index.js
|
|
57
57
|
– Bakes '--expose-gc' and '--max-heap-size=34' into executable
|
|
58
58
|
$ pkg --options "expose-gc,max-heap-size=34" index.js
|
|
59
59
|
– Consider packageA and packageB to be public
|
|
@@ -82,7 +82,7 @@ The entrypoint of your project is a mandatory CLI argument. It may be:
|
|
|
82
82
|
`pkg` can generate executables for several target machines at a
|
|
83
83
|
time. You can specify a comma-separated list of targets via `--targets`
|
|
84
84
|
option. A canonical target consists of 3 elements, separated by
|
|
85
|
-
dashes, for example `
|
|
85
|
+
dashes, for example `node20-macos-x64` or `node22-linux-arm64`:
|
|
86
86
|
|
|
87
87
|
- **nodeRange** (node8), node10, node12, node14, node16 or latest
|
|
88
88
|
- **platform** alpine, linux, linuxstatic, win, macos, (freebsd)
|
package/lib-es5/detector.js
CHANGED
|
@@ -86,7 +86,6 @@ function reconstructSpecifiers(specs) {
|
|
|
86
86
|
return defaults.join(', ');
|
|
87
87
|
}
|
|
88
88
|
function reconstruct(node) {
|
|
89
|
-
// @ts-expect-error Type mismatch due to @babel/types version in @types/babel__generator
|
|
90
89
|
let v = (0, generator_1.default)(node, { comments: false }).code.replace(/\n/g, '');
|
|
91
90
|
let v2;
|
|
92
91
|
while (true) {
|
|
@@ -56,7 +56,6 @@ function hasImportMeta(code) {
|
|
|
56
56
|
return false;
|
|
57
57
|
}
|
|
58
58
|
let found = false;
|
|
59
|
-
// @ts-expect-error Type mismatch due to @babel/types version in @types/babel__traverse
|
|
60
59
|
(0, traverse_1.default)(ast, {
|
|
61
60
|
// Detect import.meta usage
|
|
62
61
|
MetaProperty(path) {
|
|
@@ -69,7 +68,7 @@ function hasImportMeta(code) {
|
|
|
69
68
|
});
|
|
70
69
|
return found;
|
|
71
70
|
}
|
|
72
|
-
catch (
|
|
71
|
+
catch (_error) {
|
|
73
72
|
// If we can't parse, assume no import.meta
|
|
74
73
|
return false;
|
|
75
74
|
}
|
|
@@ -96,7 +95,6 @@ function detectESMFeatures(code, filename) {
|
|
|
96
95
|
}
|
|
97
96
|
const topLevelAwait = [];
|
|
98
97
|
const unsupportedFeatures = [];
|
|
99
|
-
// @ts-expect-error Type mismatch due to @babel/types version in @types/babel__traverse
|
|
100
98
|
(0, traverse_1.default)(ast, {
|
|
101
99
|
// Detect top-level await - can be handled with async IIFE wrapper
|
|
102
100
|
AwaitExpression(path) {
|
|
@@ -259,7 +257,6 @@ function transformESMtoCJS(code, filename) {
|
|
|
259
257
|
let hasExports = false;
|
|
260
258
|
const codeLines = code.split('\n');
|
|
261
259
|
const importLineIndices = new Set();
|
|
262
|
-
// @ts-expect-error Type mismatch due to @babel/types version
|
|
263
260
|
(0, traverse_1.default)(ast, {
|
|
264
261
|
ExportNamedDeclaration() {
|
|
265
262
|
hasExports = true;
|
|
@@ -331,7 +328,7 @@ function transformESMtoCJS(code, filename) {
|
|
|
331
328
|
const esbuildOptions = {
|
|
332
329
|
loader: 'js',
|
|
333
330
|
format: 'cjs',
|
|
334
|
-
target: '
|
|
331
|
+
target: 'node20',
|
|
335
332
|
sourcemap: false,
|
|
336
333
|
minify: false,
|
|
337
334
|
keepNames: true,
|
package/lib-es5/fabricator.js
CHANGED
|
@@ -64,19 +64,16 @@ function fabricate(bakes, fabricator, snap, body, cb) {
|
|
|
64
64
|
}
|
|
65
65
|
let stdout = Buffer.alloc(0);
|
|
66
66
|
function onError(error) {
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
68
67
|
removeListeners();
|
|
69
68
|
kill();
|
|
70
69
|
cb(new Error(`Failed to make bytecode ${fabricator.nodeRange}-${fabricator.arch} for file ${snap} error (${error.message})`));
|
|
71
70
|
}
|
|
72
71
|
function onClose(code) {
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
74
72
|
removeListeners();
|
|
75
73
|
kill();
|
|
76
74
|
if (code !== 0) {
|
|
77
75
|
return cb(new Error(`Failed to make bytecode ${fabricator.nodeRange}-${fabricator.arch} for file ${snap}`));
|
|
78
76
|
}
|
|
79
|
-
// eslint-disable-next-line no-console
|
|
80
77
|
console.log(stdout.toString());
|
|
81
78
|
return cb(new Error(`${cmd} closed unexpectedly`));
|
|
82
79
|
}
|
|
@@ -87,7 +84,6 @@ function fabricate(bakes, fabricator, snap, body, cb) {
|
|
|
87
84
|
if (stdout.length >= 4 + sizeOfBlob) {
|
|
88
85
|
const blob = Buffer.alloc(sizeOfBlob);
|
|
89
86
|
stdout.copy(blob, 0, 4, 4 + sizeOfBlob);
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
91
87
|
removeListeners();
|
|
92
88
|
return cb(undefined, blob);
|
|
93
89
|
}
|
package/lib-es5/follow.js
CHANGED
|
@@ -114,7 +114,7 @@ function follow(x, opts) {
|
|
|
114
114
|
// CJS package - fall through to standard CommonJS resolution
|
|
115
115
|
// to handle all callbacks properly
|
|
116
116
|
}
|
|
117
|
-
catch (
|
|
117
|
+
catch (_error) {
|
|
118
118
|
// ESM resolution failed - fall through to standard CommonJS resolution
|
|
119
119
|
}
|
|
120
120
|
}
|
package/lib-es5/help.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const colors_1 = require("./colors");
|
|
4
4
|
function help() {
|
|
5
|
-
// eslint-disable-next-line no-console
|
|
6
5
|
console.log(`
|
|
7
6
|
${colors_1.pc.bold('pkg')} [options] <input>
|
|
8
7
|
|
|
@@ -34,7 +33,7 @@ function help() {
|
|
|
34
33
|
${colors_1.pc.gray('–')} Makes executable for particular target machine
|
|
35
34
|
${colors_1.pc.cyan('$ pkg -t node14-win-arm64 index.js')}
|
|
36
35
|
${colors_1.pc.gray('–')} Makes executables for target machines of your choice
|
|
37
|
-
${colors_1.pc.cyan('$ pkg -t
|
|
36
|
+
${colors_1.pc.cyan('$ pkg -t node22-linux,node24-linux,node24-win index.js')}
|
|
38
37
|
${colors_1.pc.gray('–')} Bakes '--expose-gc' and '--max-heap-size=34' into executable
|
|
39
38
|
${colors_1.pc.cyan('$ pkg --options "expose-gc,max-heap-size=34" index.js')}
|
|
40
39
|
${colors_1.pc.gray('–')} Consider packageA and packageB to be public
|
package/lib-es5/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable require-atomic-updates */
|
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
4
|
};
|
|
@@ -30,7 +29,6 @@ function isConfiguration(file) {
|
|
|
30
29
|
}
|
|
31
30
|
// http://www.openwall.com/lists/musl/2012/12/08/4
|
|
32
31
|
const { hostArch, hostPlatform, isValidNodeRange, knownArchs, knownPlatforms, toFancyArch, toFancyPlatform, } = pkg_fetch_1.system;
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
34
32
|
const hostNodeRange = `node${process.version.match(/^v(\d+)/)[1]}`;
|
|
35
33
|
function parseTargets(items) {
|
|
36
34
|
// [ 'node6-macos-x64', 'node6-linux-x64' ]
|
|
@@ -191,7 +189,6 @@ async function exec(argv2) {
|
|
|
191
189
|
}
|
|
192
190
|
// version
|
|
193
191
|
if (argv.v || argv.version) {
|
|
194
|
-
// eslint-disable-next-line no-console
|
|
195
192
|
console.log(version);
|
|
196
193
|
return;
|
|
197
194
|
}
|
|
@@ -218,7 +215,6 @@ async function exec(argv2) {
|
|
|
218
215
|
throw (0, log_1.wasReported)(`Invalid compression algorithm ${algo} ( should be None, Brotli or Gzip)`);
|
|
219
216
|
}
|
|
220
217
|
if (doCompress !== compress_type_1.CompressType.None) {
|
|
221
|
-
// eslint-disable-next-line no-console
|
|
222
218
|
console.log('compression: ', compress_type_1.CompressType[doCompress]);
|
|
223
219
|
}
|
|
224
220
|
// _
|
|
@@ -288,7 +284,7 @@ async function exec(argv2) {
|
|
|
288
284
|
if (!(0, fs_1.existsSync)(config)) {
|
|
289
285
|
throw (0, log_1.wasReported)('Config file does not exist', [config]);
|
|
290
286
|
}
|
|
291
|
-
// eslint-disable-next-line
|
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
292
288
|
configJson = require(config); // may be either json or js
|
|
293
289
|
if (!configJson.name &&
|
|
294
290
|
!configJson.files &&
|
package/lib-es5/packer.js
CHANGED
package/lib-es5/resolver.js
CHANGED
package/lib-es5/walker.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable require-atomic-updates */
|
|
3
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
3
|
if (k2 === undefined) k2 = k;
|
|
5
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -838,7 +837,7 @@ class Walker {
|
|
|
838
837
|
record.body = Buffer.from(JSON.stringify(pkgContent, null, 2), 'utf8');
|
|
839
838
|
}
|
|
840
839
|
}
|
|
841
|
-
catch (
|
|
840
|
+
catch (_error) {
|
|
842
841
|
// Ignore JSON parsing errors
|
|
843
842
|
}
|
|
844
843
|
}
|
|
@@ -931,7 +930,6 @@ class Walker {
|
|
|
931
930
|
switch (store) {
|
|
932
931
|
case common_1.STORE_BLOB:
|
|
933
932
|
case common_1.STORE_CONTENT:
|
|
934
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
935
933
|
await this.step_STORE_ANY(record, task.marker, store);
|
|
936
934
|
break;
|
|
937
935
|
case common_1.STORE_LINKS:
|
|
@@ -956,7 +954,7 @@ class Walker {
|
|
|
956
954
|
if (this.params.noDictionary?.includes(file)) {
|
|
957
955
|
continue;
|
|
958
956
|
}
|
|
959
|
-
// eslint-disable-next-line
|
|
957
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
960
958
|
const config = require(path_1.default.join(dd, file));
|
|
961
959
|
this.dictionary[name] = config;
|
|
962
960
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yao-pkg/pkg",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.0",
|
|
4
4
|
"description": "Package your Node.js project into an executable",
|
|
5
5
|
"main": "lib-es5/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@babel/parser": "^7.23.0",
|
|
27
27
|
"@babel/traverse": "^7.23.0",
|
|
28
28
|
"@babel/types": "^7.23.0",
|
|
29
|
-
"esbuild": "^0.24.0",
|
|
30
29
|
"@yao-pkg/pkg-fetch": "3.5.32",
|
|
31
|
-
"
|
|
30
|
+
"esbuild": "^0.27.3",
|
|
31
|
+
"into-stream": "^9.1.0",
|
|
32
32
|
"minimist": "^1.2.6",
|
|
33
33
|
"multistream": "^4.1.0",
|
|
34
34
|
"picocolors": "^1.1.0",
|
|
@@ -37,35 +37,36 @@
|
|
|
37
37
|
"resolve": "^1.22.10",
|
|
38
38
|
"resolve.exports": "^2.0.3",
|
|
39
39
|
"stream-meter": "^1.0.4",
|
|
40
|
-
"tar": "^7.5.
|
|
40
|
+
"tar": "^7.5.7",
|
|
41
41
|
"tinyglobby": "^0.2.11",
|
|
42
42
|
"unzipper": "^0.12.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@release-it/conventional-changelog": "^
|
|
45
|
+
"@release-it/conventional-changelog": "^10.0.5",
|
|
46
46
|
"@types/babel__generator": "^7.6.5",
|
|
47
47
|
"@types/babel__traverse": "^7.20.3",
|
|
48
48
|
"@types/minimist": "^1.2.2",
|
|
49
49
|
"@types/multistream": "^4.1.0",
|
|
50
|
-
"@types/node": "^
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
51
|
"@types/picomatch": "^3.0.1",
|
|
52
52
|
"@types/resolve": "^1.20.2",
|
|
53
53
|
"@types/stream-meter": "^0.0.22",
|
|
54
54
|
"@types/tar": "^6.1.13",
|
|
55
55
|
"@types/unzipper": "^0.10.10",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
57
|
-
"@typescript-eslint/parser": "^
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
58
58
|
"esbuild-register": "^3.6.0",
|
|
59
|
-
"eslint": "^
|
|
59
|
+
"eslint": "^9.0.0",
|
|
60
60
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
61
|
-
"eslint-config-airbnb-typescript": "^
|
|
62
|
-
"eslint-config-prettier": "^
|
|
63
|
-
"eslint-plugin-import": "^2.
|
|
61
|
+
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
62
|
+
"eslint-config-prettier": "^10.0.0",
|
|
63
|
+
"eslint-plugin-import": "^2.31.0",
|
|
64
|
+
"globals": "^17.3.0",
|
|
64
65
|
"json-stable-stringify": "^1.0.1",
|
|
65
|
-
"lint-staged": "^15.
|
|
66
|
+
"lint-staged": "^15.0.0",
|
|
66
67
|
"prettier": "^3.0.3",
|
|
67
|
-
"release-it": "^
|
|
68
|
-
"rimraf": "^
|
|
68
|
+
"release-it": "^19.2.4",
|
|
69
|
+
"rimraf": "^6.1.2",
|
|
69
70
|
"simple-git-hooks": "^2.11.1",
|
|
70
71
|
"typescript": "^4.7.2"
|
|
71
72
|
},
|
|
@@ -79,9 +80,10 @@
|
|
|
79
80
|
"fix": "npm run lint:style -- -w && npm run lint:code -- --fix",
|
|
80
81
|
"prepare": "npm run build",
|
|
81
82
|
"prepublishOnly": "npm run lint",
|
|
82
|
-
"test": "npm run build && npm run test:host && npm run test:
|
|
83
|
+
"test": "npm run build && npm run test:host && npm run test:20 && npm run test:22 && npm run test:24",
|
|
83
84
|
"test:20": "node test/test.js node20 no-npm",
|
|
84
|
-
"test:
|
|
85
|
+
"test:22": "node test/test.js node22 no-npm",
|
|
86
|
+
"test:24": "node test/test.js node24 no-npm",
|
|
85
87
|
"test:host": "node test/test.js host only-npm",
|
|
86
88
|
"bump:fetch": "yarn add @yao-pkg/pkg-fetch --exact",
|
|
87
89
|
"release": "read -p 'GITHUB_TOKEN: ' GITHUB_TOKEN && export GITHUB_TOKEN=$GITHUB_TOKEN && release-it"
|
|
@@ -97,6 +99,15 @@
|
|
|
97
99
|
},
|
|
98
100
|
"packageManager": "yarn@1.22.22",
|
|
99
101
|
"engines": {
|
|
100
|
-
"node": ">=
|
|
102
|
+
"node": ">=20.0.0"
|
|
103
|
+
},
|
|
104
|
+
"resolutions": {
|
|
105
|
+
"lodash": "^4.17.23",
|
|
106
|
+
"@octokit/request-error": "^5.1.1",
|
|
107
|
+
"@octokit/plugin-paginate-rest": "^9.2.2",
|
|
108
|
+
"@octokit/request": "^8.4.1",
|
|
109
|
+
"js-yaml": "^4.1.1",
|
|
110
|
+
"brace-expansion": "^2.0.2",
|
|
111
|
+
"tmp": "^0.2.4"
|
|
101
112
|
}
|
|
102
113
|
}
|
package/prelude/bootstrap.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-unresolved */
|
|
2
|
-
/* eslint-disable global-require */
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
/* eslint-disable prefer-rest-params */
|
|
5
|
-
/* eslint-disable prefer-spread */
|
|
6
|
-
|
|
7
1
|
/* global EXECPATH_FD */
|
|
8
2
|
/* global PAYLOAD_POSITION */
|
|
9
3
|
/* global PAYLOAD_SIZE */
|