🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

rolldown

Package Overview
Dependencies
Maintainers
4
Versions
632
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rolldown - npm Package Compare versions

Comparing version
1.1.5
to
1.2.0
dist/shared/binding-Dbbi0RbO.d.mts

Sorry, the diff of this file is too big to display

+588
import { createRequire } from "node:module";
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
//#endregion
//#region src/webcontainer-fallback.cjs
var require_webcontainer_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const fs = __require("node:fs");
const childProcess = __require("node:child_process");
const version = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8")).version;
const baseDir = `/tmp/rolldown-${version}`;
const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
if (!fs.existsSync(bindingEntry)) {
const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
fs.rmSync(baseDir, {
recursive: true,
force: true
});
fs.mkdirSync(baseDir, { recursive: true });
console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
childProcess.execFileSync("pnpm", ["i", bindingPkg], {
cwd: baseDir,
stdio: "inherit"
});
}
module.exports = __require(bindingEntry);
}));
//#endregion
//#region src/binding.cjs
var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const { readFileSync } = __require("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 (process.report && 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) {
return false;
}
};
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
return __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("./rolldown-binding.android-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-android-arm64");
const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return __require("./rolldown-binding.android-arm-eabi.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-android-arm-eabi");
const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
else if (process.platform === "win32") if (process.arch === "x64") if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
try {
return __require("./rolldown-binding.win32-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-x64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.win32-x64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-x64-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ia32") {
try {
return __require("./rolldown-binding.win32-ia32-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-ia32-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.win32-arm64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-arm64-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
else if (process.platform === "darwin") {
try {
return __require("./rolldown-binding.darwin-universal.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-universal");
const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
if (process.arch === "x64") {
try {
return __require("./rolldown-binding.darwin-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-x64");
const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.darwin-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-arm64");
const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
} else if (process.platform === "freebsd") if (process.arch === "x64") {
try {
return __require("./rolldown-binding.freebsd-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-freebsd-x64");
const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.freebsd-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-freebsd-arm64");
const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-x64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-x64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("../rolldown-binding.linux-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-x64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-arm64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-arm64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-arm-musleabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm-musleabihf");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-arm-gnueabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "loong64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-loong64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-loong64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-loong64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-loong64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "riscv64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-riscv64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-riscv64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-riscv64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-riscv64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ppc64") {
try {
return __require("./rolldown-binding.linux-ppc64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-ppc64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "s390x") {
try {
return __require("./rolldown-binding.linux-s390x-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-s390x-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
else if (process.platform === "openharmony") if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.openharmony-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-arm64");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "x64") {
try {
return __require("./rolldown-binding.openharmony-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-x64");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return __require("./rolldown-binding.openharmony-arm.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-arm");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
if (bindingPackageVersion !== "1.2.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
}
nativeBinding = requireNative();
const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || process.env.NAPI_RS_FORCE_WASI === "error";
if (!nativeBinding || forceWasi) {
let wasiBinding = null;
let wasiBindingError = null;
try {
wasiBinding = __require("../rolldown-binding.wasi.cjs");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) wasiBindingError = err;
}
if (!nativeBinding || forceWasi) try {
wasiBinding = __require("@rolldown/binding-wasm32-wasi");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) {
if (!wasiBindingError) wasiBindingError = err;
else wasiBindingError.cause = err;
loadErrors.push(err);
}
}
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
error.cause = wasiBindingError;
throw error;
}
}
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
nativeBinding = require_webcontainer_fallback();
} catch (err) {
loadErrors.push(err);
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
const error = /* @__PURE__ */ 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.");
error.cause = loadErrors.reduce((err, cur) => {
cur.cause = err;
return cur;
});
throw error;
}
throw new Error(`Failed to load native binding`);
}
module.exports = nativeBinding;
module.exports.LegalCommentsMode = nativeBinding.LegalCommentsMode;
module.exports.minify = nativeBinding.minify;
module.exports.minifySync = nativeBinding.minifySync;
module.exports.Severity = nativeBinding.Severity;
module.exports.ParseResult = nativeBinding.ParseResult;
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
module.exports.ImportNameKind = nativeBinding.ImportNameKind;
module.exports.parse = nativeBinding.parse;
module.exports.parseSync = nativeBinding.parseSync;
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
module.exports.ResolverFactory = nativeBinding.ResolverFactory;
module.exports.EnforceExtension = nativeBinding.EnforceExtension;
module.exports.ModuleType = nativeBinding.ModuleType;
module.exports.sync = nativeBinding.sync;
module.exports.HelperMode = nativeBinding.HelperMode;
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
module.exports.isolatedDeclarationSync = nativeBinding.isolatedDeclarationSync;
module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
module.exports.moduleRunnerTransformSync = nativeBinding.moduleRunnerTransformSync;
module.exports.transform = nativeBinding.transform;
module.exports.transformSync = nativeBinding.transformSync;
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
module.exports.BindingBundler = nativeBinding.BindingBundler;
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
module.exports.BindingChunkingContext = nativeBinding.BindingChunkingContext;
module.exports.BindingDecodedMap = nativeBinding.BindingDecodedMap;
module.exports.BindingDevEngine = nativeBinding.BindingDevEngine;
module.exports.BindingLoadPluginContext = nativeBinding.BindingLoadPluginContext;
module.exports.BindingMagicString = nativeBinding.BindingMagicString;
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
module.exports.BindingSourceMap = nativeBinding.BindingSourceMap;
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
module.exports.BindingWatcherBundler = nativeBinding.BindingWatcherBundler;
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
module.exports.TraceSubscriberGuard = nativeBinding.TraceSubscriberGuard;
module.exports.TsconfigCache = nativeBinding.TsconfigCache;
module.exports.BindingAttachDebugInfo = nativeBinding.BindingAttachDebugInfo;
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
module.exports.BindingChunkModuleOrderBy = nativeBinding.BindingChunkModuleOrderBy;
module.exports.BindingErrorStage = nativeBinding.BindingErrorStage;
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
module.exports.BindingPropertyReadSideEffects = nativeBinding.BindingPropertyReadSideEffects;
module.exports.BindingPropertyWriteSideEffects = nativeBinding.BindingPropertyWriteSideEffects;
module.exports.BindingRebuildStrategy = nativeBinding.BindingRebuildStrategy;
module.exports.collapseSourcemaps = nativeBinding.collapseSourcemaps;
module.exports.enhancedTransform = nativeBinding.enhancedTransform;
module.exports.enhancedTransformSync = nativeBinding.enhancedTransformSync;
module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
module.exports.initTraceSubscriber = nativeBinding.initTraceSubscriber;
module.exports.registerPlugins = nativeBinding.registerPlugins;
module.exports.resolveTsconfig = nativeBinding.resolveTsconfig;
module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
}));
//#endregion
export { __toESM as n, require_binding as t };

Sorry, the diff of this file is too big to display

import { C as BindingViteJsonPluginConfig, D as BindingViteReporterPluginConfig, E as BindingViteReactRefreshWrapperPluginConfig, O as BindingViteResolvePluginConfig, S as BindingViteImportGlobPluginConfig, T as BindingViteModulePreloadPolyfillPluginConfig, b as BindingViteBuildImportAnalysisPluginConfig, l as BindingIsolatedDeclarationPluginConfig, s as BindingEsmExternalRequirePluginConfig, x as BindingViteDynamicImportVarsPluginConfig } from "./binding-Dbbi0RbO.mjs";
import { F as BuiltinPlugin, Wt as StringOrRegExp } from "./define-config-B-IDOhDz.mjs";
//#region src/builtin-plugin/constructors.d.ts
declare function viteModulePreloadPolyfillPlugin(config?: BindingViteModulePreloadPolyfillPluginConfig): BuiltinPlugin;
type DynamicImportVarsPluginConfig = Omit<BindingViteDynamicImportVarsPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
declare function viteDynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
declare function viteImportGlobPlugin(config?: BindingViteImportGlobPluginConfig): BuiltinPlugin;
declare function viteReporterPlugin(config: BindingViteReporterPluginConfig): BuiltinPlugin;
declare function viteLoadFallbackPlugin(): BuiltinPlugin;
declare function viteJsonPlugin(config: BindingViteJsonPluginConfig): BuiltinPlugin;
declare function viteBuildImportAnalysisPlugin(config: BindingViteBuildImportAnalysisPluginConfig): BuiltinPlugin;
declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, "yarnPnp">): BuiltinPlugin;
declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
declare function viteWebWorkerPostPlugin(): BuiltinPlugin;
/**
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
*
* @see https://rolldown.rs/builtin-plugins/esm-external-require
* @category Builtin Plugins
*/
declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
type ViteReactRefreshWrapperPluginConfig = Omit<BindingViteReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
/**
* This plugin should not be used for Rolldown.
*/
declare function oxcRuntimePlugin(): BuiltinPlugin;
declare function viteReactRefreshWrapperPlugin(config: ViteReactRefreshWrapperPluginConfig): BuiltinPlugin;
//#endregion
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWebWorkerPostPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-SiXbePVH.mjs";
//#region src/builtin-plugin/constructors.ts
function viteModulePreloadPolyfillPlugin(config) {
return new BuiltinPlugin("builtin:vite-module-preload-polyfill", config);
}
function viteDynamicImportVarsPlugin(config) {
if (config) {
config.include = normalizedStringOrRegex(config.include);
config.exclude = normalizedStringOrRegex(config.exclude);
}
return new BuiltinPlugin("builtin:vite-dynamic-import-vars", config);
}
function viteImportGlobPlugin(config) {
return new BuiltinPlugin("builtin:vite-import-glob", config);
}
function viteReporterPlugin(config) {
return new BuiltinPlugin("builtin:vite-reporter", config);
}
function viteLoadFallbackPlugin() {
return new BuiltinPlugin("builtin:vite-load-fallback");
}
function viteJsonPlugin(config) {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-json", config));
}
function viteBuildImportAnalysisPlugin(config) {
return new BuiltinPlugin("builtin:vite-build-import-analysis", config);
}
function viteResolvePlugin(config) {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", {
...config,
yarnPnp: typeof process === "object" && !!process.versions?.pnp
}));
}
function isolatedDeclarationPlugin(config) {
return new BuiltinPlugin("builtin:isolated-declaration", config);
}
function viteWebWorkerPostPlugin() {
return new BuiltinPlugin("builtin:vite-web-worker-post");
}
/**
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
*
* @see https://rolldown.rs/builtin-plugins/esm-external-require
* @category Builtin Plugins
*/
function esmExternalRequirePlugin(config) {
const plugin = new BuiltinPlugin("builtin:esm-external-require", config);
plugin.enforce = "pre";
return plugin;
}
/**
* This plugin should not be used for Rolldown.
*/
function oxcRuntimePlugin() {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:oxc-runtime"));
}
function viteReactRefreshWrapperPlugin(config) {
if (config) {
config.include = normalizedStringOrRegex(config.include);
config.exclude = normalizedStringOrRegex(config.exclude);
}
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-react-refresh-wrapper", config));
}
//#endregion
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWebWorkerPostPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };

Sorry, the diff of this file is too big to display

import { t as require_binding } from "./binding-Dby9rwGk.mjs";
//#region src/types/sourcemap.ts
function bindingifySourcemap(map) {
if (map == null) return;
return { inner: typeof map === "string" ? map : {
file: map.file ?? void 0,
mappings: map.mappings,
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
sources: map.sources?.map((s) => s ?? void 0),
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
names: map.names,
x_google_ignoreList: map.x_google_ignoreList,
debugId: "debugId" in map ? map.debugId : void 0
} };
}
require_binding();
function unwrapBindingResult(container) {
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
return container;
}
function normalizeBindingResult(container) {
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
return container;
}
function normalizeBindingError(e) {
return e.type === "JsError" ? e.field0 : Object.assign(/* @__PURE__ */ new Error(), {
code: e.field0.kind,
kind: e.field0.kind,
message: e.field0.message,
id: e.field0.id,
exporter: e.field0.exporter,
loc: e.field0.loc,
pos: e.field0.pos,
stack: void 0
});
}
function aggregateBindingErrorsIntoJsError(rawErrors) {
const errors = rawErrors.map(normalizeBindingError);
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
for (let i = 0; i < errors.length; i++) {
summary += "\n";
if (i >= 5) {
summary += "...";
break;
}
summary += getErrorMessage(errors[i]);
}
const wrapper = new Error(summary);
Object.defineProperty(wrapper, "errors", {
configurable: true,
enumerable: true,
get: () => errors,
set: (value) => Object.defineProperty(wrapper, "errors", {
configurable: true,
enumerable: true,
value
})
});
return wrapper;
}
function getErrorMessage(e) {
if (Object.hasOwn(e, "kind")) return e.message;
let s = "";
if (e.plugin) s += `[plugin ${e.plugin}]`;
const id = e.id ?? e.loc?.file;
if (id) {
s += " " + id;
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
}
if (s) s += "\n";
const message = `${e.name ?? "Error"}: ${e.message}`;
s += message;
if (e.frame) s = joinNewLine(s, e.frame);
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
if (e.cause) {
s = joinNewLine(s, "Caused by:");
s = joinNewLine(s, getErrorMessage(e.cause).split("\n").map((line) => " " + line).join("\n"));
}
return s;
}
function joinNewLine(s1, s2) {
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
}
//#endregion
export { bindingifySourcemap as a, unwrapBindingResult as i, normalizeBindingError as n, normalizeBindingResult as r, aggregateBindingErrorsIntoJsError as t };
import { a as RolldownLog } from "./logging-xuHO4mAy.mjs";
//#region src/get-log-filter.d.ts
/**
* @param filters A list of log filters to apply
* @returns A function that tests whether a log should be output
*
* @category Config
*/
type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
/**
* A helper function to generate log filters using the same syntax as the CLI.
*
* @example
* ```ts
* import { defineConfig } from 'rolldown';
* import { getLogFilter } from 'rolldown/getLogFilter';
*
* const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
*
* export default defineConfig({
* input: 'main.js',
* onLog(level, log, handler) {
* if (logFilter(log)) {
* handler(level, log);
* }
* }
* });
* ```
*
* @category Config
*/
declare const getLogFilter: GetLogFilter;
//#endregion
export { getLogFilter as n, GetLogFilter as t };
import { t as rolldown } from "./rolldown-951h_1lf.mjs";
import fs from "node:fs";
import path from "node:path";
import { readdir } from "node:fs/promises";
import { cwd } from "node:process";
import { pathToFileURL } from "node:url";
//#region src/utils/load-config.ts
async function bundleTsConfig(configFile, isEsm) {
const dirnameVarName = "injected_original_dirname";
const filenameVarName = "injected_original_filename";
const importMetaUrlVarName = "injected_original_import_meta_url";
const bundle = await rolldown({
input: configFile,
platform: "node",
resolve: { mainFields: ["main"] },
transform: { define: {
__dirname: dirnameVarName,
__filename: filenameVarName,
"import.meta.url": importMetaUrlVarName,
"import.meta.dirname": dirnameVarName,
"import.meta.filename": filenameVarName
} },
treeshake: false,
external: [/^[\w@][^:]/],
plugins: [{
name: "inject-file-scope-variables",
transform: {
filter: { id: /\.[cm]?[jt]s$/ },
async handler(code, id) {
return {
code: `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};` + code,
map: null
};
}
}
}]
});
const outputDir = path.dirname(configFile);
const fileName = (await bundle.write({
dir: outputDir,
format: isEsm ? "esm" : "cjs",
sourcemap: "inline",
entryFileNames: `rolldown.config.[hash]${path.extname(configFile).replace("ts", "js")}`
})).output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
return path.join(outputDir, fileName);
}
const SUPPORTED_JS_CONFIG_FORMATS = [
".js",
".mjs",
".cjs"
];
const SUPPORTED_TS_CONFIG_FORMATS = [
".ts",
".mts",
".cts"
];
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
const DEFAULT_CONFIG_BASE = "rolldown.config";
async function findConfigFileNameInCwd() {
const filesInWorkingDirectory = new Set(await readdir(cwd()));
for (const extension of SUPPORTED_CONFIG_FORMATS) {
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
if (filesInWorkingDirectory.has(fileName)) return fileName;
}
throw new Error("No `rolldown.config` configuration file found.");
}
async function loadTsConfig(configFile) {
const file = await bundleTsConfig(configFile, isFilePathESM(configFile));
try {
return (await import(pathToFileURL(file).href)).default;
} finally {
fs.unlink(file, () => {});
}
}
function isFilePathESM(filePath) {
if (/\.m[jt]s$/.test(filePath)) return true;
else if (/\.c[jt]s$/.test(filePath)) return false;
else {
const pkg = findNearestPackageData(path.dirname(filePath));
if (pkg) return pkg.type === "module";
return false;
}
}
function findNearestPackageData(basedir) {
while (basedir) {
const pkgPath = path.join(basedir, "package.json");
if (tryStatSync(pkgPath)?.isFile()) try {
return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
} catch {}
const nextBasedir = path.dirname(basedir);
if (nextBasedir === basedir) break;
basedir = nextBasedir;
}
return null;
}
function tryStatSync(file) {
try {
return fs.statSync(file, { throwIfNoEntry: false });
} catch {}
}
async function loadNativeConfig(resolvedPath) {
const url = pathToFileURL(resolvedPath).href;
const { freshImport } = await import("./dist-DKbukT1H.mjs");
const freshImported = freshImport(url);
if (freshImported) {
const { result } = await freshImported;
return result.default;
}
return (await import(url + "?t=" + Date.now())).default;
}
/**
* Load config from a file in a way that Rolldown does.
*
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
* @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
* @returns The loaded config export
*
* @category Config
*/
async function loadConfig(configPath, options = {}) {
const configLoader = options.configLoader ?? "bundle";
const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
try {
if (configLoader === "native") return await loadNativeConfig(path.resolve(configPath));
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(path.resolve(configPath));
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
} catch (err) {
if (configLoader === "native") {
const tsHint = SUPPORTED_TS_CONFIG_FORMATS.includes(ext) && !process.features.typescript ? " This runtime does not natively support TypeScript config files." : "";
throw new Error(`Failed to load the config file "${configPath}" using the "native" config loader.${tsHint} Try "--configLoader bundle", or register a loader such as "--import tsx".`, { cause: err });
}
throw new Error("Error happened while loading config.", { cause: err });
}
}
//#endregion
export { loadConfig as t };
//#region src/log/logging.d.ts
/** @inline */
type LogLevel = "info" | "debug" | "warn";
/** @inline */
type LogLevelOption = LogLevel | "silent";
/** @inline */
type LogLevelWithError = LogLevel | "error";
interface RolldownLog {
binding?: string;
cause?: unknown;
/**
* The log code for this log object.
* @example 'PLUGIN_ERROR'
*/
code?: string;
exporter?: string;
frame?: string;
hook?: string;
id?: string;
ids?: string[];
loc?: {
column: number;
file?: string;
line: number;
};
/**
* The message for this log object.
* @example 'The "transform" hook used by the output plugin "rolldown-plugin-foo" is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.'
*/
message: string;
meta?: any;
names?: string[];
plugin?: string;
pluginCode?: unknown;
pos?: number;
reexporter?: string;
stack?: string;
url?: string;
}
/** @inline */
type RolldownLogWithString = RolldownLog | string;
/** @category Plugin APIs */
interface RolldownError extends RolldownLog {
name?: string;
stack?: string;
watchFiles?: string[];
}
type LogOrStringHandler = (level: LogLevelWithError, log: RolldownLogWithString) => void;
//#endregion
export { RolldownLog as a, RolldownError as i, LogLevelOption as n, RolldownLogWithString as o, LogOrStringHandler as r, LogLevel as t };
import { n as __toESM, t as require_binding } from "./binding-Dby9rwGk.mjs";
import { c as logPluginError, n as error } from "./logs-ZGEh6uhb.mjs";
//#region src/builtin-plugin/utils.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
var BuiltinPlugin = class {
name;
_options;
/** Vite-specific option to control plugin ordering */
enforce;
constructor(name, _options) {
this.name = name;
this._options = _options;
}
};
function makeBuiltinPluginCallable(plugin) {
let callablePlugin = new import_binding.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
const wrappedPlugin = plugin;
for (const key in callablePlugin) {
const wrappedHook = async function(...args) {
try {
return await callablePlugin[key](...args);
} catch (e) {
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
return error(logPluginError(e, plugin.name, {
hook: key,
id: key === "transform" ? args[2] : void 0
}));
}
};
const order = callablePlugin.getOrder(key);
if (order == void 0) wrappedPlugin[key] = wrappedHook;
else wrappedPlugin[key] = {
handler: wrappedHook,
order
};
}
return wrappedPlugin;
}
function bindingifyBuiltInPlugin(plugin) {
return {
__name: plugin.name,
options: plugin._options
};
}
function bindingifyManifestPlugin(plugin, pluginContextData) {
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
return {
__name: plugin.name,
options: {
...options,
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
} : void 0
}
};
}
//#endregion
//#region src/utils/normalize-string-or-regex.ts
function normalizedStringOrRegex(pattern) {
if (!pattern) return;
if (!isReadonlyArray(pattern)) return [pattern];
return pattern;
}
function isReadonlyArray(input) {
return Array.isArray(input);
}
//#endregion
export { makeBuiltinPluginCallable as a, bindingifyManifestPlugin as i, BuiltinPlugin as n, bindingifyBuiltInPlugin as r, normalizedStringOrRegex as t };
import { n as __toESM, t as require_binding } from "./binding-Dby9rwGk.mjs";
//#region ../../node_modules/.pnpm/oxc-parser@0.140.0/node_modules/oxc-parser/src-js/wrap.js
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
function wrap(result) {
let program, module, comments, errors;
return {
get program() {
if (!program) program = jsonParseAst(result.program);
return program;
},
get module() {
if (!module) module = result.module;
return module;
},
get comments() {
if (!comments) comments = result.comments;
return comments;
},
get errors() {
if (!errors) errors = result.errors;
return errors;
}
};
}
function jsonParseAst(programJson) {
const { node: program, fixes } = JSON.parse(programJson);
for (const fixPath of fixes) applyFix(program, fixPath);
return program;
}
function applyFix(program, fixPath) {
let node = program;
for (const key of fixPath) node = node[key];
if (node.bigint) node.value = BigInt(node.bigint);
else try {
node.value = RegExp(node.regex.pattern, node.regex.flags);
} catch {}
}
//#endregion
//#region src/utils/parse.ts
/**
* Parse JS/TS source asynchronously on a separate thread.
*
* Note that not all of the workload can happen on a separate thread.
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
* has to happen on current thread. This synchronous deserialization work typically outweighs
* the asynchronous parsing by a factor of between 3 and 20.
*
* i.e. the majority of the workload cannot be parallelized by using this method.
*
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
*
* @category Utilities
*/
async function parse(filename, sourceText, options) {
return wrap(await (0, import_binding.parse)(filename, sourceText, options));
}
/**
* Parse JS/TS source synchronously on current thread.
*
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
* (see {@linkcode parse} documentation for details).
*
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
* with {@linkcode parseSync} rather than using {@linkcode parse}.
*
* @category Utilities
*/
function parseSync(filename, sourceText, options) {
return wrap((0, import_binding.parseSync)(filename, sourceText, options));
}
//#endregion
export { parseSync as n, parse as t };
import { n as __toESM, t as require_binding } from "./binding-Dby9rwGk.mjs";
import { a as bindingifySourcemap, n as normalizeBindingError } from "./error-DFGNOCle.mjs";
//#region src/utils/minify.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
/**
* Minify asynchronously.
*
* Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
*
* @category Utilities
* @experimental
*/
async function minify(filename, sourceText, options) {
const inputMap = bindingifySourcemap(options?.inputMap);
const result = await (0, import_binding.minify)(filename, sourceText, options);
if (result.map && inputMap) result.map = {
version: 3,
...(0, import_binding.collapseSourcemaps)([inputMap, bindingifySourcemap(result.map)])
};
return result;
}
/**
* Minify synchronously.
*
* @category Utilities
* @experimental
*/
function minifySync(filename, sourceText, options) {
const inputMap = bindingifySourcemap(options?.inputMap);
const result = (0, import_binding.minifySync)(filename, sourceText, options);
if (result.map && inputMap) result.map = {
version: 3,
...(0, import_binding.collapseSourcemaps)([inputMap, bindingifySourcemap(result.map)])
};
return result;
}
//#endregion
//#region src/utils/transform.ts
const yarnPnp$1 = typeof process === "object" && !!process.versions?.pnp;
function normalizeBindingWarning(warning) {
if (warning.type === "JsError") return warning.field0;
return {
code: warning.field0.kind,
message: warning.field0.message,
id: warning.field0.id,
exporter: warning.field0.exporter,
loc: warning.field0.loc,
pos: warning.field0.pos
};
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
*
* Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns a promise that resolves to an object containing the transformed code,
* source maps, and any errors that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
async function transform(filename, sourceText, options, cache) {
const result = await (0, import_binding.enhancedTransform)(filename, sourceText, options, cache, yarnPnp$1);
return {
...result,
errors: result.errors.map(normalizeBindingError),
warnings: result.warnings.map(normalizeBindingWarning)
};
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns an object containing the transformed code, source maps, and any errors
* that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
function transformSync(filename, sourceText, options, cache) {
const result = (0, import_binding.enhancedTransformSync)(filename, sourceText, options, cache, yarnPnp$1);
return {
...result,
errors: result.errors.map(normalizeBindingError),
warnings: result.warnings.map(normalizeBindingWarning)
};
}
//#endregion
//#region src/utils/resolve-tsconfig.ts
const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
/**
* Cache for tsconfig resolution to avoid redundant file system operations.
*
* The cache stores resolved tsconfig configurations keyed by their file paths.
* When transforming multiple files in the same project, tsconfig lookups are
* deduplicated, improving performance.
*
* @category Utilities
* @experimental
*/
var TsconfigCache = class extends import_binding.TsconfigCache {
constructor() {
super(yarnPnp);
}
};
/** @hidden This is only expected to be used by Vite */
function resolveTsconfig(filename, cache) {
return (0, import_binding.resolveTsconfig)(filename, cache, yarnPnp);
}
//#endregion
export { minify as a, transformSync as i, resolveTsconfig as n, minifySync as o, transform as r, TsconfigCache as t };
import { c as validateOption, t as RolldownBuild, u as PluginDriver } from "./rolldown-build-CdF8HAHX.mjs";
//#region src/api/rolldown/index.ts
/**
* The API compatible with Rollup's `rollup` function.
*
* Unlike Rollup, the module graph is not built until the methods of the bundle object are called.
*
* @param input The input options object.
* @returns A Promise that resolves to a bundle object.
*
* @example
* ```js
* import { rolldown } from 'rolldown';
*
* let bundle, failed = false;
* try {
* bundle = await rolldown({
* input: 'src/main.js',
* });
* await bundle.write({
* format: 'esm',
* });
* } catch (e) {
* console.error(e);
* failed = true;
* }
* if (bundle) {
* await bundle.close();
* }
* process.exitCode = failed ? 1 : 0;
* ```
*
* @category Programmatic APIs
*/
const rolldown = async (input) => {
validateOption("input", input);
return new RolldownBuild(await PluginDriver.callOptionsHook(input));
};
//#endregion
export { rolldown as t };

Sorry, the diff of this file is too big to display

import { a as RolldownLog } from "./logging-xuHO4mAy.mjs";
import { F as MinifyOptions$1, G as TsconfigCache$1, I as MinifyResult$1, R as ParseResult$1, U as SourceMap, a as BindingEnhancedTransformOptions, o as BindingEnhancedTransformResult, y as BindingTsconfigResult, z as ParserOptions$1 } from "./binding-Dbbi0RbO.mjs";
//#region src/utils/resolve-tsconfig.d.ts
/**
* Cache for tsconfig resolution to avoid redundant file system operations.
*
* The cache stores resolved tsconfig configurations keyed by their file paths.
* When transforming multiple files in the same project, tsconfig lookups are
* deduplicated, improving performance.
*
* @category Utilities
* @experimental
*/
declare class TsconfigCache extends TsconfigCache$1 {
constructor();
}
/** @hidden This is only expected to be used by Vite */
declare function resolveTsconfig(filename: string, cache?: TsconfigCache | null): BindingTsconfigResult | null;
//#endregion
//#region src/utils/parse.d.ts
/**
* Result of parsing a code
*
* @category Utilities
*/
interface ParseResult extends ParseResult$1 {}
/**
* Options for parsing a code
*
* @category Utilities
*/
interface ParserOptions extends ParserOptions$1 {}
/**
* Parse JS/TS source asynchronously on a separate thread.
*
* Note that not all of the workload can happen on a separate thread.
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
* has to happen on current thread. This synchronous deserialization work typically outweighs
* the asynchronous parsing by a factor of between 3 and 20.
*
* i.e. the majority of the workload cannot be parallelized by using this method.
*
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
*
* @category Utilities
*/
declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
/**
* Parse JS/TS source synchronously on current thread.
*
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
* (see {@linkcode parse} documentation for details).
*
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
* with {@linkcode parseSync} rather than using {@linkcode parse}.
*
* @category Utilities
*/
declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
//#endregion
//#region src/utils/minify.d.ts
/**
* Options for minification.
*
* @category Utilities
*/
interface MinifyOptions extends MinifyOptions$1 {
inputMap?: SourceMap;
}
/**
* The result of minification.
*
* @category Utilities
*/
interface MinifyResult extends MinifyResult$1 {}
/**
* Minify asynchronously.
*
* Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
*
* @category Utilities
* @experimental
*/
declare function minify(filename: string, sourceText: string, options?: MinifyOptions | null): Promise<MinifyResult>;
/**
* Minify synchronously.
*
* @category Utilities
* @experimental
*/
declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | null): MinifyResult;
//#endregion
//#region src/utils/transform.d.ts
/**
* Options for transforming a code.
*
* @category Utilities
*/
interface TransformOptions extends BindingEnhancedTransformOptions {}
/**
* Result of transforming a code.
*
* @category Utilities
*/
type TransformResult = Omit<BindingEnhancedTransformResult, "errors" | "warnings"> & {
errors: Error[];
warnings: RolldownLog[];
};
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
*
* Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns a promise that resolves to an object containing the transformed code,
* source maps, and any errors that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
declare function transform(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): Promise<TransformResult>;
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns an object containing the transformed code, source maps, and any errors
* that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): TransformResult;
//#endregion
export { MinifyOptions as a, minifySync as c, parse as d, parseSync as f, transformSync as i, ParseResult as l, resolveTsconfig as m, TransformResult as n, MinifyResult as o, TsconfigCache as p, transform as r, minify as s, TransformOptions as t, ParserOptions as u };
import { n as __toESM, t as require_binding } from "./binding-Dby9rwGk.mjs";
import { o as logMultipleWatcherOption } from "./logs-ZGEh6uhb.mjs";
import { v as LOG_LEVEL_WARN } from "./bindingify-input-options-_ppP73I9.mjs";
import { t as arraify } from "./misc-CoQm4NHO.mjs";
import { n as createBundlerOptions, u as PluginDriver } from "./rolldown-build-CdF8HAHX.mjs";
import { t as aggregateBindingErrorsIntoJsError } from "./error-DFGNOCle.mjs";
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
/**
* This is not the set of all possible signals.
*
* It IS, however, the set of all signals that trigger
* an exit on either Linux or BSD systems. Linux is a
* superset of the signal names supported on BSD, and
* the unknown signals just fail to register, so we can
* catch that easily enough.
*
* Windows signals are a different set, since there are
* signals that terminate Windows processes, but don't
* terminate (or don't even exist) on Posix systems.
*
* Don't bother with SIGKILL. It's uncatchable, which
* means that we can't fire any callbacks anyway.
*
* If a user does happen to register a handler on a non-
* fatal signal like SIGWINCH or something, and then
* exit, it'll end up firing `process.emit('exit')`, so
* the handler will be fired anyway.
*
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
* artificially, inherently leave the process in a
* state from which it is not safe to try and enter JS
* listeners.
*/
const signals = [];
signals.push("SIGHUP", "SIGINT", "SIGTERM");
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
//#endregion
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
const kExitEmitter = Symbol.for("signal-exit emitter");
const global = globalThis;
const ObjectDefineProperty = Object.defineProperty.bind(Object);
var Emitter = class {
emitted = {
afterExit: false,
exit: false
};
listeners = {
afterExit: [],
exit: []
};
count = 0;
id = Math.random();
constructor() {
if (global[kExitEmitter]) return global[kExitEmitter];
ObjectDefineProperty(global, kExitEmitter, {
value: this,
writable: false,
enumerable: false,
configurable: false
});
}
on(ev, fn) {
this.listeners[ev].push(fn);
}
removeListener(ev, fn) {
const list = this.listeners[ev];
const i = list.indexOf(fn);
/* c8 ignore start */
if (i === -1) return;
/* c8 ignore stop */
if (i === 0 && list.length === 1) list.length = 0;
else list.splice(i, 1);
}
emit(ev, code, signal) {
if (this.emitted[ev]) return false;
this.emitted[ev] = true;
let ret = false;
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
return ret;
}
};
var SignalExitBase = class {};
const signalExitWrap = (handler) => {
return {
onExit(cb, opts) {
return handler.onExit(cb, opts);
},
load() {
return handler.load();
},
unload() {
return handler.unload();
}
};
};
var SignalExitFallback = class extends SignalExitBase {
onExit() {
return () => {};
}
load() {}
unload() {}
};
var SignalExit = class extends SignalExitBase {
/* c8 ignore start */
#hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
/* c8 ignore stop */
#emitter = new Emitter();
#process;
#originalProcessEmit;
#originalProcessReallyExit;
#sigListeners = {};
#loaded = false;
constructor(process) {
super();
this.#process = process;
this.#sigListeners = {};
for (const sig of signals) this.#sigListeners[sig] = () => {
const listeners = this.#process.listeners(sig);
let { count } = this.#emitter;
/* c8 ignore start */
const p = process;
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
/* c8 ignore stop */
if (listeners.length === count) {
this.unload();
const ret = this.#emitter.emit("exit", null, sig);
/* c8 ignore start */
const s = sig === "SIGHUP" ? this.#hupSig : sig;
if (!ret) process.kill(process.pid, s);
}
};
this.#originalProcessReallyExit = process.reallyExit;
this.#originalProcessEmit = process.emit;
}
onExit(cb, opts) {
/* c8 ignore start */
if (!processOk(this.#process)) return () => {};
/* c8 ignore stop */
if (this.#loaded === false) this.load();
const ev = opts?.alwaysLast ? "afterExit" : "exit";
this.#emitter.on(ev, cb);
return () => {
this.#emitter.removeListener(ev, cb);
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
};
}
load() {
if (this.#loaded) return;
this.#loaded = true;
this.#emitter.count += 1;
for (const sig of signals) try {
const fn = this.#sigListeners[sig];
if (fn) this.#process.on(sig, fn);
} catch (_) {}
this.#process.emit = (ev, ...a) => {
return this.#processEmit(ev, ...a);
};
this.#process.reallyExit = (code) => {
return this.#processReallyExit(code);
};
}
unload() {
if (!this.#loaded) return;
this.#loaded = false;
signals.forEach((sig) => {
const listener = this.#sigListeners[sig];
/* c8 ignore start */
if (!listener) throw new Error("Listener not defined for signal: " + sig);
/* c8 ignore stop */
try {
this.#process.removeListener(sig, listener);
} catch (_) {}
/* c8 ignore stop */
});
this.#process.emit = this.#originalProcessEmit;
this.#process.reallyExit = this.#originalProcessReallyExit;
this.#emitter.count -= 1;
}
#processReallyExit(code) {
/* c8 ignore start */
if (!processOk(this.#process)) return 0;
this.#process.exitCode = code || 0;
/* c8 ignore stop */
this.#emitter.emit("exit", this.#process.exitCode, null);
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
}
#processEmit(ev, ...args) {
const og = this.#originalProcessEmit;
if (ev === "exit" && processOk(this.#process)) {
if (typeof args[0] === "number") this.#process.exitCode = args[0];
/* c8 ignore start */
const ret = og.call(this.#process, ev, ...args);
/* c8 ignore start */
this.#emitter.emit("exit", this.#process.exitCode, null);
/* c8 ignore stop */
return ret;
} else return og.call(this.#process, ev, ...args);
}
};
const process$1 = globalThis.process;
const { onExit: onExit$1, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
//#endregion
//#region src/utils/signal-exit.ts
function onExit(...args) {
if (typeof process === "object" && process.versions.webcontainer) {
process.on("exit", (code) => {
args[0](code, null);
});
return;
}
onExit$1(...args);
}
//#endregion
//#region src/api/watch/watch-emitter.ts
var WatcherEmitter = class {
listeners = /* @__PURE__ */ new Map();
on(event, listener) {
const listeners = this.listeners.get(event);
if (listeners) listeners.push(listener);
else this.listeners.set(event, [listener]);
return this;
}
off(event, listener) {
const listeners = this.listeners.get(event);
if (listeners) {
const index = listeners.indexOf(listener);
if (index !== -1) listeners.splice(index, 1);
}
return this;
}
clear(event) {
this.listeners.delete(event);
}
/** Async emit — sequential dispatch so side effects from earlier handlers
* (e.g. `event.result.close()` triggering `closeBundle`) are visible to later handlers. */
async emit(event, ...args) {
const handlers = this.listeners.get(event);
if (handlers?.length) for (const h of handlers) await h(...args);
}
async close() {}
};
//#endregion
//#region src/api/watch/watcher.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
function createEventCallback(emitter) {
return async (event) => {
switch (event.eventKind()) {
case "event": {
const code = event.bundleEventKind();
if (code === "BUNDLE_END") {
const { duration, output, result } = event.bundleEndData();
await emitter.emit("event", {
code: "BUNDLE_END",
duration,
output: [output],
result
});
} else if (code === "ERROR") {
const data = event.bundleErrorData();
await emitter.emit("event", {
code: "ERROR",
error: aggregateBindingErrorsIntoJsError(data.error),
result: data.result
});
} else await emitter.emit("event", { code });
break;
}
case "change": {
const { path, kind } = event.watchChangeData();
await emitter.emit("change", path, { event: kind });
break;
}
case "restart":
await emitter.emit("restart");
break;
case "close":
await emitter.emit("close");
break;
}
};
}
var Watcher = class {
closed;
inner;
emitter;
stopWorkers;
constructor(emitter, inner, stopWorkers) {
this.closed = false;
this.inner = inner;
this.emitter = emitter;
const originClose = emitter.close.bind(emitter);
emitter.close = async () => {
await this.close();
originClose();
};
this.stopWorkers = stopWorkers;
process.nextTick(() => this.run());
}
async close() {
if (this.closed) return;
this.closed = true;
for (const stop of this.stopWorkers) await stop?.();
await this.inner.close();
(0, import_binding.shutdownAsyncRuntime)();
}
async run() {
await this.inner.run();
this.inner.waitForClose();
}
};
async function createWatcher(emitter, input) {
const options = arraify(input);
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
})).flat());
warnMultiplePollingOptions(bundlerOptions);
const callback = createEventCallback(emitter);
new Watcher(emitter, new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), callback), bundlerOptions.map((option) => option.stopWorkers));
}
function warnMultiplePollingOptions(bundlerOptions) {
let found = false;
for (const option of bundlerOptions) {
const watch = option.inputOptions.watch;
const watcher = watch && typeof watch === "object" ? watch.watcher ?? watch.notify : void 0;
if (watcher && (watcher.usePolling != null || watcher.pollInterval != null)) {
if (found) {
option.onLog(LOG_LEVEL_WARN, logMultipleWatcherOption());
return;
}
found = true;
}
}
}
//#endregion
//#region src/api/watch/index.ts
/**
* The API compatible with Rollup's `watch` function.
*
* This function will rebuild the bundle when it detects that the individual modules have changed on disk.
*
* Note that when using this function, it is your responsibility to call `event.result.close()` in response to the `BUNDLE_END` event to avoid resource leaks.
*
* @param input The watch options object or the list of them.
* @returns A watcher object.
*
* @example
* ```js
* import { watch } from 'rolldown';
*
* const watcher = watch({ /* ... *\/ });
* watcher.on('event', (event) => {
* if (event.code === 'BUNDLE_END') {
* console.log(event.duration);
* event.result.close();
* }
* });
*
* // Stop watching
* watcher.close();
* ```
*
* @experimental
* @category Programmatic APIs
*/
function watch(input) {
const emitter = new WatcherEmitter();
createWatcher(emitter, input);
return emitter;
}
//#endregion
export { onExit as n, watch as t };
+6
-6

