Files
next.js/rspack/crates/binding/index.js
Arian Tron 61f56f997c
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
first commit
2026-03-10 19:37:31 +03:30

478 lines
14 KiB
JavaScript

// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
const { createRequire } = require('node:module')
require = createRequire(__filename)
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process')
.execSync('ldd --version', { encoding: 'utf8' })
.includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./binding.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-android-arm64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./binding.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-android-arm-eabi')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on Android ${process.arch}`)
)
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
try {
return require('./binding.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-win32-x64-msvc')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'ia32') {
try {
return require('./binding.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-win32-ia32-msvc')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./binding.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-win32-arm64-msvc')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on Windows: ${process.arch}`)
)
}
} else if (process.platform === 'darwin') {
try {
return require('./binding.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-darwin-universal')
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./binding.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-darwin-x64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./binding.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-darwin-arm64')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on macOS: ${process.arch}`)
)
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./binding.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-freebsd-x64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./binding.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-freebsd-arm64')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)
)
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./binding.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-x64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./binding.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-x64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./binding.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./binding.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./binding.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm-musleabihf')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./binding.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm-gnueabihf')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./binding.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-riscv64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./binding.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-riscv64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./binding.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-ppc64-gnu')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./binding.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-s390x-gnu')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on Linux: ${process.arch}`)
)
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./binding.linux-arm64-ohos.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm64-ohos')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./binding.linux-x64-ohos.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-x64-ohos')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./binding.linux-arm-ohos.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@next/rspack-binding-linux-arm-ohos')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(
new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`)
)
}
} else {
loadErrors.push(
new Error(
`Unsupported OS: ${process.platform}, architecture: ${process.arch}`
)
)
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
nativeBinding = require('./binding.wasi.cjs')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
if (!nativeBinding) {
try {
nativeBinding = require('@next/rspack-binding-wasm32-wasi')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{ cause: loadErrors }
)
}
throw new Error(`Failed to load native binding`)
}
module.exports = nativeBinding
module.exports.registerNextExternalsPlugin =
nativeBinding.registerNextExternalsPlugin
module.exports.Assets = nativeBinding.Assets
module.exports.AsyncDependenciesBlock = nativeBinding.AsyncDependenciesBlock
module.exports.Chunk = nativeBinding.Chunk
module.exports.ChunkGraph = nativeBinding.ChunkGraph
module.exports.ChunkGroup = nativeBinding.ChunkGroup
module.exports.Chunks = nativeBinding.Chunks
module.exports.CodeGenerationResult = nativeBinding.CodeGenerationResult
module.exports.CodeGenerationResults = nativeBinding.CodeGenerationResults
module.exports.ConcatenatedModule = nativeBinding.ConcatenatedModule
module.exports.ContextModule = nativeBinding.ContextModule
module.exports.Dependency = nativeBinding.Dependency
module.exports.Diagnostics = nativeBinding.Diagnostics
module.exports.EntryDataDto = nativeBinding.EntryDataDto
module.exports.EntryDataDTO = nativeBinding.EntryDataDTO
module.exports.EntryDependency = nativeBinding.EntryDependency
module.exports.EntryOptionsDto = nativeBinding.EntryOptionsDto
module.exports.EntryOptionsDTO = nativeBinding.EntryOptionsDTO
module.exports.ExternalModule = nativeBinding.ExternalModule
module.exports.JsCompilation = nativeBinding.JsCompilation
module.exports.JsCompiler = nativeBinding.JsCompiler
module.exports.JsContextModuleFactoryAfterResolveData =
nativeBinding.JsContextModuleFactoryAfterResolveData
module.exports.JsContextModuleFactoryBeforeResolveData =
nativeBinding.JsContextModuleFactoryBeforeResolveData
module.exports.JsDependencies = nativeBinding.JsDependencies
module.exports.JsEntries = nativeBinding.JsEntries
module.exports.JsExportsInfo = nativeBinding.JsExportsInfo
module.exports.JsModuleGraph = nativeBinding.JsModuleGraph
module.exports.JsResolver = nativeBinding.JsResolver
module.exports.JsResolverFactory = nativeBinding.JsResolverFactory
module.exports.JsStats = nativeBinding.JsStats
module.exports.KnownBuildInfo = nativeBinding.KnownBuildInfo
module.exports.Module = nativeBinding.Module
module.exports.ModuleGraphConnection = nativeBinding.ModuleGraphConnection
module.exports.NativeWatcher = nativeBinding.NativeWatcher
module.exports.NativeWatchResult = nativeBinding.NativeWatchResult
module.exports.NormalModule = nativeBinding.NormalModule
module.exports.RawExternalItemFnCtx = nativeBinding.RawExternalItemFnCtx
module.exports.ReadonlyResourceData = nativeBinding.ReadonlyResourceData
module.exports.ResolverFactory = nativeBinding.ResolverFactory
module.exports.Sources = nativeBinding.Sources
module.exports.VirtualFileStore = nativeBinding.VirtualFileStore
module.exports.JsVirtualFileStore = nativeBinding.JsVirtualFileStore
module.exports.async = nativeBinding.async
module.exports.BuiltinPluginName = nativeBinding.BuiltinPluginName
module.exports.cleanupGlobalTrace = nativeBinding.cleanupGlobalTrace
module.exports.EnforceExtension = nativeBinding.EnforceExtension
module.exports.EXPECTED_RSPACK_CORE_VERSION =
nativeBinding.EXPECTED_RSPACK_CORE_VERSION
module.exports.formatDiagnostic = nativeBinding.formatDiagnostic
module.exports.JsLoaderState = nativeBinding.JsLoaderState
module.exports.JsRspackSeverity = nativeBinding.JsRspackSeverity
module.exports.loadBrowserslist = nativeBinding.loadBrowserslist
module.exports.minify = nativeBinding.minify
module.exports.minifySync = nativeBinding.minifySync
module.exports.RawRuleSetConditionType = nativeBinding.RawRuleSetConditionType
module.exports.registerGlobalTrace = nativeBinding.registerGlobalTrace
module.exports.RegisterJsTapKind = nativeBinding.RegisterJsTapKind
module.exports.sync = nativeBinding.sync
module.exports.syncTraceEvent = nativeBinding.syncTraceEvent
module.exports.transform = nativeBinding.transform
module.exports.transformSync = nativeBinding.transformSync