@yao-pkg/pkg 5.12.0 → 5.12.1
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/lib-es5/producer.js +19 -2
- package/lib-es5/walker.js +13 -2
- package/package.json +3 -4
package/lib-es5/producer.js
CHANGED
|
@@ -105,10 +105,27 @@ function findPackageJson(nodeFile) {
|
|
|
105
105
|
}
|
|
106
106
|
return dir;
|
|
107
107
|
}
|
|
108
|
+
function getPrebuildEnvPrefix(pkgName) {
|
|
109
|
+
return `npm_config_${(pkgName || '')
|
|
110
|
+
.replace(/[^a-zA-Z0-9]/g, '_')
|
|
111
|
+
.replace(/^_/, '')}`;
|
|
112
|
+
}
|
|
108
113
|
function nativePrebuildInstall(target, nodeFile) {
|
|
109
114
|
var _a, _b;
|
|
110
115
|
const prebuildInstall = path_1.default.join(__dirname, '../node_modules/.bin/prebuild-install');
|
|
111
116
|
const dir = findPackageJson(nodeFile);
|
|
117
|
+
const packageJson = JSON.parse(fs_extra_1.default.readFileSync(path_1.default.join(dir, 'package.json'), { encoding: 'utf-8' }));
|
|
118
|
+
// only try prebuild-install for packages that actually use it or if
|
|
119
|
+
// explicitly configured via environment variables
|
|
120
|
+
const envPrefix = getPrebuildEnvPrefix(packageJson.name);
|
|
121
|
+
if (((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['prebuild-install']) == null &&
|
|
122
|
+
![
|
|
123
|
+
`${envPrefix}_binary_host`,
|
|
124
|
+
`${envPrefix}_binary_host_mirror`,
|
|
125
|
+
`${envPrefix}_local_prebuilds`,
|
|
126
|
+
].some((i) => i in process.env)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
112
129
|
// parse the target node version from the binaryPath
|
|
113
130
|
const nodeVersion = path_1.default.basename(target.binaryPath).split('-')[1];
|
|
114
131
|
if (!/^v[0-9]+\.[0-9]+\.[0-9]+$/.test(nodeVersion)) {
|
|
@@ -122,7 +139,7 @@ function nativePrebuildInstall(target, nodeFile) {
|
|
|
122
139
|
if (!fs_extra_1.default.existsSync(`${nodeFile}.bak`)) {
|
|
123
140
|
fs_extra_1.default.copyFileSync(nodeFile, `${nodeFile}.bak`);
|
|
124
141
|
}
|
|
125
|
-
const napiVersions = (_b =
|
|
142
|
+
const napiVersions = (_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.binary) === null || _b === void 0 ? void 0 : _b.napi_versions;
|
|
126
143
|
const options = [
|
|
127
144
|
'--platform',
|
|
128
145
|
types_1.platform[target.platform],
|
|
@@ -289,7 +306,7 @@ function producer({ backpack, bakes, slash, target, symLinks, doCompress, native
|
|
|
289
306
|
if ((0, common_1.isDotNODE)(stripe.file) && nativeBuild) {
|
|
290
307
|
try {
|
|
291
308
|
const platformFile = nativePrebuildInstall(target, stripe.file);
|
|
292
|
-
if (fs_extra_1.default.existsSync(platformFile)) {
|
|
309
|
+
if (platformFile && fs_extra_1.default.existsSync(platformFile)) {
|
|
293
310
|
return cb(null, pipeMayCompressToNewMeter(fs_extra_1.default.createReadStream(platformFile)));
|
|
294
311
|
}
|
|
295
312
|
}
|
package/lib-es5/walker.js
CHANGED
|
@@ -29,11 +29,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const assert_1 = __importDefault(require("assert"));
|
|
31
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
|
-
const is_core_module_1 = __importDefault(require("is-core-module"));
|
|
33
32
|
const globby_1 = __importDefault(require("globby"));
|
|
34
33
|
const path_1 = __importDefault(require("path"));
|
|
35
34
|
const chalk_1 = __importDefault(require("chalk"));
|
|
36
35
|
const minimatch_1 = require("minimatch");
|
|
36
|
+
const module_1 = require("module");
|
|
37
37
|
const common_1 = require("./common");
|
|
38
38
|
const follow_1 = require("./follow");
|
|
39
39
|
const log_1 = require("./log");
|
|
@@ -48,6 +48,17 @@ const options_1 = __importDefault(require("./options"));
|
|
|
48
48
|
// performance hit.
|
|
49
49
|
const strictVerify = Boolean(process.env.PKG_STRICT_VER);
|
|
50
50
|
const win32 = process.platform === 'win32';
|
|
51
|
+
/**
|
|
52
|
+
* Checks if a module is a core module
|
|
53
|
+
* module.isBuiltin is available in Node.js 16.17.0 or later. Once we drop support for older
|
|
54
|
+
* versions of Node.js, we can use module.isBuiltin instead of this function.
|
|
55
|
+
*/
|
|
56
|
+
function isBuiltin(moduleName) {
|
|
57
|
+
const moduleNameWithoutPrefix = moduleName.startsWith('node:')
|
|
58
|
+
? moduleName.slice(5)
|
|
59
|
+
: moduleName;
|
|
60
|
+
return module_1.builtinModules.includes(moduleNameWithoutPrefix);
|
|
61
|
+
}
|
|
51
62
|
function unlikelyJavascript(file) {
|
|
52
63
|
return ['.css', '.html', '.json', '.vue'].includes(path_1.default.extname(file));
|
|
53
64
|
}
|
|
@@ -666,7 +677,7 @@ class Walker {
|
|
|
666
677
|
async stepDerivatives(record, marker, derivatives) {
|
|
667
678
|
for (const derivative of derivatives) {
|
|
668
679
|
// TODO: actually use the target node version
|
|
669
|
-
if ((
|
|
680
|
+
if (isBuiltin(derivative.alias))
|
|
670
681
|
continue;
|
|
671
682
|
switch (derivative.aliasType) {
|
|
672
683
|
case common_1.ALIAS_AS_RELATIVE:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yao-pkg/pkg",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.1",
|
|
4
4
|
"description": "Package your Node.js project into an executable",
|
|
5
5
|
"main": "lib-es5/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"fs-extra": "^9.1.0",
|
|
31
31
|
"globby": "^11.1.0",
|
|
32
32
|
"into-stream": "^6.0.0",
|
|
33
|
-
"is-core-module": "2.9.0",
|
|
34
33
|
"minimatch": "9.0.4",
|
|
35
34
|
"minimist": "^1.2.6",
|
|
36
35
|
"multistream": "^4.1.0",
|
|
@@ -43,7 +42,6 @@
|
|
|
43
42
|
"@release-it/conventional-changelog": "7.0.2",
|
|
44
43
|
"@types/babel__generator": "7.6.5",
|
|
45
44
|
"@types/fs-extra": "9.0.13",
|
|
46
|
-
"@types/is-core-module": "2.2.0",
|
|
47
45
|
"@types/minimatch": "^5.1.2",
|
|
48
46
|
"@types/minimist": "1.2.2",
|
|
49
47
|
"@types/multistream": "4.1.0",
|
|
@@ -141,5 +139,6 @@
|
|
|
141
139
|
},
|
|
142
140
|
"publishConfig": {
|
|
143
141
|
"access": "public"
|
|
144
|
-
}
|
|
142
|
+
},
|
|
143
|
+
"packageManager": "yarn@1.22.22"
|
|
145
144
|
}
|