@parcel/hash
Advanced tools
Comparing version 2.8.4-nightly.2872 to 2.8.4-nightly.2875
263
index.js
@@ -1,22 +0,253 @@ | ||
let parts = [process.platform, process.arch]; | ||
if (process.platform === 'linux') { | ||
const {MUSL, family} = require('detect-libc'); | ||
if (family === MUSL) { | ||
parts.push('musl'); | ||
} else if (process.arch === 'arm') { | ||
parts.push('gnueabihf'); | ||
const { existsSync, readFileSync } = require('fs') | ||
const { join } = require('path') | ||
const { platform, arch } = process | ||
let nativeBinding = null | ||
let localFileExisted = false | ||
let loadError = null | ||
function isMusl() { | ||
// For Node 10 | ||
if (!process.report || typeof process.report.getReport !== 'function') { | ||
try { | ||
const lddPath = require('child_process').execSync('which ldd').toString().trim(); | ||
return readFileSync(lddPath, 'utf8').includes('musl') | ||
} catch (e) { | ||
return true | ||
} | ||
} else { | ||
parts.push('gnu'); | ||
const { glibcVersionRuntime } = process.report.getReport().header | ||
return !glibcVersionRuntime | ||
} | ||
} else if (process.platform === 'win32') { | ||
parts.push('msvc'); | ||
} | ||
let name = `./parcel-hash.${parts.join('-')}.node`; | ||
if (process.env.PARCEL_BUILD_ENV === 'production') { | ||
module.exports = require(name); | ||
} else if (require('fs').existsSync(require('path').join(__dirname, name))) { | ||
module.exports = require(name); | ||
switch (platform) { | ||
case 'android': | ||
switch (arch) { | ||
case 'arm64': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.android-arm64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.android-arm64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-android-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.android-arm-eabi.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.android-arm-eabi.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-android-arm-eabi') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Android ${arch}`) | ||
} | ||
break | ||
case 'win32': | ||
switch (arch) { | ||
case 'x64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-x64-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-x64-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-x64-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'ia32': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-ia32-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-ia32-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-ia32-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.win32-arm64-msvc.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.win32-arm64-msvc.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-win32-arm64-msvc') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Windows: ${arch}`) | ||
} | ||
break | ||
case 'darwin': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.darwin-universal.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-universal.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-universal') | ||
} | ||
break | ||
} catch {} | ||
switch (arch) { | ||
case 'x64': | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.darwin-x64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-x64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-x64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'arm64': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.darwin-arm64.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.darwin-arm64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-darwin-arm64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on macOS: ${arch}`) | ||
} | ||
break | ||
case 'freebsd': | ||
if (arch !== 'x64') { | ||
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) | ||
} | ||
localFileExisted = existsSync(join(__dirname, 'parcel-hash.freebsd-x64.node')) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.freebsd-x64.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-freebsd-x64') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
case 'linux': | ||
switch (arch) { | ||
case 'x64': | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-x64-musl.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-x64-musl.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-x64-musl') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-x64-gnu.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-x64-gnu.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-x64-gnu') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} | ||
break | ||
case 'arm64': | ||
if (isMusl()) { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm64-musl.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm64-musl.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm64-musl') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} else { | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm64-gnu.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm64-gnu.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm64-gnu') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
} | ||
break | ||
case 'arm': | ||
localFileExisted = existsSync( | ||
join(__dirname, 'parcel-hash.linux-arm-gnueabihf.node') | ||
) | ||
try { | ||
if (localFileExisted) { | ||
nativeBinding = require('./parcel-hash.linux-arm-gnueabihf.node') | ||
} else { | ||
nativeBinding = require('@parcel/hash-linux-arm-gnueabihf') | ||
} | ||
} catch (e) { | ||
loadError = e | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported architecture on Linux: ${arch}`) | ||
} | ||
break | ||
default: | ||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`) | ||
} | ||
module.exports.init = Promise.resolve(); | ||
if (!nativeBinding) { | ||
if (loadError) { | ||
throw loadError | ||
} | ||
throw new Error(`Failed to load native binding`) | ||
} | ||
const { hashString, hashBuffer, Hash } = nativeBinding | ||
module.exports.hashString = hashString | ||
module.exports.hashBuffer = hashBuffer | ||
module.exports.Hash = Hash |
{ | ||
"name": "@parcel/hash", | ||
"version": "2.8.4-nightly.2872+9d1933b3d", | ||
"version": "2.8.4-nightly.2875+307268c07", | ||
"license": "MIT", | ||
@@ -35,10 +35,9 @@ "main": "index.js", | ||
"dependencies": { | ||
"detect-libc": "^1.0.3", | ||
"xxhash-wasm": "^0.4.2" | ||
}, | ||
"devDependencies": { | ||
"@napi-rs/cli": "^2.6.2", | ||
"@napi-rs/cli": "^2.14.8", | ||
"tiny-benchy": "^1.0.2" | ||
}, | ||
"gitHead": "9d1933b3d89a3f57f3ac1c70f4fb755738d78604" | ||
"gitHead": "307268c07570ce142ad4becaabc3548849e147ea" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3080446
1
297
1
3
- Removeddetect-libc@^1.0.3
- Removeddetect-libc@1.0.3(transitive)