@@ -1,7 +0,7 @@

import { n as onExit, t as watch } from "./shared/watch-B1b0gmVh.mjs";
import { S as version, x as description } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
import { n as onExit, t as watch } from "./shared/watch-WnrlHRS0.mjs";
import { S as version, x as description } from "./shared/bindingify-input-options-_ppP73I9.mjs";
import { t as arraify } from "./shared/misc-CoQm4NHO.mjs";
import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CtPvmZgJ.mjs";
import { t as rolldown } from "./shared/rolldown-ChpIlMRm.mjs";
import { t as loadConfig } from "./shared/load-config-BL_FI6dc.mjs";
import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CdF8HAHX.mjs";
import { t as rolldown } from "./shared/rolldown-951h_1lf.mjs";
import { t as loadConfig } from "./shared/load-config-C6UyiS41.mjs";
import path from "node:path";

@@ -865,3 +865,3 @@ import g$1 from "node:process";

//#endregion
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/usingCtx.js
//#region \0@oxc-project+runtime@0.140.0/helpers/esm/usingCtx.js
function _usingCtx() {

@@ -868,0 +868,0 @@ var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {

@@ -1,3 +0,2 @@

import { L as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-BhJ90aEv.mjs";
import { L as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-B-IDOhDz.mjs";
//#region src/utils/load-config.d.ts

@@ -7,22 +6,22 @@ type ConfigLoader = "bundle" | "native";

/**
* How to load the config file.
* - `'bundle'` (default): bundle the config with Rolldown, then import it.
* - `'native'`: import the config directly, delegating TypeScript/loader
* handling to the runtime. Faster, but requires runtime support.
*
* @default 'bundle'
*/
* How to load the config file.
* - `'bundle'` (default): bundle the config with Rolldown, then import it.
* - `'native'`: import the config directly, delegating TypeScript/loader
* handling to the runtime. Faster, but requires runtime support.
*
* @default 'bundle'
*/
configLoader?: ConfigLoader;
}
/**
* Load config from a file in a way that Rolldown does.
*
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
* @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
* @returns The loaded config export
*
* @category Config
*/
* Load config from a file in a way that Rolldown does.
*
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
* @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
* @returns The loaded config export
*
* @category Config
*/
declare function loadConfig(configPath: string, options?: LoadConfigOptions): Promise<ConfigExport>;
//#endregion
export { VERSION, defineConfig, loadConfig };

@@ -1,4 +0,4 @@

import { b as VERSION } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
import { b as VERSION } from "./shared/bindingify-input-options-_ppP73I9.mjs";
import { t as defineConfig } from "./shared/define-config-Demdg3_4.mjs";
import { t as loadConfig } from "./shared/load-config-BL_FI6dc.mjs";
import { t as loadConfig } from "./shared/load-config-C6UyiS41.mjs";
export { VERSION, defineConfig, loadConfig };

@@ -1,6 +0,5 @@

import { B as ResolveResult, C as BindingViteManifestPluginConfig, G as isolatedDeclaration, I as NapiResolveOptions, K as isolatedDeclarationSync, M as IsolatedDeclarationsResult, O as BindingViteTransformPluginConfig, V as ResolverFactory, _ as BindingTsconfigRawOptions, f as BindingRebuildStrategy, g as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, j as IsolatedDeclarationsOptions, n as BindingBundleAnalyzerPluginConfig, q as moduleRunnerTransform, r as BindingBundleState } from "./shared/binding-D26QphWG.mjs";
import { Bt as OutputOptions, F as BuiltinPlugin, Q as defineParallelPlugin, Wt as StringOrRegExp, Yt as RolldownOutput, Zt as freeExternalMemory, l as InputOptions, lt as NormalizedOutputOptions } from "./shared/define-config-BhJ90aEv.mjs";
import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-BPrUvqEZ.mjs";
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-BbWPse2X.mjs";
import { H as ResolverFactory, J as moduleRunnerTransform, K as isolatedDeclaration, L as NapiResolveOptions, M as IsolatedDeclarationsOptions, N as IsolatedDeclarationsResult, V as ResolveResult, _ as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, k as BindingViteTransformPluginConfig, n as BindingBundleAnalyzerPluginConfig, p as BindingRebuildStrategy, q as isolatedDeclarationSync, r as BindingBundleState, u as BindingLazyChunkOutput, v as BindingTsconfigRawOptions, w as BindingViteManifestPluginConfig } from "./shared/binding-Dbbi0RbO.mjs";
import { Bt as OutputOptions, F as BuiltinPlugin, Q as defineParallelPlugin, Wt as StringOrRegExp, Yt as RolldownOutput, Zt as freeExternalMemory, l as InputOptions, lt as NormalizedOutputOptions } from "./shared/define-config-B-IDOhDz.mjs";
import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-Cs2bUDRH.mjs";
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-CSWbNgBZ.mjs";
//#region src/api/dev/dev-options.d.ts

@@ -15,54 +14,54 @@ type DevOnHmrUpdates = (result: Error | {

/**
* If `true`, files are not written to disk.
* @default false
*/
* If `true`, files are not written to disk.
* @default false
*/
skipWrite?: boolean;
/**
* If `true`, use polling instead of native file system events for watching.
* @default false
*/
* If `true`, use polling instead of native file system events for watching.
* @default false
*/
usePolling?: boolean;
/**
* Poll interval in milliseconds (only used when usePolling is true).
* @default 100
*/
* Poll interval in milliseconds (only used when usePolling is true).
* @default 100
*/
pollInterval?: number;
/**
* If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
* @default true
*/
* If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
* @default true
*/
useDebounce?: boolean;
/**
* Debounce duration in milliseconds (only used when useDebounce is true).
* @default 10
*/
* Debounce duration in milliseconds (only used when useDebounce is true).
* @default 10
*/
debounceDuration?: number;
/**
* Whether to compare file contents for poll-based watchers (only used when usePolling is true).
* When enabled, poll watchers will check file contents to determine if they actually changed.
* @default false
*/
* Whether to compare file contents for poll-based watchers (only used when usePolling is true).
* When enabled, poll watchers will check file contents to determine if they actually changed.
* @default false
*/
compareContentsForPolling?: boolean;
/**
* Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
* Controls how frequently the debouncer checks for events to process.
* When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
* @default undefined (auto-select)
*/
* Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
* Controls how frequently the debouncer checks for events to process.
* When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
* @default undefined (auto-select)
*/
debounceTickRate?: number;
/**
* Filter to limit which discovered files are registered with the file watcher.
*
* Strings are treated as glob patterns.
*
* @default []
*/
* Filter to limit which discovered files are registered with the file watcher.
*
* Strings are treated as glob patterns.
*
* @default []
*/
include?: StringOrRegExp | StringOrRegExp[];
/**
* Filter to prevent discovered files from being registered with the file watcher.
*
* Strings are treated as glob patterns.
*
* @default []
*/
* Filter to prevent discovered files from being registered with the file watcher.
*
* Strings are treated as glob patterns.
*
* @default []
*/
exclude?: StringOrRegExp | StringOrRegExp[];

@@ -74,18 +73,19 @@ }

/**
* Called with assets emitted while generating an HMR patch or compiling a
* lazy entry (e.g. an image newly imported by the changed/lazy module).
*
* These never go through {@link onOutput}, so a consumer that serves built
* files (e.g. Vite's bundled dev server) must register this to receive them
* and write them to its in-memory file store before the client requests them.
*/
* Called with assets emitted while generating an HMR patch or compiling a
* lazy entry (e.g. an image newly imported by the changed/lazy module).
*
* These never go through {@link onOutput}, so a consumer that serves built
* files (e.g. Vite's bundled dev server) must register this to receive them
* and write them to its in-memory file store before the client requests them.
*/
onAdditionalAssets?: DevOnAdditionalAssets;
/**
* Strategy for triggering rebuilds after HMR updates.
* - `'always'`: Always trigger a rebuild after HMR updates
* - `'auto'`: Trigger rebuild only if HMR updates contain full reload updates
* - `'never'`: Never trigger rebuild after HMR updates (default)
* @default 'auto'
*/
rebuildStrategy?: "always" | "auto" | "never";
* Strategy for triggering rebuilds after HMR updates.
* - `'always'`: Always trigger a rebuild after HMR updates
* - `'never'`: Never trigger rebuild after HMR updates. The server no longer
* decides full reloads, so there is no `'auto'` upgrade anymore; pull fresh
* bundle output explicitly (e.g. `ensureLatestBuildOutput`) when needed.
* @default 'never'
*/
rebuildStrategy?: "always" | "never";
watch?: DevWatchOptions;

@@ -104,18 +104,27 @@ }

triggerFullBuild(): void;
invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingClientHmrUpdate[]>;
registerModules(clientId: string, modules: string[]): Promise<void>;
/**
* Client-connect signal (the clientId hello): creates the per-client session
* with an empty ship map. Reconnects arrive as fresh clientIds.
*/
registerClient(clientId: string): Promise<void>;
/**
* Delivery notification from the serving middleware: the response for
* `filename` completed, so record its modules as shipped to that client.
*/
notifyPayloadDelivered(filename: string): Promise<void>;
removeClient(clientId: string): Promise<void>;
close(): Promise<void>;
/**
* Compile a lazy entry module and return HMR-style patch code.
*
* This is called when a dynamically imported module is first requested at runtime.
* The module was previously stubbed with a proxy, and now we need to compile the
* actual module and its dependencies.
*
* @param moduleId - The absolute file path of the module to compile
* @param clientId - The client ID requesting this compilation
* @returns The compiled JavaScript code as a string (HMR patch format)
*/
compileEntry(moduleId: string, clientId: string): Promise<string>;
* Compile a lazy entry module and return HMR-style patch code.
*
* This is called when a dynamically imported module is first requested at runtime.
* The module was previously stubbed with a proxy, and now we need to compile the
* actual module and its dependencies.
*
* @param moduleId - The absolute file path of the module to compile
* @param clientId - The client ID requesting this compilation
* @returns The compiled chunk: its code plus the filename whose delivery the
* serving middleware reports via {@link notifyPayloadDelivered}
*/
compileEntry(moduleId: string, clientId: string): Promise<BindingLazyChunkOutput>;
}

@@ -128,16 +137,16 @@ //#endregion

/**
* This is an experimental API. Its behavior may change in the future.
*
* - Calling this API will only execute the `scan/build` stage of rolldown.
* - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
*
* @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
* ```ts
* import { scan } from 'rolldown/api/experimental';
*
* const cleanupPromise = await scan(...);
* await cleanupPromise;
* // Now all resources have been cleaned up.
* ```
*/
* This is an experimental API. Its behavior may change in the future.
*
* - Calling this API will only execute the `scan/build` stage of rolldown.
* - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
*
* @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
* ```ts
* import { scan } from 'rolldown/api/experimental';
*
* const cleanupPromise = await scan(...);
* await cleanupPromise;
* // Now all resources have been cleaned up.
* ```
*/
declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;

@@ -156,49 +165,49 @@ //#endregion

/**
* A plugin that analyzes bundle composition and generates detailed reports.
*
* The plugin outputs a file containing detailed information about:
* - All chunks and their relationships
* - Modules bundled in each chunk
* - Import dependencies between chunks
* - Reachable modules from each entry point
*
* @example
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin()
* ]
* }
* ```
*
* @example
* **Custom filename**
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin({
* fileName: 'bundle-analysis.json'
* })
* ]
* }
* ```
*
* @example
* **LLM-friendly markdown output**
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin({
* format: 'md'
* })
* ]
* }
* ```
*/
* A plugin that analyzes bundle composition and generates detailed reports.
*
* The plugin outputs a file containing detailed information about:
* - All chunks and their relationships
* - Modules bundled in each chunk
* - Import dependencies between chunks
* - Reachable modules from each entry point
*
* @example
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin()
* ]
* }
* ```
*
* @example
* **Custom filename**
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin({
* fileName: 'bundle-analysis.json'
* })
* ]
* }
* ```
*
* @example
* **LLM-friendly markdown output**
* ```js
* import { bundleAnalyzerPlugin } from 'rolldown/experimental';
*
* export default {
* plugins: [
* bundleAnalyzerPlugin({
* format: 'md'
* })
* ]
* }
* ```
*/
declare function bundleAnalyzerPlugin(config?: BindingBundleAnalyzerPluginConfig): BuiltinPlugin;

@@ -224,28 +233,28 @@ //#endregion

/**
* In-memory file system for browser builds.
*
* This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
* It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
*
* - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
* - `volume`: The underlying `Volume` instance that stores the filesystem state
*
* Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
*
* @example
* ```typescript
* import { memfs } from 'rolldown/experimental';
*
* // Write files to virtual filesystem before bundling
* memfs?.volume.fromJSON({
* '/src/index.js': 'export const foo = 42;',
* '/package.json': '{"name": "my-app"}'
* });
*
* // Read files from the virtual filesystem
* const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
* ```
*
* @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
*/
* In-memory file system for browser builds.
*
* This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
* It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
*
* - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
* - `volume`: The underlying `Volume` instance that stores the filesystem state
*
* Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
*
* @example
* ```typescript
* import { memfs } from 'rolldown/experimental';
*
* // Write files to virtual filesystem before bundling
* memfs?.volume.fromJSON({
* '/src/index.js': 'export const foo = 42;',
* '/package.json': '{"name": "my-app"}'
* });
*
* // Read files from the virtual filesystem
* const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
* ```
*
* @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
*/
declare const memfs: {

@@ -252,0 +261,0 @@ fs: any;

@@ -1,9 +0,9 @@

import { n as __toESM, t as require_binding } from "./shared/binding-TuFFIE_J.mjs";
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-dnh67V_w.mjs";
import { o as transformToRollupOutput } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-CtPvmZgJ.mjs";
import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-BHRSI0R7.mjs";
import { n as parseSync$1, t as parse$1 } from "./shared/parse-D4dtlfWy.mjs";
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-D_3i7dpX.mjs";
import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-DxqIJB3x.mjs";
import { n as __toESM, t as require_binding } from "./shared/binding-Dby9rwGk.mjs";
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-SiXbePVH.mjs";
import { o as transformToRollupOutput } from "./shared/bindingify-input-options-_ppP73I9.mjs";
import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-CdF8HAHX.mjs";
import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-DFGNOCle.mjs";
import { n as parseSync$1, t as parse$1 } from "./shared/parse-BFj5G_7i.mjs";
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-CuGa75s-.mjs";
import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-2TXRF_zr.mjs";
import { pathToFileURL } from "node:url";

@@ -47,3 +47,3 @@ //#region src/api/dev/dev-engine.ts

} : void 0,
rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding.BindingRebuildStrategy.Auto : import_binding.BindingRebuildStrategy.Never : void 0,
rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : import_binding.BindingRebuildStrategy.Never : void 0,
watch: devOptions.watch && {

@@ -87,7 +87,15 @@ skipWrite: devOptions.watch.skipWrite,

}
async invalidate(file, firstInvalidatedBy) {
return unwrapBindingResult(await this.#inner.invalidate(file, firstInvalidatedBy));
/**
* Client-connect signal (the clientId hello): creates the per-client session
* with an empty ship map. Reconnects arrive as fresh clientIds.
*/
async registerClient(clientId) {
await this.#inner.registerClient(clientId);
}
async registerModules(clientId, modules) {
await this.#inner.registerModules(clientId, modules);
/**
* Delivery notification from the serving middleware: the response for
* `filename` completed, so record its modules as shipped to that client.
*/
async notifyPayloadDelivered(filename) {
await this.#inner.notifyPayloadDelivered(filename);
}

@@ -109,3 +117,4 @@ async removeClient(clientId) {

* @param clientId - The client ID requesting this compilation
* @returns The compiled JavaScript code as a string (HMR patch format)
* @returns The compiled chunk: its code plus the filename whose delivery the
* serving middleware reports via {@link notifyPayloadDelivered}
*/

@@ -112,0 +121,0 @@ async compileEntry(moduleId, clientId) {

/**
* @typedef {{ type: 'hmr:module-registered', modules: string[] }} DevRuntimeMessage
* @typedef {{ send(message: DevRuntimeMessage): void }} Messenger
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
* @typedef {{ ids: string[], localCount: number, edges: number[][], dynamicEdges?: number[][] }} ModuleGraphDelta
* @typedef {{ createModuleHotContext(moduleId: string): any, onModuleCacheRemoval(moduleId: string): void }} DevRuntimeHooks
*/
export class MissingFactoryError {
/**
* @param {string} id
*/
constructor(id: string);
id: string;
}
export class DevRuntime {
/**
* @param {Messenger} messenger
* @param {string} clientId
*/
constructor(messenger: Messenger, clientId: string);
constructor(clientId: string);
/**

@@ -16,17 +25,64 @@ * Client ID generated at runtime initialization, used for lazy compilation requests.

clientId: string;
messenger: Messenger;
/**
* @type {Record<string, Module>}
* Static import edges from `registerGraph` — entries persist across `removeModuleCache`
* and change only by replacement from a newer payload (last write wins).
* @type {Map<string, { edges: string[] }>}
*/
modules: Record<string, Module>;
staticImports: Map<string, {
edges: string[];
}>;
/**
* @param {string} _moduleId
* Reverse index over the static imports.
* @type {Map<string, Set<string>>}
*/
createModuleHotContext(_moduleId: string): void;
importers: Map<string, Set<string>>;
/**
* @param {[string, string][]} _boundaries
* Dynamic `import()` edges from `registerGraph`, keyed by importer — mirror of
* `staticImports` for the dynamic reverse index.
* @type {Map<string, { edges: string[] }>}
*/
applyUpdates(_boundaries: [string, string][]): void;
dynamicImports: Map<string, {
edges: string[];
}>;
/**
* Reverse index over the dynamic imports.
* @type {Map<string, Set<string>>}
*/
dynamicImporters: Map<string, Set<string>>;
/**
* The module cache. Membership means "this module's side effects ran in this tab" —
* registration is emitted ahead of every module body, and nothing un-registers on
* unwind, so a factory that throws mid-body stays registered. A `Map` rather than a
* plain object: HMR eviction deletes entries, and a `delete` on an object drops V8
* into dictionary mode, taxing every later lookup on the hottest read path.
* @type {Map<string, Module>}
*/
moduleCache: Map<string, Module>;
/**
* Re-runnable factories from HMR patches and lazy chunks. The initial bundle stays
* scope-hoisted and contributes none.
* @type {Map<string, { kind: 'esm' | 'cjs', fn: (id: string) => void }>}
*/
factories: Map<string, {
kind: "esm" | "cjs";
fn: (id: string) => void;
}>;
/**
* Installed by the dev client at boot. The runtime is a store + executor and makes
* no HMR decisions; accepting, disposing, and reloading live behind these hooks.
* @type {DevRuntimeHooks | null}
*/
hooks: DevRuntimeHooks | null;
/**
* @param {ModuleGraphDelta} delta
*/
registerGraph(delta: ModuleGraphDelta): void;
/**
* @param {string} id
* @param {'esm' | 'cjs'} kind
* @param {(id: string) => void} fn
*/
registerFactory(id: string, kind: "esm" | "cjs", fn: (id: string) => void): void;
/**
* @param {string} id
* @param {{ exports: any }} exportsHolder

@@ -39,31 +95,33 @@ */

* @param {string} id
* @returns {string[]}
*/
loadExports(id: string): any;
getImporters(id: string): string[];
/**
* __esmMin
*
* When `dedup` is truthy and `id` is already registered on the runtime,
* skip the factory: another lazy blob got there first. HMR patches pass
* no `dedup` so they always re-run the factory and replace the registered
* exports.
*
* @type {<T>(id: string, fn: any, dedup: any, res: T) => () => T}
* @internal
* @param {string} id
*/
createEsmInitializer: <T>(id: string, fn: any, dedup: any, res: T) => () => T;
isExecuted(id: string): any;
/**
* __commonJSMin
*
* Same dedup gate as createEsmInitializer. With `dedup` truthy and `id`
* registered, reuse the registered exports object; otherwise run the
* factory.
*
* @type {<T extends { exports: any }>(id: string, cb: any, dedup: any, mod: { exports: any }, registered: any) => () => T}
* @internal
* @param {string} id
*/
createCjsInitializer: <T extends {
exports: any;
}>(id: string, cb: any, dedup: any, mod: {
exports: any;
}, registered: any) => () => T;
hasFactory(id: string): any;
/**
* Module-cache delete only — static imports and factories persist. Removal is what
* re-arms a cache-gated factory for `initModule`.
* @param {string} id
*/
removeModuleCache(id: string): void;
/**
* The one re-execution gate: registered → return the live exports; otherwise run the
* mapped factory (which registers itself first, then runs the body).
* @param {string} id
*/
initModule(id: string): any;
/**
* @param {string} id
*/
loadExports(id: string): any;
/**
* @param {string} moduleId
*/
createModuleHotContext(moduleId: string): any;
/** @internal */

@@ -83,10 +141,22 @@ __toESM: any;

__reExport: any;
sendModuleRegisteredMessage: (module: string) => void;
}
export type DevRuntimeMessage = {
type: "hmr:module-registered";
modules: string[];
/**
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
*/
export type ModuleGraphDelta = {
ids: string[];
localCount: number;
edges: number[][];
dynamicEdges?: number[][];
};
export type Messenger = {
send(message: DevRuntimeMessage): void;
/**
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
*/
export type DevRuntimeHooks = {
createModuleHotContext(moduleId: string): any;
onModuleCacheRemoval(moduleId: string): void;
};

@@ -93,0 +163,0 @@ declare class Module {

@@ -1,3 +0,2 @@

import { P as withFilter } from "./shared/define-config-BhJ90aEv.mjs";
import { P as withFilter } from "./shared/define-config-B-IDOhDz.mjs";
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.1/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts

@@ -93,3 +92,4 @@ //#region src/filter/composable-filters.d.ts

declare function interpreterImpl(expr: TopLevelFilterExpression[], code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean; //#endregion
declare function exprInterpreter(expr: FilterExpression, code?: string, id?: string, moduleType?: PluginModuleType, importerId?: string, ctx?: InterpreterCtx): boolean;
//#endregion
//#region src/filter/filter-vite-plugins.d.ts

@@ -123,3 +123,4 @@ /**

*/
declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[]; //#endregion
declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
//#endregion
//#region src/filter/simple-filters.d.ts

@@ -195,4 +196,4 @@ /**

declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[]; //#endregion
declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
//#endregion
export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };

@@ -1,3 +0,3 @@

import { a as RolldownLog } from "./shared/logging-BSNejiLS.mjs";
import { n as getLogFilter, t as GetLogFilter } from "./shared/get-log-filter-BpNVNJ5-.mjs";
import { a as RolldownLog } from "./shared/logging-xuHO4mAy.mjs";
import { n as getLogFilter, t as GetLogFilter } from "./shared/get-log-filter-AjBknEEO.mjs";
export { GetLogFilter, type RolldownLog, type RolldownLog as RollupLog, getLogFilter as default };

@@ -1,4 +0,4 @@

import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-BSNejiLS.mjs";
import { z as PreRenderedChunk } from "./shared/binding-D26QphWG.mjs";
import { $ as MinimalPluginContext, $t as SourcemapIgnoreListOption, A as RolldownPlugin, At as ChunkingContext, B as SourceMapInput, Bt as OutputOptions, C as ParallelPluginHooks, Ct as BuildOptions, D as ResolveIdExtraOptions, Dt as AdvancedChunksOptions, E as PluginMeta, Et as AdvancedChunksGroup, Ft as GeneratedCodeOptions, G as EmittedChunk, Gt as OutputAsset, H as TreeshakingOptions, I as RUNTIME_MODULE_ID, It as GeneratedCodePreset, J as GetModuleInfo, Jt as RenderedModule, K as EmittedFile, Kt as OutputChunk, L as VERSION, Lt as GlobalsFunction, M as SourceDescription, Mt as CodeSplittingNameFunction, N as TransformResult, Nt as CodeSplittingOptions, O as ResolveIdResult, Ot as BuiltinModuleTag, Pt as CommentsOptions, Qt as ModuleInfo, R as BundleError, Rt as MinifyOptions, S as ObjectHook, St as RolldownBuild, T as Plugin, Tt as AddonFunction, U as TransformPluginContext, Ut as PartialNull, V as OutputBundle, Vt as PreRenderedAsset, W as EmittedAsset, X as PluginContextResolveOptions, Xt as SourceMap, Y as PluginContext, Yt as RolldownOutput, Z as DefineParallelPluginResult, _ as HookFilterExtension, _t as RolldownWatcher, a as ChunkOptimizationOptions, at as RolldownDirectoryEntry, b as ModuleOptions, bt as WatchOptions, c as InputOption, ct as InternalModuleFormat, d as OptimizationOptions, dt as TransformOptions, et as PluginContextMeta, f as WatcherFileWatcherOptions, ft as ChecksOptions, g as FunctionPluginHooks, gt as watch, h as CustomPluginOptions, ht as RolldownMagicString, i as RolldownOptions, it as BufferEncoding, j as RolldownPluginOption, jt as CodeSplittingGroup, k as ResolvedId, kt as ChunkFileNamesFunction, l as InputOptions, lt as NormalizedOutputOptions, m as AsyncPluginHooks, mt as WarningHandlerWithDefault, n as RolldownOptionsFunction, nt as HookFilter, o as ExternalOption, ot as RolldownFileStats, p as WatcherOptions, pt as LoggingFunction, q as EmittedPrebuiltChunk, qt as RenderedChunk, r as defineConfig, rt as ModuleTypeFilter, s as ExternalOptionFunction, st as RolldownFsModule, t as ConfigExport, tt as GeneralHookFilter, u as ModuleTypes, ut as NormalizedInputOptions, v as ImportKind, vt as RolldownWatcherEvent, w as PartialResolvedId, wt as build, x as ModuleType, xt as rolldown, y as LoadResult, yt as RolldownWatcherWatcherEventMap, z as ExistingRawSourceMap, zt as ModuleFormat } from "./shared/define-config-BhJ90aEv.mjs";
import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-xuHO4mAy.mjs";
import { B as PreRenderedChunk } from "./shared/binding-Dbbi0RbO.mjs";
import { $ as MinimalPluginContext, $t as SourcemapIgnoreListOption, A as RolldownPlugin, At as ChunkingContext, B as SourceMapInput, Bt as OutputOptions, C as ParallelPluginHooks, Ct as BuildOptions, D as ResolveIdExtraOptions, Dt as AdvancedChunksOptions, E as PluginMeta, Et as AdvancedChunksGroup, Ft as GeneratedCodeOptions, G as EmittedChunk, Gt as OutputAsset, H as TreeshakingOptions, I as RUNTIME_MODULE_ID, It as GeneratedCodePreset, J as GetModuleInfo, Jt as RenderedModule, K as EmittedFile, Kt as OutputChunk, L as VERSION, Lt as GlobalsFunction, M as SourceDescription, Mt as CodeSplittingNameFunction, N as TransformResult, Nt as CodeSplittingOptions, O as ResolveIdResult, Ot as BuiltinModuleTag, Pt as CommentsOptions, Qt as ModuleInfo, R as BundleError, Rt as MinifyOptions, S as ObjectHook, St as RolldownBuild, T as Plugin, Tt as AddonFunction, U as TransformPluginContext, Ut as PartialNull, V as OutputBundle, Vt as PreRenderedAsset, W as EmittedAsset, X as PluginContextResolveOptions, Xt as SourceMap, Y as PluginContext, Yt as RolldownOutput, Z as DefineParallelPluginResult, _ as HookFilterExtension, _t as RolldownWatcher, a as ChunkOptimizationOptions, at as RolldownDirectoryEntry, b as ModuleOptions, bt as WatchOptions, c as InputOption, ct as InternalModuleFormat, d as OptimizationOptions, dt as TransformOptions, et as PluginContextMeta, f as WatcherFileWatcherOptions, ft as ChecksOptions, g as FunctionPluginHooks, gt as watch, h as CustomPluginOptions, ht as RolldownMagicString, i as RolldownOptions, it as BufferEncoding, j as RolldownPluginOption, jt as CodeSplittingGroup, k as ResolvedId, kt as ChunkFileNamesFunction, l as InputOptions, lt as NormalizedOutputOptions, m as AsyncPluginHooks, mt as WarningHandlerWithDefault, n as RolldownOptionsFunction, nt as HookFilter, o as ExternalOption, ot as RolldownFileStats, p as WatcherOptions, pt as LoggingFunction, q as EmittedPrebuiltChunk, qt as RenderedChunk, r as defineConfig, rt as ModuleTypeFilter, s as ExternalOptionFunction, st as RolldownFsModule, t as ConfigExport, tt as GeneralHookFilter, u as ModuleTypes, ut as NormalizedInputOptions, v as ImportKind, vt as RolldownWatcherEvent, w as PartialResolvedId, wt as build, x as ModuleType, xt as rolldown, y as LoadResult, yt as RolldownWatcherWatcherEventMap, z as ExistingRawSourceMap, zt as ModuleFormat } from "./shared/define-config-B-IDOhDz.mjs";
export { type AddonFunction, type AdvancedChunksGroup, type AdvancedChunksOptions, type AsyncPluginHooks, type BufferEncoding, type BuildOptions, type BuiltinModuleTag, type BundleError, type ChecksOptions, type ChunkFileNamesFunction, type ChunkOptimizationOptions, type ChunkingContext, type CodeSplittingGroup, type CodeSplittingNameFunction, type CodeSplittingOptions, type CommentsOptions, type ConfigExport, type CustomPluginOptions, type DefineParallelPluginResult, type EmittedAsset, type EmittedChunk, type EmittedFile, type EmittedPrebuiltChunk, type ExistingRawSourceMap, type ExternalOption, type ExternalOptionFunction, type FunctionPluginHooks, type GeneralHookFilter, type GeneratedCodeOptions, type GeneratedCodePreset, type GetModuleInfo, type GlobalsFunction, type HookFilter, type HookFilterExtension, type ImportKind, type InputOption, type InputOptions, type InternalModuleFormat, type LoadResult, type LogLevel, type LogLevelOption, type LogOrStringHandler, type LoggingFunction, type MinifyOptions, type MinimalPluginContext, type ModuleFormat, type ModuleInfo, type ModuleOptions, type ModuleType, type ModuleTypeFilter, type ModuleTypes, type NormalizedInputOptions, type NormalizedOutputOptions, type ObjectHook, type OptimizationOptions, type OutputAsset, type OutputBundle, type OutputChunk, type OutputOptions, type ParallelPluginHooks, type PartialNull, type PartialResolvedId, type Plugin, type PluginContext, type PluginContextMeta, type PluginContextResolveOptions, type PluginMeta, type PreRenderedAsset, type PreRenderedChunk, RUNTIME_MODULE_ID, type RenderedChunk, type RenderedModule, type ResolveIdExtraOptions, type ResolveIdResult, type ResolvedId, type RolldownBuild, type RolldownDirectoryEntry, type RolldownError, type RolldownError as RollupError, type RolldownFileStats, type RolldownFsModule, type RolldownLog, type RolldownLog as RollupLog, type RolldownLogWithString, type RolldownLogWithString as RollupLogWithString, RolldownMagicString, type RolldownOptions, type RolldownOptionsFunction, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatcher, type RolldownWatcherEvent, type RolldownWatcherWatcherEventMap, type SourceDescription, type SourceMap, type SourceMapInput, type SourcemapIgnoreListOption, type TransformOptions, type TransformPluginContext, type TransformResult, type TreeshakingOptions, VERSION, type WarningHandlerWithDefault, type WatchOptions, type WatcherFileWatcherOptions, type WatcherOptions, build, defineConfig, rolldown, watch };

@@ -1,5 +0,5 @@

import { n as __toESM, t as require_binding } from "./shared/binding-TuFFIE_J.mjs";
import { n as onExit, t as watch } from "./shared/watch-B1b0gmVh.mjs";
import { b as VERSION, r as RolldownMagicString } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
import { t as rolldown } from "./shared/rolldown-ChpIlMRm.mjs";
import { n as __toESM, t as require_binding } from "./shared/binding-Dby9rwGk.mjs";
import { n as onExit, t as watch } from "./shared/watch-WnrlHRS0.mjs";
import { b as VERSION, r as RolldownMagicString } from "./shared/bindingify-input-options-_ppP73I9.mjs";
import { t as rolldown } from "./shared/rolldown-951h_1lf.mjs";
import { t as defineConfig } from "./shared/define-config-Demdg3_4.mjs";

@@ -6,0 +6,0 @@ import { isMainThread } from "node:worker_threads";

@@ -1,3 +0,3 @@

import { n as __toESM, t as require_binding } from "./shared/binding-TuFFIE_J.mjs";
import { i as PluginContextData, n as bindingifyPlugin } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
import { n as __toESM, t as require_binding } from "./shared/binding-Dby9rwGk.mjs";
import { i as PluginContextData, n as bindingifyPlugin } from "./shared/bindingify-input-options-_ppP73I9.mjs";
import { parentPort, workerData } from "node:worker_threads";

@@ -4,0 +4,0 @@ //#region src/parallel-plugin-worker.ts

@@ -1,3 +0,2 @@

import { Ht as MaybePromise, T as Plugin } from "./shared/define-config-BhJ90aEv.mjs";
import { Ht as MaybePromise, T as Plugin } from "./shared/define-config-B-IDOhDz.mjs";
//#region src/plugin/parallel-plugin-implementation.d.ts

@@ -7,4 +6,4 @@ type ParallelPluginImplementation = Plugin;

/**
* Thread number
*/
* Thread number
*/
threadNumber: number;

@@ -11,0 +10,0 @@ };

@@ -1,32 +0,31 @@

import { L as ParseResult$1, R as ParserOptions$1 } from "./shared/binding-D26QphWG.mjs";
import { R as ParseResult$1, z as ParserOptions$1 } from "./shared/binding-Dbbi0RbO.mjs";
import { Program } from "@oxc-project/types";
//#region src/parse-ast-index.d.ts
/**
* @hidden
*/
* @hidden
*/
type ParseResult = ParseResult$1;
/**
* @hidden
*/
* @hidden
*/
type ParserOptions = ParserOptions$1;
/**
* Parse code synchronously and return the AST.
*
* This function is similar to Rollup's `parseAst` function.
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
*
* @category Utilities
*/
* Parse code synchronously and return the AST.
*
* This function is similar to Rollup's `parseAst` function.
* Prefer using {@linkcode parseSync} instead of this function as it has more information in the return value.
*
* @category Utilities
*/
declare function parseAst(sourceText: string, options?: ParserOptions | null, filename?: string): Program;
/**
* Parse code asynchronously and return the AST.
*
* This function is similar to Rollup's `parseAstAsync` function.
* Prefer using {@linkcode parseAsync} instead of this function as it has more information in the return value.
*
* @category Utilities
*/
* Parse code asynchronously and return the AST.
*
* This function is similar to Rollup's `parseAstAsync` function.
* Prefer using {@linkcode parseAsync} instead of this function as it has more information in the return value.
*
* @category Utilities
*/
declare function parseAstAsync(sourceText: string, options?: ParserOptions | null, filename?: string): Promise<Program>;
//#endregion
export { ParseResult, ParserOptions, parseAst, parseAstAsync };
import { l as locate, n as error, s as logParseError, t as augmentCodeLocation, u as getCodeFrame } from "./shared/logs-ZGEh6uhb.mjs";
import { n as parseSync, t as parse } from "./shared/parse-D4dtlfWy.mjs";
import { n as parseSync, t as parse } from "./shared/parse-BFj5G_7i.mjs";
//#region src/parse-ast-index.ts

@@ -4,0 +4,0 @@ function wrap(result, filename, sourceText) {

@@ -1,33 +0,32 @@

import { m as BindingReplacePluginConfig } from "./shared/binding-D26QphWG.mjs";
import { F as BuiltinPlugin } from "./shared/define-config-BhJ90aEv.mjs";
import { t as esmExternalRequirePlugin } from "./shared/constructors-BbWPse2X.mjs";
import { h as BindingReplacePluginConfig } from "./shared/binding-Dbbi0RbO.mjs";
import { F as BuiltinPlugin } from "./shared/define-config-B-IDOhDz.mjs";
import { t as esmExternalRequirePlugin } from "./shared/constructors-CSWbNgBZ.mjs";
//#region src/builtin-plugin/replace-plugin.d.ts
/**
* Replaces targeted strings in files while bundling.
*
* @example
* **Basic usage**
* ```js
* replacePlugin({
* 'process.env.NODE_ENV': JSON.stringify('production'),
* __buildVersion: 15
* })
* ```
* @example
* **With options**
* ```js
* replacePlugin({
* 'process.env.NODE_ENV': JSON.stringify('production'),
* __buildVersion: 15
* }, {
* preventAssignment: false,
* })
* ```
*
* @see https://rolldown.rs/builtin-plugins/replace
* @category Builtin Plugins
*/
* Replaces targeted strings in files while bundling.
*
* @example
* **Basic usage**
* ```js
* replacePlugin({
* 'process.env.NODE_ENV': JSON.stringify('production'),
* __buildVersion: 15
* })
* ```
* @example
* **With options**
* ```js
* replacePlugin({
* 'process.env.NODE_ENV': JSON.stringify('production'),
* __buildVersion: 15
* }, {
* preventAssignment: false,
* })
* ```
*
* @see https://rolldown.rs/builtin-plugins/replace
* @category Builtin Plugins
*/
declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
//#endregion
export { esmExternalRequirePlugin, replacePlugin };

@@ -1,3 +0,3 @@

import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-dnh67V_w.mjs";
import { t as esmExternalRequirePlugin } from "./shared/constructors-D_3i7dpX.mjs";
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-SiXbePVH.mjs";
import { t as esmExternalRequirePlugin } from "./shared/constructors-CuGa75s-.mjs";
//#region src/builtin-plugin/replace-plugin.ts

@@ -4,0 +4,0 @@ /**

@@ -1,7 +0,6 @@

import { _ as BindingTsconfigRawOptions, g as BindingTsconfigCompilerOptions } from "./shared/binding-D26QphWG.mjs";
import { a as MinifyOptions, c as minifySync, d as parse, f as parseSync, i as transformSync, l as ParseResult, n as TransformResult, o as MinifyResult, p as TsconfigCache, r as transform, s as minify, t as TransformOptions, u as ParserOptions } from "./shared/transform-BPrUvqEZ.mjs";
import { _ as BindingTsconfigCompilerOptions, v as BindingTsconfigRawOptions } from "./shared/binding-Dbbi0RbO.mjs";
import { a as MinifyOptions, c as minifySync, d as parse, f as parseSync, i as transformSync, l as ParseResult, n as TransformResult, o as MinifyResult, p as TsconfigCache, r as transform, s as minify, t as TransformOptions, u as ParserOptions } from "./shared/transform-Cs2bUDRH.mjs";
import * as ESTree from "@oxc-project/types";
import { Program } from "@oxc-project/types";
//#region ../../node_modules/.pnpm/oxc-parser@0.139.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
//#region ../../node_modules/.pnpm/oxc-parser@0.140.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
interface VisitorObject$1 {

@@ -342,30 +341,30 @@ DebuggerStatement?: (node: ESTree.DebuggerStatement) => void;

/**
* Visitor object for traversing AST.
*
* @category Utilities
*/
* Visitor object for traversing AST.
*
* @category Utilities
*/
type VisitorObject = VisitorObject$1;
/**
* Visitor class for traversing AST.
*
* @example
* ```ts
* import { Visitor } from 'rolldown/utils';
* import { parseSync } from 'rolldown/utils';
*
* const result = parseSync(...);
* const visitor = new Visitor({
* VariableDeclaration(path) {
* // Do something with the variable declaration
* },
* "VariableDeclaration:exit"(path) {
* // Do something after visiting the variable declaration
* }
* });
* visitor.visit(result.program);
* ```
*
* @category Utilities
* @experimental
*/
* Visitor class for traversing AST.
*
* @example
* ```ts
* import { Visitor } from 'rolldown/utils';
* import { parseSync } from 'rolldown/utils';
*
* const result = parseSync(...);
* const visitor = new Visitor({
* VariableDeclaration(path) {
* // Do something with the variable declaration
* },
* "VariableDeclaration:exit"(path) {
* // Do something after visiting the variable declaration
* }
* });
* visitor.visit(result.program);
* ```
*
* @category Utilities
* @experimental
*/
declare class Visitor {

@@ -372,0 +371,0 @@ #private;

{
"name": "rolldown",
"version": "1.1.5",
"version": "1.2.0",
"description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",

@@ -56,7 +56,7 @@ "keywords": [

"dependencies": {
"@oxc-project/types": "=0.139.0",
"@oxc-project/types": "=0.140.0",
"@rolldown/pluginutils": "^1.0.0"
},
"devDependencies": {
"@napi-rs/cli": "^3.7.2",
"@napi-rs/cli": "^3.7.3",
"@napi-rs/wasm-runtime": "^1.1.6",

@@ -71,6 +71,6 @@ "@oxc-node/cli": "^0.1.0",

"glob": "^13.0.0",
"oxc-parser": "=0.139.0",
"oxc-parser": "=0.140.0",
"pathe": "^2.0.3",
"remeda": "^2.34.1",
"rolldown-plugin-dts": "^0.26.0",
"rolldown-plugin-dts": "^0.27.0",
"rollup": "^4.60.4",

@@ -81,3 +81,3 @@ "signal-exit": "4.1.0",

"valibot": "1.4.2",
"rolldown": "1.1.5"
"rolldown": "1.2.0"
},

@@ -118,17 +118,17 @@ "napi": {

"optionalDependencies": {
"@rolldown/binding-darwin-x64": "1.1.5",
"@rolldown/binding-win32-x64-msvc": "1.1.5",
"@rolldown/binding-linux-x64-gnu": "1.1.5",
"@rolldown/binding-linux-x64-musl": "1.1.5",
"@rolldown/binding-freebsd-x64": "1.1.5",
"@rolldown/binding-linux-arm-gnueabihf": "1.1.5",
"@rolldown/binding-linux-arm64-gnu": "1.1.5",
"@rolldown/binding-darwin-arm64": "1.1.5",
"@rolldown/binding-linux-arm64-musl": "1.1.5",
"@rolldown/binding-openharmony-arm64": "1.1.5",
"@rolldown/binding-win32-arm64-msvc": "1.1.5",
"@rolldown/binding-android-arm64": "1.1.5",
"@rolldown/binding-wasm32-wasi": "1.1.5",
"@rolldown/binding-linux-s390x-gnu": "1.1.5",
"@rolldown/binding-linux-ppc64-gnu": "1.1.5"
"@rolldown/binding-darwin-x64": "1.2.0",
"@rolldown/binding-win32-x64-msvc": "1.2.0",
"@rolldown/binding-linux-x64-gnu": "1.2.0",
"@rolldown/binding-linux-x64-musl": "1.2.0",
"@rolldown/binding-freebsd-x64": "1.2.0",
"@rolldown/binding-linux-arm-gnueabihf": "1.2.0",
"@rolldown/binding-linux-arm64-gnu": "1.2.0",
"@rolldown/binding-darwin-arm64": "1.2.0",
"@rolldown/binding-linux-arm64-musl": "1.2.0",
"@rolldown/binding-openharmony-arm64": "1.2.0",
"@rolldown/binding-win32-arm64-msvc": "1.2.0",
"@rolldown/binding-android-arm64": "1.2.0",
"@rolldown/binding-wasm32-wasi": "1.2.0",
"@rolldown/binding-linux-s390x-gnu": "1.2.0",
"@rolldown/binding-linux-ppc64-gnu": "1.2.0"
},

@@ -135,0 +135,0 @@ "scripts": {

Sorry, the diff of this file is too big to display

import { createRequire } from "node:module";
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
//#endregion
//#region src/webcontainer-fallback.cjs
var require_webcontainer_fallback = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const fs = __require("node:fs");
const childProcess = __require("node:child_process");
const version = JSON.parse(fs.readFileSync(__require.resolve("rolldown/package.json"), "utf-8")).version;
const baseDir = `/tmp/rolldown-${version}`;
const bindingEntry = `${baseDir}/node_modules/@rolldown/binding-wasm32-wasi/rolldown-binding.wasi.cjs`;
if (!fs.existsSync(bindingEntry)) {
const bindingPkg = `@rolldown/binding-wasm32-wasi@${version}`;
fs.rmSync(baseDir, {
recursive: true,
force: true
});
fs.mkdirSync(baseDir, { recursive: true });
console.log(`[rolldown] Downloading ${bindingPkg} on WebContainer...`);
childProcess.execFileSync("pnpm", ["i", bindingPkg], {
cwd: baseDir,
stdio: "inherit"
});
}
module.exports = __require(bindingEntry);
}));
//#endregion
//#region src/binding.cjs
var require_binding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
const { readFileSync } = __require("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 (process.report && 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) {
return false;
}
};
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
return __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("./rolldown-binding.android-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-android-arm64");
const bindingPackageVersion = __require("@rolldown/binding-android-arm64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return __require("./rolldown-binding.android-arm-eabi.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-android-arm-eabi");
const bindingPackageVersion = __require("@rolldown/binding-android-arm-eabi/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Android ${process.arch}`));
else if (process.platform === "win32") if (process.arch === "x64") if (process.config && process.config.variables && process.config.variables.shlib_suffix === "dll.a" || process.config && process.config.variables && process.config.variables.node_target_type === "shared_library") {
try {
return __require("./rolldown-binding.win32-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-x64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-win32-x64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.win32-x64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-x64-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-x64-msvc/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ia32") {
try {
return __require("./rolldown-binding.win32-ia32-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-ia32-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-ia32-msvc/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.win32-arm64-msvc.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-win32-arm64-msvc");
const bindingPackageVersion = __require("@rolldown/binding-win32-arm64-msvc/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Windows: ${process.arch}`));
else if (process.platform === "darwin") {
try {
return __require("./rolldown-binding.darwin-universal.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-universal");
const bindingPackageVersion = __require("@rolldown/binding-darwin-universal/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
if (process.arch === "x64") {
try {
return __require("./rolldown-binding.darwin-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-x64");
const bindingPackageVersion = __require("@rolldown/binding-darwin-x64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.darwin-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-darwin-arm64");
const bindingPackageVersion = __require("@rolldown/binding-darwin-arm64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on macOS: ${process.arch}`));
} else if (process.platform === "freebsd") if (process.arch === "x64") {
try {
return __require("./rolldown-binding.freebsd-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-freebsd-x64");
const bindingPackageVersion = __require("@rolldown/binding-freebsd-x64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.freebsd-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-freebsd-arm64");
const bindingPackageVersion = __require("@rolldown/binding-freebsd-arm64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-x64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-x64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-x64-musl/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("../rolldown-binding.linux-x64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-x64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-x64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-arm64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-musl/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-arm64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "arm") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-arm-musleabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm-musleabihf");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm-musleabihf/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-arm-gnueabihf.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-arm-gnueabihf");
const bindingPackageVersion = __require("@rolldown/binding-linux-arm-gnueabihf/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "loong64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-loong64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-loong64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-musl/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-loong64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-loong64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-loong64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "riscv64") if (isMusl()) {
try {
return __require("./rolldown-binding.linux-riscv64-musl.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-riscv64-musl");
const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-musl/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else {
try {
return __require("./rolldown-binding.linux-riscv64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-riscv64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-riscv64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
}
else if (process.arch === "ppc64") {
try {
return __require("./rolldown-binding.linux-ppc64-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-ppc64-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-ppc64-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "s390x") {
try {
return __require("./rolldown-binding.linux-s390x-gnu.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-linux-s390x-gnu");
const bindingPackageVersion = __require("@rolldown/binding-linux-s390x-gnu/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on Linux: ${process.arch}`));
else if (process.platform === "openharmony") if (process.arch === "arm64") {
try {
return __require("./rolldown-binding.openharmony-arm64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-arm64");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "x64") {
try {
return __require("./rolldown-binding.openharmony-x64.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-x64");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-x64/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else if (process.arch === "arm") {
try {
return __require("./rolldown-binding.openharmony-arm.node");
} catch (e) {
loadErrors.push(e);
}
try {
const binding = __require("@rolldown/binding-openharmony-arm");
const bindingPackageVersion = __require("@rolldown/binding-openharmony-arm/package.json").version;
if (bindingPackageVersion !== "1.1.5" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 1.1.5 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
return binding;
} catch (e) {
loadErrors.push(e);
}
} else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
else loadErrors.push(/* @__PURE__ */ new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
}
nativeBinding = requireNative();
const forceWasi = process.env.NAPI_RS_FORCE_WASI === "true" || process.env.NAPI_RS_FORCE_WASI === "error";
if (!nativeBinding || forceWasi) {
let wasiBinding = null;
let wasiBindingError = null;
try {
wasiBinding = __require("../rolldown-binding.wasi.cjs");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) wasiBindingError = err;
}
if (!nativeBinding || forceWasi) try {
wasiBinding = __require("@rolldown/binding-wasm32-wasi");
nativeBinding = wasiBinding;
} catch (err) {
if (forceWasi) {
if (!wasiBindingError) wasiBindingError = err;
else wasiBindingError.cause = err;
loadErrors.push(err);
}
}
if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
const error = /* @__PURE__ */ new Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
error.cause = wasiBindingError;
throw error;
}
}
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) try {
nativeBinding = require_webcontainer_fallback();
} catch (err) {
loadErrors.push(err);
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
const error = /* @__PURE__ */ 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.");
error.cause = loadErrors.reduce((err, cur) => {
cur.cause = err;
return cur;
});
throw error;
}
throw new Error(`Failed to load native binding`);
}
module.exports = nativeBinding;
module.exports.LegalCommentsMode = nativeBinding.LegalCommentsMode;
module.exports.minify = nativeBinding.minify;
module.exports.minifySync = nativeBinding.minifySync;
module.exports.Severity = nativeBinding.Severity;
module.exports.ParseResult = nativeBinding.ParseResult;
module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind;
module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind;
module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind;
module.exports.ImportNameKind = nativeBinding.ImportNameKind;
module.exports.parse = nativeBinding.parse;
module.exports.parseSync = nativeBinding.parseSync;
module.exports.rawTransferSupported = nativeBinding.rawTransferSupported;
module.exports.ResolverFactory = nativeBinding.ResolverFactory;
module.exports.EnforceExtension = nativeBinding.EnforceExtension;
module.exports.ModuleType = nativeBinding.ModuleType;
module.exports.sync = nativeBinding.sync;
module.exports.HelperMode = nativeBinding.HelperMode;
module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
module.exports.isolatedDeclarationSync = nativeBinding.isolatedDeclarationSync;
module.exports.moduleRunnerTransform = nativeBinding.moduleRunnerTransform;
module.exports.moduleRunnerTransformSync = nativeBinding.moduleRunnerTransformSync;
module.exports.transform = nativeBinding.transform;
module.exports.transformSync = nativeBinding.transformSync;
module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
module.exports.BindingBundleErrorEventData = nativeBinding.BindingBundleErrorEventData;
module.exports.BindingBundler = nativeBinding.BindingBundler;
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
module.exports.BindingChunkingContext = nativeBinding.BindingChunkingContext;
module.exports.BindingDecodedMap = nativeBinding.BindingDecodedMap;
module.exports.BindingDevEngine = nativeBinding.BindingDevEngine;
module.exports.BindingLoadPluginContext = nativeBinding.BindingLoadPluginContext;
module.exports.BindingMagicString = nativeBinding.BindingMagicString;
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
module.exports.BindingRenderedChunk = nativeBinding.BindingRenderedChunk;
module.exports.BindingRenderedChunkMeta = nativeBinding.BindingRenderedChunkMeta;
module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
module.exports.BindingSourceMap = nativeBinding.BindingSourceMap;
module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
module.exports.BindingWatcher = nativeBinding.BindingWatcher;
module.exports.BindingWatcherBundler = nativeBinding.BindingWatcherBundler;
module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
module.exports.TraceSubscriberGuard = nativeBinding.TraceSubscriberGuard;
module.exports.TsconfigCache = nativeBinding.TsconfigCache;
module.exports.BindingAttachDebugInfo = nativeBinding.BindingAttachDebugInfo;
module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
module.exports.BindingChunkModuleOrderBy = nativeBinding.BindingChunkModuleOrderBy;
module.exports.BindingErrorStage = nativeBinding.BindingErrorStage;
module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
module.exports.BindingPropertyReadSideEffects = nativeBinding.BindingPropertyReadSideEffects;
module.exports.BindingPropertyWriteSideEffects = nativeBinding.BindingPropertyWriteSideEffects;
module.exports.BindingRebuildStrategy = nativeBinding.BindingRebuildStrategy;
module.exports.collapseSourcemaps = nativeBinding.collapseSourcemaps;
module.exports.enhancedTransform = nativeBinding.enhancedTransform;
module.exports.enhancedTransformSync = nativeBinding.enhancedTransformSync;
module.exports.FilterTokenKind = nativeBinding.FilterTokenKind;
module.exports.initTraceSubscriber = nativeBinding.initTraceSubscriber;
module.exports.registerPlugins = nativeBinding.registerPlugins;
module.exports.resolveTsconfig = nativeBinding.resolveTsconfig;
module.exports.shutdownAsyncRuntime = nativeBinding.shutdownAsyncRuntime;
module.exports.startAsyncRuntime = nativeBinding.startAsyncRuntime;
}));
//#endregion
export { __toESM as n, require_binding as t };

Sorry, the diff of this file is too big to display

import { D as BindingViteResolvePluginConfig, E as BindingViteReporterPluginConfig, S as BindingViteJsonPluginConfig, T as BindingViteReactRefreshWrapperPluginConfig, b as BindingViteDynamicImportVarsPluginConfig, l as BindingIsolatedDeclarationPluginConfig, s as BindingEsmExternalRequirePluginConfig, w as BindingViteModulePreloadPolyfillPluginConfig, x as BindingViteImportGlobPluginConfig, y as BindingViteBuildImportAnalysisPluginConfig } from "./binding-D26QphWG.mjs";
import { F as BuiltinPlugin, Wt as StringOrRegExp } from "./define-config-BhJ90aEv.mjs";
//#region src/builtin-plugin/constructors.d.ts
declare function viteModulePreloadPolyfillPlugin(config?: BindingViteModulePreloadPolyfillPluginConfig): BuiltinPlugin;
type DynamicImportVarsPluginConfig = Omit<BindingViteDynamicImportVarsPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
declare function viteDynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
declare function viteImportGlobPlugin(config?: BindingViteImportGlobPluginConfig): BuiltinPlugin;
declare function viteReporterPlugin(config: BindingViteReporterPluginConfig): BuiltinPlugin;
declare function viteLoadFallbackPlugin(): BuiltinPlugin;
declare function viteJsonPlugin(config: BindingViteJsonPluginConfig): BuiltinPlugin;
declare function viteBuildImportAnalysisPlugin(config: BindingViteBuildImportAnalysisPluginConfig): BuiltinPlugin;
declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, "yarnPnp">): BuiltinPlugin;
declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
declare function viteWebWorkerPostPlugin(): BuiltinPlugin;
/**
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
*
* @see https://rolldown.rs/builtin-plugins/esm-external-require
* @category Builtin Plugins
*/
declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
type ViteReactRefreshWrapperPluginConfig = Omit<BindingViteReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
include?: StringOrRegExp | StringOrRegExp[];
exclude?: StringOrRegExp | StringOrRegExp[];
};
/**
* This plugin should not be used for Rolldown.
*/
declare function oxcRuntimePlugin(): BuiltinPlugin;
declare function viteReactRefreshWrapperPlugin(config: ViteReactRefreshWrapperPluginConfig): BuiltinPlugin;
//#endregion
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWebWorkerPostPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };
import { a as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-dnh67V_w.mjs";
//#region src/builtin-plugin/constructors.ts
function viteModulePreloadPolyfillPlugin(config) {
return new BuiltinPlugin("builtin:vite-module-preload-polyfill", config);
}
function viteDynamicImportVarsPlugin(config) {
if (config) {
config.include = normalizedStringOrRegex(config.include);
config.exclude = normalizedStringOrRegex(config.exclude);
}
return new BuiltinPlugin("builtin:vite-dynamic-import-vars", config);
}
function viteImportGlobPlugin(config) {
return new BuiltinPlugin("builtin:vite-import-glob", config);
}
function viteReporterPlugin(config) {
return new BuiltinPlugin("builtin:vite-reporter", config);
}
function viteLoadFallbackPlugin() {
return new BuiltinPlugin("builtin:vite-load-fallback");
}
function viteJsonPlugin(config) {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-json", config));
}
function viteBuildImportAnalysisPlugin(config) {
return new BuiltinPlugin("builtin:vite-build-import-analysis", config);
}
function viteResolvePlugin(config) {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", {
...config,
yarnPnp: typeof process === "object" && !!process.versions?.pnp
}));
}
function isolatedDeclarationPlugin(config) {
return new BuiltinPlugin("builtin:isolated-declaration", config);
}
function viteWebWorkerPostPlugin() {
return new BuiltinPlugin("builtin:vite-web-worker-post");
}
/**
* A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
*
* @see https://rolldown.rs/builtin-plugins/esm-external-require
* @category Builtin Plugins
*/
function esmExternalRequirePlugin(config) {
const plugin = new BuiltinPlugin("builtin:esm-external-require", config);
plugin.enforce = "pre";
return plugin;
}
/**
* This plugin should not be used for Rolldown.
*/
function oxcRuntimePlugin() {
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:oxc-runtime"));
}
function viteReactRefreshWrapperPlugin(config) {
if (config) {
config.include = normalizedStringOrRegex(config.include);
config.exclude = normalizedStringOrRegex(config.exclude);
}
return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-react-refresh-wrapper", config));
}
//#endregion
export { viteDynamicImportVarsPlugin as a, viteLoadFallbackPlugin as c, viteReporterPlugin as d, viteResolvePlugin as f, viteBuildImportAnalysisPlugin as i, viteModulePreloadPolyfillPlugin as l, isolatedDeclarationPlugin as n, viteImportGlobPlugin as o, viteWebWorkerPostPlugin as p, oxcRuntimePlugin as r, viteJsonPlugin as s, esmExternalRequirePlugin as t, viteReactRefreshWrapperPlugin as u };

Sorry, the diff of this file is too big to display

import { t as require_binding } from "./binding-TuFFIE_J.mjs";
//#region src/types/sourcemap.ts
function bindingifySourcemap(map) {
if (map == null) return;
return { inner: typeof map === "string" ? map : {
file: map.file ?? void 0,
mappings: map.mappings,
sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
sources: map.sources?.map((s) => s ?? void 0),
sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
names: map.names,
x_google_ignoreList: map.x_google_ignoreList,
debugId: "debugId" in map ? map.debugId : void 0
} };
}
require_binding();
function unwrapBindingResult(container) {
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
return container;
}
function normalizeBindingResult(container) {
if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
return container;
}
function normalizeBindingError(e) {
return e.type === "JsError" ? e.field0 : Object.assign(/* @__PURE__ */ new Error(), {
code: e.field0.kind,
kind: e.field0.kind,
message: e.field0.message,
id: e.field0.id,
exporter: e.field0.exporter,
loc: e.field0.loc,
pos: e.field0.pos,
stack: void 0
});
}
function aggregateBindingErrorsIntoJsError(rawErrors) {
const errors = rawErrors.map(normalizeBindingError);
let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
for (let i = 0; i < errors.length; i++) {
summary += "\n";
if (i >= 5) {
summary += "...";
break;
}
summary += getErrorMessage(errors[i]);
}
const wrapper = new Error(summary);
Object.defineProperty(wrapper, "errors", {
configurable: true,
enumerable: true,
get: () => errors,
set: (value) => Object.defineProperty(wrapper, "errors", {
configurable: true,
enumerable: true,
value
})
});
return wrapper;
}
function getErrorMessage(e) {
if (Object.hasOwn(e, "kind")) return e.message;
let s = "";
if (e.plugin) s += `[plugin ${e.plugin}]`;
const id = e.id ?? e.loc?.file;
if (id) {
s += " " + id;
if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
}
if (s) s += "\n";
const message = `${e.name ?? "Error"}: ${e.message}`;
s += message;
if (e.frame) s = joinNewLine(s, e.frame);
if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
if (e.cause) {
s = joinNewLine(s, "Caused by:");
s = joinNewLine(s, getErrorMessage(e.cause).split("\n").map((line) => " " + line).join("\n"));
}
return s;
}
function joinNewLine(s1, s2) {
return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
}
//#endregion
export { bindingifySourcemap as a, unwrapBindingResult as i, normalizeBindingError as n, normalizeBindingResult as r, aggregateBindingErrorsIntoJsError as t };
import { a as RolldownLog } from "./logging-BSNejiLS.mjs";
//#region src/get-log-filter.d.ts
/**
* @param filters A list of log filters to apply
* @returns A function that tests whether a log should be output
*
* @category Config
*/
type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
/**
* A helper function to generate log filters using the same syntax as the CLI.
*
* @example
* ```ts
* import { defineConfig } from 'rolldown';
* import { getLogFilter } from 'rolldown/getLogFilter';
*
* const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
*
* export default defineConfig({
* input: 'main.js',
* onLog(level, log, handler) {
* if (logFilter(log)) {
* handler(level, log);
* }
* }
* });
* ```
*
* @category Config
*/
declare const getLogFilter: GetLogFilter;
//#endregion
export { getLogFilter as n, GetLogFilter as t };
import { t as rolldown } from "./rolldown-ChpIlMRm.mjs";
import fs from "node:fs";
import path from "node:path";
import { readdir } from "node:fs/promises";
import { cwd } from "node:process";
import { pathToFileURL } from "node:url";
//#region src/utils/load-config.ts
async function bundleTsConfig(configFile, isEsm) {
const dirnameVarName = "injected_original_dirname";
const filenameVarName = "injected_original_filename";
const importMetaUrlVarName = "injected_original_import_meta_url";
const bundle = await rolldown({
input: configFile,
platform: "node",
resolve: { mainFields: ["main"] },
transform: { define: {
__dirname: dirnameVarName,
__filename: filenameVarName,
"import.meta.url": importMetaUrlVarName,
"import.meta.dirname": dirnameVarName,
"import.meta.filename": filenameVarName
} },
treeshake: false,
external: [/^[\w@][^:]/],
plugins: [{
name: "inject-file-scope-variables",
transform: {
filter: { id: /\.[cm]?[jt]s$/ },
async handler(code, id) {
return {
code: `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};` + code,
map: null
};
}
}
}]
});
const outputDir = path.dirname(configFile);
const fileName = (await bundle.write({
dir: outputDir,
format: isEsm ? "esm" : "cjs",
sourcemap: "inline",
entryFileNames: `rolldown.config.[hash]${path.extname(configFile).replace("ts", "js")}`
})).output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
return path.join(outputDir, fileName);
}
const SUPPORTED_JS_CONFIG_FORMATS = [
".js",
".mjs",
".cjs"
];
const SUPPORTED_TS_CONFIG_FORMATS = [
".ts",
".mts",
".cts"
];
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
const DEFAULT_CONFIG_BASE = "rolldown.config";
async function findConfigFileNameInCwd() {
const filesInWorkingDirectory = new Set(await readdir(cwd()));
for (const extension of SUPPORTED_CONFIG_FORMATS) {
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
if (filesInWorkingDirectory.has(fileName)) return fileName;
}
throw new Error("No `rolldown.config` configuration file found.");
}
async function loadTsConfig(configFile) {
const file = await bundleTsConfig(configFile, isFilePathESM(configFile));
try {
return (await import(pathToFileURL(file).href)).default;
} finally {
fs.unlink(file, () => {});
}
}
function isFilePathESM(filePath) {
if (/\.m[jt]s$/.test(filePath)) return true;
else if (/\.c[jt]s$/.test(filePath)) return false;
else {
const pkg = findNearestPackageData(path.dirname(filePath));
if (pkg) return pkg.type === "module";
return false;
}
}
function findNearestPackageData(basedir) {
while (basedir) {
const pkgPath = path.join(basedir, "package.json");
if (tryStatSync(pkgPath)?.isFile()) try {
return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
} catch {}
const nextBasedir = path.dirname(basedir);
if (nextBasedir === basedir) break;
basedir = nextBasedir;
}
return null;
}
function tryStatSync(file) {
try {
return fs.statSync(file, { throwIfNoEntry: false });
} catch {}
}
async function loadNativeConfig(resolvedPath) {
const url = pathToFileURL(resolvedPath).href;
const { freshImport } = await import("./dist-DKbukT1H.mjs");
const freshImported = freshImport(url);
if (freshImported) {
const { result } = await freshImported;
return result.default;
}
return (await import(url + "?t=" + Date.now())).default;
}
/**
* Load config from a file in a way that Rolldown does.
*
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
* @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
* @returns The loaded config export
*
* @category Config
*/
async function loadConfig(configPath, options = {}) {
const configLoader = options.configLoader ?? "bundle";
const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
try {
if (configLoader === "native") return await loadNativeConfig(path.resolve(configPath));
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(path.resolve(configPath));
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
} catch (err) {
if (configLoader === "native") {
const tsHint = SUPPORTED_TS_CONFIG_FORMATS.includes(ext) && !process.features.typescript ? " This runtime does not natively support TypeScript config files." : "";
throw new Error(`Failed to load the config file "${configPath}" using the "native" config loader.${tsHint} Try "--configLoader bundle", or register a loader such as "--import tsx".`, { cause: err });
}
throw new Error("Error happened while loading config.", { cause: err });
}
}
//#endregion
export { loadConfig as t };
//#region src/log/logging.d.ts
/** @inline */
type LogLevel = "info" | "debug" | "warn";
/** @inline */
type LogLevelOption = LogLevel | "silent";
/** @inline */
type LogLevelWithError = LogLevel | "error";
interface RolldownLog {
binding?: string;
cause?: unknown;
/**
* The log code for this log object.
* @example 'PLUGIN_ERROR'
*/
code?: string;
exporter?: string;
frame?: string;
hook?: string;
id?: string;
ids?: string[];
loc?: {
column: number;
file?: string;
line: number;
};
/**
* The message for this log object.
* @example 'The "transform" hook used by the output plugin "rolldown-plugin-foo" is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.'
*/
message: string;
meta?: any;
names?: string[];
plugin?: string;
pluginCode?: unknown;
pos?: number;
reexporter?: string;
stack?: string;
url?: string;
}
/** @inline */
type RolldownLogWithString = RolldownLog | string;
/** @category Plugin APIs */
interface RolldownError extends RolldownLog {
name?: string;
stack?: string;
watchFiles?: string[];
}
type LogOrStringHandler = (level: LogLevelWithError, log: RolldownLogWithString) => void;
//#endregion
export { RolldownLog as a, RolldownError as i, LogLevelOption as n, RolldownLogWithString as o, LogOrStringHandler as r, LogLevel as t };
import { n as __toESM, t as require_binding } from "./binding-TuFFIE_J.mjs";
import { c as logPluginError, n as error } from "./logs-ZGEh6uhb.mjs";
//#region src/builtin-plugin/utils.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
var BuiltinPlugin = class {
name;
_options;
/** Vite-specific option to control plugin ordering */
enforce;
constructor(name, _options) {
this.name = name;
this._options = _options;
}
};
function makeBuiltinPluginCallable(plugin) {
let callablePlugin = new import_binding.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
const wrappedPlugin = plugin;
for (const key in callablePlugin) {
const wrappedHook = async function(...args) {
try {
return await callablePlugin[key](...args);
} catch (e) {
if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
return error(logPluginError(e, plugin.name, {
hook: key,
id: key === "transform" ? args[2] : void 0
}));
}
};
const order = callablePlugin.getOrder(key);
if (order == void 0) wrappedPlugin[key] = wrappedHook;
else wrappedPlugin[key] = {
handler: wrappedHook,
order
};
}
return wrappedPlugin;
}
function bindingifyBuiltInPlugin(plugin) {
return {
__name: plugin.name,
options: plugin._options
};
}
function bindingifyManifestPlugin(plugin, pluginContextData) {
const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
return {
__name: plugin.name,
options: {
...options,
isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
} : void 0
}
};
}
//#endregion
//#region src/utils/normalize-string-or-regex.ts
function normalizedStringOrRegex(pattern) {
if (!pattern) return;
if (!isReadonlyArray(pattern)) return [pattern];
return pattern;
}
function isReadonlyArray(input) {
return Array.isArray(input);
}
//#endregion
export { makeBuiltinPluginCallable as a, bindingifyManifestPlugin as i, BuiltinPlugin as n, bindingifyBuiltInPlugin as r, normalizedStringOrRegex as t };
import { n as __toESM, t as require_binding } from "./binding-TuFFIE_J.mjs";
//#region ../../node_modules/.pnpm/oxc-parser@0.139.0/node_modules/oxc-parser/src-js/wrap.js
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
function wrap(result) {
let program, module, comments, errors;
return {
get program() {
if (!program) program = jsonParseAst(result.program);
return program;
},
get module() {
if (!module) module = result.module;
return module;
},
get comments() {
if (!comments) comments = result.comments;
return comments;
},
get errors() {
if (!errors) errors = result.errors;
return errors;
}
};
}
function jsonParseAst(programJson) {
const { node: program, fixes } = JSON.parse(programJson);
for (const fixPath of fixes) applyFix(program, fixPath);
return program;
}
function applyFix(program, fixPath) {
let node = program;
for (const key of fixPath) node = node[key];
if (node.bigint) node.value = BigInt(node.bigint);
else try {
node.value = RegExp(node.regex.pattern, node.regex.flags);
} catch {}
}
//#endregion
//#region src/utils/parse.ts
/**
* Parse JS/TS source asynchronously on a separate thread.
*
* Note that not all of the workload can happen on a separate thread.
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
* has to happen on current thread. This synchronous deserialization work typically outweighs
* the asynchronous parsing by a factor of between 3 and 20.
*
* i.e. the majority of the workload cannot be parallelized by using this method.
*
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
*
* @category Utilities
*/
async function parse(filename, sourceText, options) {
return wrap(await (0, import_binding.parse)(filename, sourceText, options));
}
/**
* Parse JS/TS source synchronously on current thread.
*
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
* (see {@linkcode parse} documentation for details).
*
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
* with {@linkcode parseSync} rather than using {@linkcode parse}.
*
* @category Utilities
*/
function parseSync(filename, sourceText, options) {
return wrap((0, import_binding.parseSync)(filename, sourceText, options));
}
//#endregion
export { parseSync as n, parse as t };
import { n as __toESM, t as require_binding } from "./binding-TuFFIE_J.mjs";
import { a as bindingifySourcemap, n as normalizeBindingError } from "./error-BHRSI0R7.mjs";
//#region src/utils/minify.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
/**
* Minify asynchronously.
*
* Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
*
* @category Utilities
* @experimental
*/
async function minify(filename, sourceText, options) {
const inputMap = bindingifySourcemap(options?.inputMap);
const result = await (0, import_binding.minify)(filename, sourceText, options);
if (result.map && inputMap) result.map = {
version: 3,
...(0, import_binding.collapseSourcemaps)([inputMap, bindingifySourcemap(result.map)])
};
return result;
}
/**
* Minify synchronously.
*
* @category Utilities
* @experimental
*/
function minifySync(filename, sourceText, options) {
const inputMap = bindingifySourcemap(options?.inputMap);
const result = (0, import_binding.minifySync)(filename, sourceText, options);
if (result.map && inputMap) result.map = {
version: 3,
...(0, import_binding.collapseSourcemaps)([inputMap, bindingifySourcemap(result.map)])
};
return result;
}
//#endregion
//#region src/utils/transform.ts
const yarnPnp$1 = typeof process === "object" && !!process.versions?.pnp;
function normalizeBindingWarning(warning) {
if (warning.type === "JsError") return warning.field0;
return {
code: warning.field0.kind,
message: warning.field0.message,
id: warning.field0.id,
exporter: warning.field0.exporter,
loc: warning.field0.loc,
pos: warning.field0.pos
};
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
*
* Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns a promise that resolves to an object containing the transformed code,
* source maps, and any errors that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
async function transform(filename, sourceText, options, cache) {
const result = await (0, import_binding.enhancedTransform)(filename, sourceText, options, cache, yarnPnp$1);
return {
...result,
errors: result.errors.map(normalizeBindingError),
warnings: result.warnings.map(normalizeBindingWarning)
};
}
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns an object containing the transformed code, source maps, and any errors
* that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
function transformSync(filename, sourceText, options, cache) {
const result = (0, import_binding.enhancedTransformSync)(filename, sourceText, options, cache, yarnPnp$1);
return {
...result,
errors: result.errors.map(normalizeBindingError),
warnings: result.warnings.map(normalizeBindingWarning)
};
}
//#endregion
//#region src/utils/resolve-tsconfig.ts
const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
/**
* Cache for tsconfig resolution to avoid redundant file system operations.
*
* The cache stores resolved tsconfig configurations keyed by their file paths.
* When transforming multiple files in the same project, tsconfig lookups are
* deduplicated, improving performance.
*
* @category Utilities
* @experimental
*/
var TsconfigCache = class extends import_binding.TsconfigCache {
constructor() {
super(yarnPnp);
}
};
/** @hidden This is only expected to be used by Vite */
function resolveTsconfig(filename, cache) {
return (0, import_binding.resolveTsconfig)(filename, cache, yarnPnp);
}
//#endregion
export { minify as a, transformSync as i, resolveTsconfig as n, minifySync as o, transform as r, TsconfigCache as t };

Sorry, the diff of this file is too big to display

import { c as validateOption, t as RolldownBuild, u as PluginDriver } from "./rolldown-build-CtPvmZgJ.mjs";
//#region src/api/rolldown/index.ts
/**
* The API compatible with Rollup's `rollup` function.
*
* Unlike Rollup, the module graph is not built until the methods of the bundle object are called.
*
* @param input The input options object.
* @returns A Promise that resolves to a bundle object.
*
* @example
* ```js
* import { rolldown } from 'rolldown';
*
* let bundle, failed = false;
* try {
* bundle = await rolldown({
* input: 'src/main.js',
* });
* await bundle.write({
* format: 'esm',
* });
* } catch (e) {
* console.error(e);
* failed = true;
* }
* if (bundle) {
* await bundle.close();
* }
* process.exitCode = failed ? 1 : 0;
* ```
*
* @category Programmatic APIs
*/
const rolldown = async (input) => {
validateOption("input", input);
return new RolldownBuild(await PluginDriver.callOptionsHook(input));
};
//#endregion
export { rolldown as t };
import { a as RolldownLog } from "./logging-BSNejiLS.mjs";
import { F as MinifyResult$1, H as SourceMap, L as ParseResult$1, P as MinifyOptions$1, R as ParserOptions$1, W as TsconfigCache$1, a as BindingEnhancedTransformOptions, o as BindingEnhancedTransformResult, v as BindingTsconfigResult } from "./binding-D26QphWG.mjs";
//#region src/utils/resolve-tsconfig.d.ts
/**
* Cache for tsconfig resolution to avoid redundant file system operations.
*
* The cache stores resolved tsconfig configurations keyed by their file paths.
* When transforming multiple files in the same project, tsconfig lookups are
* deduplicated, improving performance.
*
* @category Utilities
* @experimental
*/
declare class TsconfigCache extends TsconfigCache$1 {
constructor();
}
/** @hidden This is only expected to be used by Vite */
declare function resolveTsconfig(filename: string, cache?: TsconfigCache | null): BindingTsconfigResult | null;
//#endregion
//#region src/utils/parse.d.ts
/**
* Result of parsing a code
*
* @category Utilities
*/
interface ParseResult extends ParseResult$1 {}
/**
* Options for parsing a code
*
* @category Utilities
*/
interface ParserOptions extends ParserOptions$1 {}
/**
* Parse JS/TS source asynchronously on a separate thread.
*
* Note that not all of the workload can happen on a separate thread.
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
* has to happen on current thread. This synchronous deserialization work typically outweighs
* the asynchronous parsing by a factor of between 3 and 20.
*
* i.e. the majority of the workload cannot be parallelized by using this method.
*
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
*
* @category Utilities
*/
declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
/**
* Parse JS/TS source synchronously on current thread.
*
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
* (see {@linkcode parse} documentation for details).
*
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
* with {@linkcode parseSync} rather than using {@linkcode parse}.
*
* @category Utilities
*/
declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
//#endregion
//#region src/utils/minify.d.ts
/**
* Options for minification.
*
* @category Utilities
*/
interface MinifyOptions extends MinifyOptions$1 {
inputMap?: SourceMap;
}
/**
* The result of minification.
*
* @category Utilities
*/
interface MinifyResult extends MinifyResult$1 {}
/**
* Minify asynchronously.
*
* Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
*
* @category Utilities
* @experimental
*/
declare function minify(filename: string, sourceText: string, options?: MinifyOptions | null): Promise<MinifyResult>;
/**
* Minify synchronously.
*
* @category Utilities
* @experimental
*/
declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | null): MinifyResult;
//#endregion
//#region src/utils/transform.d.ts
/**
* Options for transforming a code.
*
* @category Utilities
*/
interface TransformOptions extends BindingEnhancedTransformOptions {}
/**
* Result of transforming a code.
*
* @category Utilities
*/
type TransformResult = Omit<BindingEnhancedTransformResult, "errors" | "warnings"> & {
errors: Error[];
warnings: RolldownLog[];
};
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
*
* Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns a promise that resolves to an object containing the transformed code,
* source maps, and any errors that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
declare function transform(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): Promise<TransformResult>;
/**
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
*
* @param filename The name of the file being transformed. If this is a
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
* @param sourceText The source code to transform.
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
* Only used when `options.tsconfig` is `true`.
*
* @returns an object containing the transformed code, source maps, and any errors
* that occurred during parsing or transformation.
*
* @category Utilities
* @experimental
*/
declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): TransformResult;
//#endregion
export { MinifyOptions as a, minifySync as c, parse as d, parseSync as f, transformSync as i, ParseResult as l, resolveTsconfig as m, TransformResult as n, MinifyResult as o, TsconfigCache as p, transform as r, minify as s, TransformOptions as t, ParserOptions as u };
import { n as __toESM, t as require_binding } from "./binding-TuFFIE_J.mjs";
import { o as logMultipleWatcherOption } from "./logs-ZGEh6uhb.mjs";
import { v as LOG_LEVEL_WARN } from "./bindingify-input-options-XPJLJOD0.mjs";
import { t as arraify } from "./misc-CoQm4NHO.mjs";
import { n as createBundlerOptions, u as PluginDriver } from "./rolldown-build-CtPvmZgJ.mjs";
import { t as aggregateBindingErrorsIntoJsError } from "./error-BHRSI0R7.mjs";
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
/**
* This is not the set of all possible signals.
*
* It IS, however, the set of all signals that trigger
* an exit on either Linux or BSD systems. Linux is a
* superset of the signal names supported on BSD, and
* the unknown signals just fail to register, so we can
* catch that easily enough.
*
* Windows signals are a different set, since there are
* signals that terminate Windows processes, but don't
* terminate (or don't even exist) on Posix systems.
*
* Don't bother with SIGKILL. It's uncatchable, which
* means that we can't fire any callbacks anyway.
*
* If a user does happen to register a handler on a non-
* fatal signal like SIGWINCH or something, and then
* exit, it'll end up firing `process.emit('exit')`, so
* the handler will be fired anyway.
*
* SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised
* artificially, inherently leave the process in a
* state from which it is not safe to try and enter JS
* listeners.
*/
const signals = [];
signals.push("SIGHUP", "SIGINT", "SIGTERM");
if (process.platform !== "win32") signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
if (process.platform === "linux") signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
//#endregion
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/index.js
const processOk = (process) => !!process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
const kExitEmitter = Symbol.for("signal-exit emitter");
const global = globalThis;
const ObjectDefineProperty = Object.defineProperty.bind(Object);
var Emitter = class {
emitted = {
afterExit: false,
exit: false
};
listeners = {
afterExit: [],
exit: []
};
count = 0;
id = Math.random();
constructor() {
if (global[kExitEmitter]) return global[kExitEmitter];
ObjectDefineProperty(global, kExitEmitter, {
value: this,
writable: false,
enumerable: false,
configurable: false
});
}
on(ev, fn) {
this.listeners[ev].push(fn);
}
removeListener(ev, fn) {
const list = this.listeners[ev];
const i = list.indexOf(fn);
/* c8 ignore start */
if (i === -1) return;
/* c8 ignore stop */
if (i === 0 && list.length === 1) list.length = 0;
else list.splice(i, 1);
}
emit(ev, code, signal) {
if (this.emitted[ev]) return false;
this.emitted[ev] = true;
let ret = false;
for (const fn of this.listeners[ev]) ret = fn(code, signal) === true || ret;
if (ev === "exit") ret = this.emit("afterExit", code, signal) || ret;
return ret;
}
};
var SignalExitBase = class {};
const signalExitWrap = (handler) => {
return {
onExit(cb, opts) {
return handler.onExit(cb, opts);
},
load() {
return handler.load();
},
unload() {
return handler.unload();
}
};
};
var SignalExitFallback = class extends SignalExitBase {
onExit() {
return () => {};
}
load() {}
unload() {}
};
var SignalExit = class extends SignalExitBase {
/* c8 ignore start */
#hupSig = process$1.platform === "win32" ? "SIGINT" : "SIGHUP";
/* c8 ignore stop */
#emitter = new Emitter();
#process;
#originalProcessEmit;
#originalProcessReallyExit;
#sigListeners = {};
#loaded = false;
constructor(process) {
super();
this.#process = process;
this.#sigListeners = {};
for (const sig of signals) this.#sigListeners[sig] = () => {
const listeners = this.#process.listeners(sig);
let { count } = this.#emitter;
/* c8 ignore start */
const p = process;
if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") count += p.__signal_exit_emitter__.count;
/* c8 ignore stop */
if (listeners.length === count) {
this.unload();
const ret = this.#emitter.emit("exit", null, sig);
/* c8 ignore start */
const s = sig === "SIGHUP" ? this.#hupSig : sig;
if (!ret) process.kill(process.pid, s);
}
};
this.#originalProcessReallyExit = process.reallyExit;
this.#originalProcessEmit = process.emit;
}
onExit(cb, opts) {
/* c8 ignore start */
if (!processOk(this.#process)) return () => {};
/* c8 ignore stop */
if (this.#loaded === false) this.load();
const ev = opts?.alwaysLast ? "afterExit" : "exit";
this.#emitter.on(ev, cb);
return () => {
this.#emitter.removeListener(ev, cb);
if (this.#emitter.listeners["exit"].length === 0 && this.#emitter.listeners["afterExit"].length === 0) this.unload();
};
}
load() {
if (this.#loaded) return;
this.#loaded = true;
this.#emitter.count += 1;
for (const sig of signals) try {
const fn = this.#sigListeners[sig];
if (fn) this.#process.on(sig, fn);
} catch (_) {}
this.#process.emit = (ev, ...a) => {
return this.#processEmit(ev, ...a);
};
this.#process.reallyExit = (code) => {
return this.#processReallyExit(code);
};
}
unload() {
if (!this.#loaded) return;
this.#loaded = false;
signals.forEach((sig) => {
const listener = this.#sigListeners[sig];
/* c8 ignore start */
if (!listener) throw new Error("Listener not defined for signal: " + sig);
/* c8 ignore stop */
try {
this.#process.removeListener(sig, listener);
} catch (_) {}
/* c8 ignore stop */
});
this.#process.emit = this.#originalProcessEmit;
this.#process.reallyExit = this.#originalProcessReallyExit;
this.#emitter.count -= 1;
}
#processReallyExit(code) {
/* c8 ignore start */
if (!processOk(this.#process)) return 0;
this.#process.exitCode = code || 0;
/* c8 ignore stop */
this.#emitter.emit("exit", this.#process.exitCode, null);
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
}
#processEmit(ev, ...args) {
const og = this.#originalProcessEmit;
if (ev === "exit" && processOk(this.#process)) {
if (typeof args[0] === "number") this.#process.exitCode = args[0];
/* c8 ignore start */
const ret = og.call(this.#process, ev, ...args);
/* c8 ignore start */
this.#emitter.emit("exit", this.#process.exitCode, null);
/* c8 ignore stop */
return ret;
} else return og.call(this.#process, ev, ...args);
}
};
const process$1 = globalThis.process;
const { onExit: onExit$1, load, unload } = signalExitWrap(processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback());
//#endregion
//#region src/utils/signal-exit.ts
function onExit(...args) {
if (typeof process === "object" && process.versions.webcontainer) {
process.on("exit", (code) => {
args[0](code, null);
});
return;
}
onExit$1(...args);
}
//#endregion
//#region src/api/watch/watch-emitter.ts
var WatcherEmitter = class {
listeners = /* @__PURE__ */ new Map();
on(event, listener) {
const listeners = this.listeners.get(event);
if (listeners) listeners.push(listener);
else this.listeners.set(event, [listener]);
return this;
}
off(event, listener) {
const listeners = this.listeners.get(event);
if (listeners) {
const index = listeners.indexOf(listener);
if (index !== -1) listeners.splice(index, 1);
}
return this;
}
clear(event) {
this.listeners.delete(event);
}
/** Async emit — sequential dispatch so side effects from earlier handlers
* (e.g. `event.result.close()` triggering `closeBundle`) are visible to later handlers. */
async emit(event, ...args) {
const handlers = this.listeners.get(event);
if (handlers?.length) for (const h of handlers) await h(...args);
}
async close() {}
};
//#endregion
//#region src/api/watch/watcher.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
function createEventCallback(emitter) {
return async (event) => {
switch (event.eventKind()) {
case "event": {
const code = event.bundleEventKind();
if (code === "BUNDLE_END") {
const { duration, output, result } = event.bundleEndData();
await emitter.emit("event", {
code: "BUNDLE_END",
duration,
output: [output],
result
});
} else if (code === "ERROR") {
const data = event.bundleErrorData();
await emitter.emit("event", {
code: "ERROR",
error: aggregateBindingErrorsIntoJsError(data.error),
result: data.result
});
} else await emitter.emit("event", { code });
break;
}
case "change": {
const { path, kind } = event.watchChangeData();
await emitter.emit("change", path, { event: kind });
break;
}
case "restart":
await emitter.emit("restart");
break;
case "close":
await emitter.emit("close");
break;
}
};
}
var Watcher = class {
closed;
inner;
emitter;
stopWorkers;
constructor(emitter, inner, stopWorkers) {
this.closed = false;
this.inner = inner;
this.emitter = emitter;
const originClose = emitter.close.bind(emitter);
emitter.close = async () => {
await this.close();
originClose();
};
this.stopWorkers = stopWorkers;
process.nextTick(() => this.run());
}
async close() {
if (this.closed) return;
this.closed = true;
for (const stop of this.stopWorkers) await stop?.();
await this.inner.close();
(0, import_binding.shutdownAsyncRuntime)();
}
async run() {
await this.inner.run();
this.inner.waitForClose();
}
};
async function createWatcher(emitter, input) {
const options = arraify(input);
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
})).flat());
warnMultiplePollingOptions(bundlerOptions);
const callback = createEventCallback(emitter);
new Watcher(emitter, new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), callback), bundlerOptions.map((option) => option.stopWorkers));
}
function warnMultiplePollingOptions(bundlerOptions) {
let found = false;
for (const option of bundlerOptions) {
const watch = option.inputOptions.watch;
const watcher = watch && typeof watch === "object" ? watch.watcher ?? watch.notify : void 0;
if (watcher && (watcher.usePolling != null || watcher.pollInterval != null)) {
if (found) {
option.onLog(LOG_LEVEL_WARN, logMultipleWatcherOption());
return;
}
found = true;
}
}
}
//#endregion
//#region src/api/watch/index.ts
/**
* The API compatible with Rollup's `watch` function.
*
* This function will rebuild the bundle when it detects that the individual modules have changed on disk.
*
* Note that when using this function, it is your responsibility to call `event.result.close()` in response to the `BUNDLE_END` event to avoid resource leaks.
*
* @param input The watch options object or the list of them.
* @returns A watcher object.
*
* @example
* ```js
* import { watch } from 'rolldown';
*
* const watcher = watch({ /* ... *\/ });
* watcher.on('event', (event) => {
* if (event.code === 'BUNDLE_END') {
* console.log(event.duration);
* event.result.close();
* }
* });
*
* // Stop watching
* watcher.close();
* ```
*
* @experimental
* @category Programmatic APIs
*/
function watch(input) {
const emitter = new WatcherEmitter();
createWatcher(emitter, input);
return emitter;
}
//#endregion
export { onExit as n, watch as t };

Sorry, the diff of this file is too big to display