@rspack/core
Version:
The fast Rust-based web bundler with webpack-compatible API
1,634 lines (1,616 loc) • 697 kB
JavaScript
"use strict";
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 __typeError = (msg) => {
throw TypeError(msg);
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target2, all) => {
for (var name2 in all)
__defProp(target2, name2, { get: all[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter2) => (__accessCheck(obj, member, "read from private field"), getter2 ? getter2.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
// ../../node_modules/.pnpm/json-parse-even-better-errors@3.0.2/node_modules/json-parse-even-better-errors/lib/index.js
var require_lib = __commonJS({
"../../node_modules/.pnpm/json-parse-even-better-errors@3.0.2/node_modules/json-parse-even-better-errors/lib/index.js"(exports2, module2) {
"use strict";
var INDENT = Symbol.for("indent");
var NEWLINE = Symbol.for("newline");
var DEFAULT_NEWLINE = "\n";
var DEFAULT_INDENT = " ";
var BOM = /^\uFEFF/;
var FORMAT = /^\s*[{[]((?:\r?\n)+)([\s\t]*)/;
var EMPTY = /^(?:\{\}|\[\])((?:\r?\n)+)?$/;
var UNEXPECTED_TOKEN = /^Unexpected token '?(.)'?(,)? /i;
var hexify = (char) => {
const h = char.charCodeAt(0).toString(16).toUpperCase();
return `0x${h.length % 2 ? "0" : ""}${h}`;
};
var stripBOM = (txt) => String(txt).replace(BOM, "");
var makeParsedError = (msg, parsing, position = 0) => ({
message: `${msg} while parsing ${parsing}`,
position
});
var parseError = (e, txt, context2 = 20) => {
let msg = e.message;
if (!txt) {
return makeParsedError(msg, "empty string");
}
const badTokenMatch = msg.match(UNEXPECTED_TOKEN);
const badIndexMatch = msg.match(/ position\s+(\d+)/i);
if (badTokenMatch) {
msg = msg.replace(
UNEXPECTED_TOKEN,
`Unexpected token ${JSON.stringify(badTokenMatch[1])} (${hexify(badTokenMatch[1])})$2 `
);
}
let errIdx;
if (badIndexMatch) {
errIdx = +badIndexMatch[1];
} else if (msg.match(/^Unexpected end of JSON.*/i)) {
errIdx = txt.length - 1;
}
if (errIdx == null) {
return makeParsedError(msg, `'${txt.slice(0, context2 * 2)}'`);
}
const start = errIdx <= context2 ? 0 : errIdx - context2;
const end = errIdx + context2 >= txt.length ? txt.length : errIdx + context2;
const slice = `${start ? "..." : ""}${txt.slice(start, end)}${end === txt.length ? "" : "..."}`;
return makeParsedError(
msg,
`${txt === slice ? "" : "near "}${JSON.stringify(slice)}`,
errIdx
);
};
var JSONParseError = class extends SyntaxError {
constructor(er, txt, context2, caller) {
const metadata = parseError(er, txt, context2);
super(metadata.message);
Object.assign(this, metadata);
this.code = "EJSONPARSE";
this.systemError = er;
Error.captureStackTrace(this, caller || this.constructor);
}
get name() {
return this.constructor.name;
}
set name(n) {
}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
};
var parseJson = (txt, reviver) => {
const result2 = JSON.parse(txt, reviver);
if (result2 && typeof result2 === "object") {
const match = txt.match(EMPTY) || txt.match(FORMAT) || [null, "", ""];
result2[NEWLINE] = match[1] ?? DEFAULT_NEWLINE;
result2[INDENT] = match[2] ?? DEFAULT_INDENT;
}
return result2;
};
var parseJsonError = (raw, reviver, context2) => {
const txt = stripBOM(raw);
try {
return parseJson(txt, reviver);
} catch (e) {
if (typeof raw !== "string" && !Buffer.isBuffer(raw)) {
const msg = Array.isArray(raw) && raw.length === 0 ? "an empty array" : String(raw);
throw Object.assign(
new TypeError(`Cannot parse ${msg}`),
{ code: "EJSONPARSE", systemError: e }
);
}
throw new JSONParseError(e, txt, context2, parseJsonError);
}
};
module2.exports = parseJsonError;
parseJsonError.JSONParseError = JSONParseError;
parseJsonError.noExceptions = (raw, reviver) => {
try {
return parseJson(stripBOM(raw), reviver);
} catch {
}
};
}
});
// ../../node_modules/.pnpm/enhanced-resolve@5.18.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js
var require_CachedInputFileSystem = __commonJS({
"../../node_modules/.pnpm/enhanced-resolve@5.18.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js"(exports2, module2) {
"use strict";
var nextTick = require("process").nextTick;
var dirname4 = (path11) => {
let idx = path11.length - 1;
while (idx >= 0) {
const c = path11.charCodeAt(idx);
if (c === 47 || c === 92) break;
idx--;
}
if (idx < 0) return "";
return path11.slice(0, idx);
};
var runCallbacks = (callbacks, err, result2) => {
if (callbacks.length === 1) {
callbacks[0](err, result2);
callbacks.length = 0;
return;
}
let error;
for (const callback of callbacks) {
try {
callback(err, result2);
} catch (e) {
if (!error) error = e;
}
}
callbacks.length = 0;
if (error) throw error;
};
var OperationMergerBackend = class {
/**
* @param {Function | undefined} provider async method in filesystem
* @param {Function | undefined} syncProvider sync method in filesystem
* @param {BaseFileSystem} providerContext call context for the provider methods
*/
constructor(provider, syncProvider, providerContext) {
this._provider = provider;
this._syncProvider = syncProvider;
this._providerContext = providerContext;
this._activeAsyncOperations = /* @__PURE__ */ new Map();
this.provide = this._provider ? (
/**
* @param {PathLike | PathOrFileDescriptor} path path
* @param {object | FileSystemCallback<any> | undefined} options options
* @param {FileSystemCallback<any>=} callback callback
* @returns {any} result
*/
(path11, options, callback) => {
if (typeof options === "function") {
callback = /** @type {FileSystemCallback<any>} */
options;
options = void 0;
}
if (typeof path11 !== "string" && !Buffer.isBuffer(path11) && !(path11 instanceof URL) && typeof path11 !== "number") {
callback(
new TypeError("path must be a string, Buffer, URL or number")
);
return;
}
if (options) {
return (
/** @type {Function} */
this._provider.call(
this._providerContext,
path11,
options,
callback
)
);
}
let callbacks = this._activeAsyncOperations.get(path11);
if (callbacks) {
callbacks.push(callback);
return;
}
this._activeAsyncOperations.set(path11, callbacks = [callback]);
provider(
path11,
/**
* @param {Error} err error
* @param {any} result result
*/
(err, result2) => {
this._activeAsyncOperations.delete(path11);
runCallbacks(callbacks, err, result2);
}
);
}
) : null;
this.provideSync = this._syncProvider ? (
/**
* @param {PathLike | PathOrFileDescriptor} path path
* @param {object=} options options
* @returns {any} result
*/
(path11, options) => {
return (
/** @type {Function} */
this._syncProvider.call(
this._providerContext,
path11,
options
)
);
}
) : null;
}
purge() {
}
purgeParent() {
}
};
var STORAGE_MODE_IDLE = 0;
var STORAGE_MODE_SYNC = 1;
var STORAGE_MODE_ASYNC = 2;
var CacheBackend = class {
/**
* @param {number} duration max cache duration of items
* @param {function | undefined} provider async method
* @param {function | undefined} syncProvider sync method
* @param {BaseFileSystem} providerContext call context for the provider methods
*/
constructor(duration, provider, syncProvider, providerContext) {
this._duration = duration;
this._provider = provider;
this._syncProvider = syncProvider;
this._providerContext = providerContext;
this._activeAsyncOperations = /* @__PURE__ */ new Map();
this._data = /* @__PURE__ */ new Map();
this._levels = [];
for (let i = 0; i < 10; i++) this._levels.push(/* @__PURE__ */ new Set());
for (let i = 5e3; i < duration; i += 500) this._levels.push(/* @__PURE__ */ new Set());
this._currentLevel = 0;
this._tickInterval = Math.floor(duration / this._levels.length);
this._mode = STORAGE_MODE_IDLE;
this._timeout = void 0;
this._nextDecay = void 0;
this.provide = provider ? this.provide.bind(this) : null;
this.provideSync = syncProvider ? this.provideSync.bind(this) : null;
}
/**
* @param {PathLike | PathOrFileDescriptor} path path
* @param {any} options options
* @param {FileSystemCallback<any>} callback callback
* @returns {void}
*/
provide(path11, options, callback) {
if (typeof options === "function") {
callback = options;
options = void 0;
}
if (typeof path11 !== "string" && !Buffer.isBuffer(path11) && !(path11 instanceof URL) && typeof path11 !== "number") {
callback(new TypeError("path must be a string, Buffer, URL or number"));
return;
}
const strPath = typeof path11 !== "string" ? path11.toString() : path11;
if (options) {
return (
/** @type {Function} */
this._provider.call(
this._providerContext,
path11,
options,
callback
)
);
}
if (this._mode === STORAGE_MODE_SYNC) {
this._enterAsyncMode();
}
let cacheEntry = this._data.get(strPath);
if (cacheEntry !== void 0) {
if (cacheEntry.err) return nextTick(callback, cacheEntry.err);
return nextTick(callback, null, cacheEntry.result);
}
let callbacks = this._activeAsyncOperations.get(strPath);
if (callbacks !== void 0) {
callbacks.push(callback);
return;
}
this._activeAsyncOperations.set(strPath, callbacks = [callback]);
this._provider.call(
this._providerContext,
path11,
/**
* @param {Error | null} err error
* @param {any} [result] result
*/
(err, result2) => {
this._activeAsyncOperations.delete(strPath);
this._storeResult(strPath, err, result2);
this._enterAsyncMode();
runCallbacks(
/** @type {FileSystemCallback<any>[]} */
callbacks,
err,
result2
);
}
);
}
/**
* @param {PathLike | PathOrFileDescriptor} path path
* @param {any} options options
* @returns {any} result
*/
provideSync(path11, options) {
if (typeof path11 !== "string" && !Buffer.isBuffer(path11) && !(path11 instanceof URL) && typeof path11 !== "number") {
throw new TypeError("path must be a string");
}
const strPath = typeof path11 !== "string" ? path11.toString() : path11;
if (options) {
return (
/** @type {Function} */
this._syncProvider.call(
this._providerContext,
path11,
options
)
);
}
if (this._mode === STORAGE_MODE_SYNC) {
this._runDecays();
}
let cacheEntry = this._data.get(strPath);
if (cacheEntry !== void 0) {
if (cacheEntry.err) throw cacheEntry.err;
return cacheEntry.result;
}
const callbacks = this._activeAsyncOperations.get(strPath);
this._activeAsyncOperations.delete(strPath);
let result2;
try {
result2 = /** @type {Function} */
this._syncProvider.call(
this._providerContext,
path11
);
} catch (err) {
this._storeResult(
strPath,
/** @type {Error} */
err,
void 0
);
this._enterSyncModeWhenIdle();
if (callbacks) {
runCallbacks(
callbacks,
/** @type {Error} */
err,
void 0
);
}
throw err;
}
this._storeResult(strPath, null, result2);
this._enterSyncModeWhenIdle();
if (callbacks) {
runCallbacks(callbacks, null, result2);
}
return result2;
}
/**
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
*/
purge(what) {
if (!what) {
if (this._mode !== STORAGE_MODE_IDLE) {
this._data.clear();
for (const level of this._levels) {
level.clear();
}
this._enterIdleMode();
}
} else if (typeof what === "string" || Buffer.isBuffer(what) || what instanceof URL || typeof what === "number") {
const strWhat = typeof what !== "string" ? what.toString() : what;
for (let [key, data] of this._data) {
if (key.startsWith(strWhat)) {
this._data.delete(key);
data.level.delete(key);
}
}
if (this._data.size === 0) {
this._enterIdleMode();
}
} else {
for (let [key, data] of this._data) {
for (const item of what) {
const strItem = typeof item !== "string" ? item.toString() : item;
if (key.startsWith(strItem)) {
this._data.delete(key);
data.level.delete(key);
break;
}
}
}
if (this._data.size === 0) {
this._enterIdleMode();
}
}
}
/**
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
*/
purgeParent(what) {
if (!what) {
this.purge();
} else if (typeof what === "string" || Buffer.isBuffer(what) || what instanceof URL || typeof what === "number") {
const strWhat = typeof what !== "string" ? what.toString() : what;
this.purge(dirname4(strWhat));
} else {
const set = /* @__PURE__ */ new Set();
for (const item of what) {
const strItem = typeof item !== "string" ? item.toString() : item;
set.add(dirname4(strItem));
}
this.purge(set);
}
}
/**
* @param {string} path path
* @param {Error | null} err error
* @param {any} result result
*/
_storeResult(path11, err, result2) {
if (this._data.has(path11)) return;
const level = this._levels[this._currentLevel];
this._data.set(path11, { err, result: result2, level });
level.add(path11);
}
_decayLevel() {
const nextLevel = (this._currentLevel + 1) % this._levels.length;
const decay = this._levels[nextLevel];
this._currentLevel = nextLevel;
for (let item of decay) {
this._data.delete(item);
}
decay.clear();
if (this._data.size === 0) {
this._enterIdleMode();
} else {
this._nextDecay += this._tickInterval;
}
}
_runDecays() {
while (
/** @type {number} */
this._nextDecay <= Date.now() && this._mode !== STORAGE_MODE_IDLE
) {
this._decayLevel();
}
}
_enterAsyncMode() {
let timeout = 0;
switch (this._mode) {
case STORAGE_MODE_ASYNC:
return;
case STORAGE_MODE_IDLE:
this._nextDecay = Date.now() + this._tickInterval;
timeout = this._tickInterval;
break;
case STORAGE_MODE_SYNC:
this._runDecays();
if (
/** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC}*/
this._mode === STORAGE_MODE_IDLE
)
return;
timeout = Math.max(
0,
/** @type {number} */
this._nextDecay - Date.now()
);
break;
}
this._mode = STORAGE_MODE_ASYNC;
const ref = setTimeout(() => {
this._mode = STORAGE_MODE_SYNC;
this._runDecays();
}, timeout);
if (ref.unref) ref.unref();
this._timeout = ref;
}
_enterSyncModeWhenIdle() {
if (this._mode === STORAGE_MODE_IDLE) {
this._mode = STORAGE_MODE_SYNC;
this._nextDecay = Date.now() + this._tickInterval;
}
}
_enterIdleMode() {
this._mode = STORAGE_MODE_IDLE;
this._nextDecay = void 0;
if (this._timeout) clearTimeout(this._timeout);
}
};
var createBackend = (duration, provider, syncProvider, providerContext) => {
if (duration > 0) {
return new CacheBackend(duration, provider, syncProvider, providerContext);
}
return new OperationMergerBackend(provider, syncProvider, providerContext);
};
module2.exports = class CachedInputFileSystem {
/**
* @param {BaseFileSystem} fileSystem file system
* @param {number} duration duration in ms files are cached
*/
constructor(fileSystem, duration) {
this.fileSystem = fileSystem;
this._lstatBackend = createBackend(
duration,
this.fileSystem.lstat,
this.fileSystem.lstatSync,
this.fileSystem
);
const lstat = this._lstatBackend.provide;
this.lstat = /** @type {FileSystem["lstat"]} */
lstat;
const lstatSync = this._lstatBackend.provideSync;
this.lstatSync = /** @type {SyncFileSystem["lstatSync"]} */
lstatSync;
this._statBackend = createBackend(
duration,
this.fileSystem.stat,
this.fileSystem.statSync,
this.fileSystem
);
const stat = this._statBackend.provide;
this.stat = /** @type {FileSystem["stat"]} */
stat;
const statSync = this._statBackend.provideSync;
this.statSync = /** @type {SyncFileSystem["statSync"]} */
statSync;
this._readdirBackend = createBackend(
duration,
this.fileSystem.readdir,
this.fileSystem.readdirSync,
this.fileSystem
);
const readdir = this._readdirBackend.provide;
this.readdir = /** @type {FileSystem["readdir"]} */
readdir;
const readdirSync2 = this._readdirBackend.provideSync;
this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */
readdirSync2;
this._readFileBackend = createBackend(
duration,
this.fileSystem.readFile,
this.fileSystem.readFileSync,
this.fileSystem
);
const readFile = this._readFileBackend.provide;
this.readFile = /** @type {FileSystem["readFile"]} */
readFile;
const readFileSync3 = this._readFileBackend.provideSync;
this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */
readFileSync3;
this._readJsonBackend = createBackend(
duration,
// prettier-ignore
this.fileSystem.readJson || this.readFile && /**
* @param {string} path path
* @param {FileSystemCallback<any>} callback
*/
((path11, callback) => {
this.readFile(path11, (err, buffer) => {
if (err) return callback(err);
if (!buffer || buffer.length === 0)
return callback(new Error("No file content"));
let data;
try {
data = JSON.parse(buffer.toString("utf-8"));
} catch (e) {
return callback(
/** @type {Error} */
e
);
}
callback(null, data);
});
}),
// prettier-ignore
this.fileSystem.readJsonSync || this.readFileSync && /**
* @param {string} path path
* @returns {any} result
*/
((path11) => {
const buffer = this.readFileSync(path11);
const data = JSON.parse(buffer.toString("utf-8"));
return data;
}),
this.fileSystem
);
const readJson = this._readJsonBackend.provide;
this.readJson = /** @type {FileSystem["readJson"]} */
readJson;
const readJsonSync = this._readJsonBackend.provideSync;
this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */
readJsonSync;
this._readlinkBackend = createBackend(
duration,
this.fileSystem.readlink,
this.fileSystem.readlinkSync,
this.fileSystem
);
const readlink = this._readlinkBackend.provide;
this.readlink = /** @type {FileSystem["readlink"]} */
readlink;
const readlinkSync = this._readlinkBackend.provideSync;
this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */
readlinkSync;
this._realpathBackend = createBackend(
duration,
this.fileSystem.realpath,
this.fileSystem.realpathSync,
this.fileSystem
);
const realpath = this._realpathBackend.provide;
this.realpath = /** @type {FileSystem["realpath"]} */
realpath;
const realpathSync = this._realpathBackend.provideSync;
this.realpathSync = /** @type {SyncFileSystem["realpathSync"]} */
realpathSync;
}
/**
* @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
*/
purge(what) {
this._statBackend.purge(what);
this._lstatBackend.purge(what);
this._readdirBackend.purgeParent(what);
this._readFileBackend.purge(what);
this._readlinkBackend.purge(what);
this._readJsonBackend.purge(what);
this._realpathBackend.purge(what);
}
};
}
});
// src/index.ts
var index_exports = {};
__export(index_exports, {
BannerPlugin: () => BannerPlugin,
Compilation: () => Compilation,
Compiler: () => Compiler,
ContextReplacementPlugin: () => ContextReplacementPlugin,
CopyRspackPlugin: () => CopyRspackPlugin,
CssExtractRspackPlugin: () => CssExtractRspackPlugin,
DefinePlugin: () => DefinePlugin,
DllPlugin: () => DllPlugin,
DllReferencePlugin: () => DllReferencePlugin,
DynamicEntryPlugin: () => DynamicEntryPlugin,
EntryOptionPlugin: () => EntryOptionPlugin_default,
EntryPlugin: () => EntryPlugin,
EnvironmentPlugin: () => EnvironmentPlugin,
EvalDevToolModulePlugin: () => EvalDevToolModulePlugin,
EvalSourceMapDevToolPlugin: () => EvalSourceMapDevToolPlugin,
ExternalsPlugin: () => ExternalsPlugin,
HotModuleReplacementPlugin: () => HotModuleReplacementPlugin,
HtmlRspackPlugin: () => HtmlRspackPlugin,
IgnorePlugin: () => IgnorePlugin,
LightningCssMinimizerRspackPlugin: () => LightningCssMinimizerRspackPlugin,
LoaderOptionsPlugin: () => LoaderOptionsPlugin,
LoaderTargetPlugin: () => LoaderTargetPlugin,
ModuleFilenameHelpers: () => ModuleFilenameHelpers_exports,
MultiCompiler: () => MultiCompiler,
MultiStats: () => MultiStats,
NoEmitOnErrorsPlugin: () => NoEmitOnErrorsPlugin,
NormalModule: () => NormalModule,
NormalModuleReplacementPlugin: () => NormalModuleReplacementPlugin,
ProgressPlugin: () => ProgressPlugin,
ProvidePlugin: () => ProvidePlugin,
RspackOptionsApply: () => RspackOptionsApply,
RuntimeGlobals: () => RuntimeGlobals,
RuntimeModule: () => RuntimeModule,
RuntimePlugin: () => RuntimePlugin,
SourceMapDevToolPlugin: () => SourceMapDevToolPlugin,
Stats: () => Stats,
SwcJsMinimizerRspackPlugin: () => SwcJsMinimizerRspackPlugin,
Template: () => Template,
ValidationError: () => ValidationError2,
WarnCaseSensitiveModulesPlugin: () => WarnCaseSensitiveModulesPlugin,
WebpackError: () => WebpackError2,
WebpackOptionsApply: () => RspackOptionsApply,
config: () => config,
container: () => container,
default: () => index_default,
electron: () => electron,
experiments: () => experiments2,
javascript: () => javascript,
library: () => library2,
node: () => node2,
optimize: () => optimize,
rspack: () => rspack,
rspackVersion: () => rspackVersion,
sharing: () => sharing,
sources: () => sources,
util: () => util7,
version: () => version,
wasm: () => wasm,
web: () => web,
webworker: () => webworker
});
module.exports = __toCommonJS(index_exports);
// src/exports.ts
var exports_exports = {};
__export(exports_exports, {
BannerPlugin: () => BannerPlugin,
Compilation: () => Compilation,
Compiler: () => Compiler,
ContextReplacementPlugin: () => ContextReplacementPlugin,
CopyRspackPlugin: () => CopyRspackPlugin,
CssExtractRspackPlugin: () => CssExtractRspackPlugin,
DefinePlugin: () => DefinePlugin,
DllPlugin: () => DllPlugin,
DllReferencePlugin: () => DllReferencePlugin,
DynamicEntryPlugin: () => DynamicEntryPlugin,
EntryOptionPlugin: () => EntryOptionPlugin_default,
EntryPlugin: () => EntryPlugin,
EnvironmentPlugin: () => EnvironmentPlugin,
EvalDevToolModulePlugin: () => EvalDevToolModulePlugin,
EvalSourceMapDevToolPlugin: () => EvalSourceMapDevToolPlugin,
ExternalsPlugin: () => ExternalsPlugin,
HotModuleReplacementPlugin: () => HotModuleReplacementPlugin,
HtmlRspackPlugin: () => HtmlRspackPlugin,
IgnorePlugin: () => IgnorePlugin,
LightningCssMinimizerRspackPlugin: () => LightningCssMinimizerRspackPlugin,
LoaderOptionsPlugin: () => LoaderOptionsPlugin,
LoaderTargetPlugin: () => LoaderTargetPlugin,
ModuleFilenameHelpers: () => ModuleFilenameHelpers_exports,
MultiCompiler: () => MultiCompiler,
MultiStats: () => MultiStats,
NoEmitOnErrorsPlugin: () => NoEmitOnErrorsPlugin,
NormalModule: () => NormalModule,
NormalModuleReplacementPlugin: () => NormalModuleReplacementPlugin,
ProgressPlugin: () => ProgressPlugin,
ProvidePlugin: () => ProvidePlugin,
RspackOptionsApply: () => RspackOptionsApply,
RuntimeGlobals: () => RuntimeGlobals,
RuntimeModule: () => RuntimeModule,
RuntimePlugin: () => RuntimePlugin,
SourceMapDevToolPlugin: () => SourceMapDevToolPlugin,
Stats: () => Stats,
SwcJsMinimizerRspackPlugin: () => SwcJsMinimizerRspackPlugin,
Template: () => Template,
ValidationError: () => ValidationError2,
WarnCaseSensitiveModulesPlugin: () => WarnCaseSensitiveModulesPlugin,
WebpackError: () => WebpackError2,
WebpackOptionsApply: () => RspackOptionsApply,
config: () => config,
container: () => container,
electron: () => electron,
experiments: () => experiments2,
javascript: () => javascript,
library: () => library2,
node: () => node2,
optimize: () => optimize,
rspackVersion: () => rspackVersion,
sharing: () => sharing,
sources: () => sources,
util: () => util7,
version: () => version,
wasm: () => wasm,
web: () => web,
webworker: () => webworker
});
var import_package = require("../package.json");
// src/Compilation.ts
var import_binding = require("@rspack/binding");
var liteTapable = __toESM(require("@rspack/lite-tapable"));
// src/Dependency.ts
var Dependency = class _Dependency {
#inner;
static __from_binding(binding9) {
return new _Dependency(binding9);
}
static __to_binding(data) {
return data.#inner;
}
constructor(binding9) {
this.#inner = binding9;
Object.defineProperties(this, {
type: {
enumerable: true,
get() {
return binding9.type;
}
},
category: {
enumerable: true,
get() {
return binding9.category;
}
},
request: {
enumerable: true,
get() {
return binding9.request;
}
},
critical: {
enumerable: true,
get() {
return binding9.critical;
},
set(val) {
binding9.critical = val;
}
}
});
}
get ids() {
return this.#inner.ids;
}
};
// src/DependenciesBlock.ts
var DependenciesBlock = class _DependenciesBlock {
#binding;
static __from_binding(binding9) {
return new _DependenciesBlock(binding9);
}
static __to_binding(block) {
return block.#binding;
}
constructor(binding9) {
this.#binding = binding9;
Object.defineProperties(this, {
dependencies: {
enumerable: true,
get() {
return binding9.dependencies.map((d) => Dependency.__from_binding(d));
}
},
blocks: {
enumerable: true,
get() {
return binding9.blocks.map((b) => _DependenciesBlock.__from_binding(b));
}
}
});
}
};
// src/util/AssetInfo.ts
var JsAssetInfo = class {
static __from_binding(jsAssetInfo) {
const {
immutable,
minimized,
development,
hotModuleReplacement,
related,
chunkhash,
fullhash,
contenthash,
javascriptModule,
sourceFilename,
copied,
extras
} = jsAssetInfo;
return {
...extras,
// extras should not overwrite any KnownAssetFields
immutable,
minimized,
development,
hotModuleReplacement,
related,
fullhash,
chunkhash,
contenthash,
javascriptModule,
sourceFilename,
copied
};
}
static __to_binding(assetInfo = {}) {
let {
immutable = false,
minimized = false,
development = false,
hotModuleReplacement = false,
related = {},
fullhash = [],
chunkhash = [],
contenthash = [],
javascriptModule,
sourceFilename,
copied,
...extras
} = assetInfo;
extras = extras ?? {};
return {
immutable,
minimized,
development,
hotModuleReplacement,
related,
fullhash,
chunkhash,
contenthash,
extras,
javascriptModule,
sourceFilename,
copied
};
}
};
// src/util/source.ts
var import_webpack_sources = require("../compiled/webpack-sources/index.js");
var JsSource = class extends import_webpack_sources.Source {
static __from_binding(source) {
if (Buffer.isBuffer(source.source)) {
return new import_webpack_sources.RawSource(source.source);
}
if (!source.map) {
return new import_webpack_sources.RawSource(source.source);
}
return new import_webpack_sources.SourceMapSource(
source.source,
"inmemory://from rust",
// @ts-expect-error: SourceMapSource can accept string as source map,
// see: https://github.com/webpack/webpack-sources/blob/9f98066311d53a153fdc7c633422a1d086528027/lib/SourceMapSource.js#L30
source.map
);
}
static __to_binding(source) {
var _a;
if (source instanceof import_webpack_sources.RawSource) {
if (source.isBuffer()) {
return {
source: source.buffer()
};
}
return {
source: source.source()
};
}
const map = JSON.stringify(
(_a = source.map) == null ? void 0 : _a.call(source, {
columns: true
})
);
const code = source.source();
return {
source: typeof code === "string" ? code : Buffer.from(code).toString("utf-8"),
map
};
}
};
// src/Module.ts
var ContextModuleFactoryBeforeResolveData = class _ContextModuleFactoryBeforeResolveData {
#inner;
static __from_binding(binding9) {
return new _ContextModuleFactoryBeforeResolveData(binding9);
}
static __to_binding(data) {
return data.#inner;
}
constructor(binding9) {
this.#inner = binding9;
Object.defineProperties(this, {
context: {
enumerable: true,
get() {
return binding9.context;
},
set(val) {
binding9.context = val;
}
},
request: {
enumerable: true,
get() {
return binding9.request;
},
set(val) {
binding9.request = val;
}
},
regExp: {
enumerable: true,
get() {
return binding9.regExp;
},
set(val) {
binding9.regExp = val;
}
},
recursive: {
enumerable: true,
get() {
return binding9.recursive;
},
set(val) {
binding9.recursive = val;
}
}
});
}
};
var ContextModuleFactoryAfterResolveData = class _ContextModuleFactoryAfterResolveData {
#inner;
static __from_binding(binding9) {
return new _ContextModuleFactoryAfterResolveData(binding9);
}
static __to_binding(data) {
return data.#inner;
}
constructor(binding9) {
this.#inner = binding9;
Object.defineProperties(this, {
resource: {
enumerable: true,
get() {
return binding9.resource;
},
set(val) {
binding9.resource = val;
}
},
context: {
enumerable: true,
get() {
return binding9.context;
},
set(val) {
binding9.context = val;
}
},
request: {
enumerable: true,
get() {
return binding9.request;
},
set(val) {
binding9.request = val;
}
},
regExp: {
enumerable: true,
get() {
return binding9.regExp;
},
set(val) {
binding9.regExp = val;
}
},
recursive: {
enumerable: true,
get() {
return binding9.recursive;
},
set(val) {
binding9.recursive = val;
}
},
dependencies: {
enumerable: true,
get() {
return binding9.dependencies.map(
(dep) => Dependency.__from_binding(dep)
);
}
}
});
}
};
var MODULE_MAPPINGS = /* @__PURE__ */ new WeakMap();
var Module = class _Module {
#inner;
static __from_binding(binding9) {
let module2 = MODULE_MAPPINGS.get(binding9);
if (module2) {
return module2;
}
module2 = new _Module(binding9);
MODULE_MAPPINGS.set(binding9, module2);
return module2;
}
static __to_binding(module2) {
return module2.#inner;
}
constructor(module2) {
this.#inner = module2;
this.buildInfo = {};
this.buildMeta = {};
Object.defineProperties(this, {
type: {
enumerable: true,
get() {
return module2.type || null;
}
},
layer: {
enumerable: true,
get() {
return module2.layer;
}
},
context: {
enumerable: true,
get() {
return module2.context;
}
},
resource: {
enumerable: true,
get() {
return module2.resource;
}
},
request: {
enumerable: true,
get() {
return module2.request;
}
},
userRequest: {
enumerable: true,
get() {
return module2.userRequest;
},
set(val) {
if (val) {
module2.userRequest = val;
}
}
},
rawRequest: {
enumerable: true,
get() {
return module2.rawRequest;
}
},
factoryMeta: {
enumerable: true,
get() {
return module2.factoryMeta;
}
},
modules: {
enumerable: true,
get() {
return module2.modules ? module2.modules.map((m) => _Module.__from_binding(m)) : void 0;
}
},
blocks: {
enumerable: true,
get() {
return module2.blocks.map((b) => DependenciesBlock.__from_binding(b));
}
},
dependencies: {
enumerable: true,
get() {
return module2.dependencies.map((d) => Dependency.__from_binding(d));
}
},
useSourceMap: {
enumerable: true,
get() {
return module2.useSourceMap;
}
},
resourceResolveData: {
enumerable: true,
get() {
return module2.resourceResolveData;
}
},
matchResource: {
enumerable: true,
get() {
return module2.matchResource;
}
}
});
}
originalSource() {
if (this.#inner.originalSource) {
return JsSource.__from_binding(this.#inner.originalSource);
}
return null;
}
identifier() {
return this.#inner.moduleIdentifier;
}
nameForCondition() {
if (typeof this.#inner.nameForCondition === "string") {
return this.#inner.nameForCondition;
}
return null;
}
size(type) {
if ("size" in this.#inner) {
return this.#inner.size(type);
}
return 0;
}
libIdent(options) {
return this.#inner.libIdent(options);
}
emitFile(filename2, source, assetInfo) {
return this.#inner.emitFile(
filename2,
JsSource.__to_binding(source),
JsAssetInfo.__to_binding(assetInfo)
);
}
};
var CodeGenerationResult = class {
#inner;
constructor(result2) {
this.#inner = result2;
}
get(sourceType) {
return this.#inner.sources[sourceType];
}
};
// src/ChunkGroup.ts
var CHUNK_GROUP_MAPPINGS = /* @__PURE__ */ new WeakMap();
var ChunkGroup = class _ChunkGroup {
#inner;
static __from_binding(binding9) {
let chunkGroup = CHUNK_GROUP_MAPPINGS.get(binding9);
if (chunkGroup) {
return chunkGroup;
}
chunkGroup = new _ChunkGroup(binding9);
CHUNK_GROUP_MAPPINGS.set(binding9, chunkGroup);
return chunkGroup;
}
constructor(inner) {
this.#inner = inner;
Object.defineProperties(this, {
chunks: {
enumerable: true,
get: () => {
return this.#inner.chunks.map(
(binding9) => Chunk.__from_binding(binding9)
);
}
},
index: {
enumerable: true,
get: () => {
return this.#inner.index;
}
},
name: {
enumerable: true,
get: () => {
return this.#inner.name;
}
},
origins: {
enumerable: true,
get: () => {
return this.#inner.origins.map((origin) => ({
module: origin.module ? Module.__from_binding(origin.module) : void 0,
request: origin.request
}));
}
},
childrenIterable: {
enumerable: true,
get: () => {
return this.#inner.childrenIterable.map(
(child) => _ChunkGroup.__from_binding(child)
);
}
}
});
}
getFiles() {
return this.#inner.getFiles();
}
getParents() {
return this.#inner.getParents().map((binding9) => _ChunkGroup.__from_binding(binding9));
}
isInitial() {
return this.#inner.isInitial();
}
getModulePreOrderIndex(module2) {
return this.#inner.getModulePreOrderIndex(Module.__to_binding(module2));
}
getModulePostOrderIndex(module2) {
return this.#inner.getModulePostOrderIndex(Module.__to_binding(module2));
}
};
// src/Chunk.ts
var CHUNK_MAPPINGS = /* @__PURE__ */ new WeakMap();
var Chunk = class _Chunk {
#inner;
static __from_binding(binding9) {
let chunk = CHUNK_MAPPINGS.get(binding9);
if (chunk) {
return chunk;
}
chunk = new _Chunk(binding9);
CHUNK_MAPPINGS.set(binding9, chunk);
return chunk;
}
static __to_binding(chunk) {
return chunk.#inner;
}
constructor(binding9) {
this.#inner = binding9;
Object.defineProperties(this, {
name: {
enumerable: true,
get: () => {
return binding9.name;
}
},
id: {
enumerable: true,
get: () => {
return binding9.id;
}
},
ids: {
enumerable: true,
get: () => {
return binding9.ids;
}
},
idNameHints: {
enumerable: true,
get: () => {
return binding9.idNameHints;
}
},
filenameTemplate: {
enumerable: true,
get: () => {
return binding9.filenameTemplate;
}
},
cssFilenameTemplate: {
enumerable: true,
get: () => {
return binding9.cssFilenameTemplate;
}
},
files: {
enumerable: true,
get: () => {
return new Set(binding9.files);
}
},
runtime: {
enumerable: true,
get: () => {
return new Set(binding9.runtime);
}
},
hash: {
enumerable: true,
get: () => {
return binding9.hash;
}
},
contentHash: {
enumerable: true,
get: () => {
return binding9.contentHash;
}
},
renderedHash: {
enumerable: true,
get: () => {
return binding9.renderedHash;
}
},
chunkReason: {
enumerable: true,
get: () => {
return binding9.chunkReason;
}
},
auxiliaryFiles: {
enumerable: true,
get: () => {
return new Set(binding9.auxiliaryFiles);
}
}
});
}
isOnlyInitial() {
return this.#inner.isOnlyInitial();
}
canBeInitial() {
return this.#inner.canBeInitial();
}
hasRuntime() {
return this.#inner.hasRuntime();
}
get groupsIterable() {
return new Set(
this.#inner.groups().map((binding9) => ChunkGroup.__from_binding(binding9))
);
}
getChunkMaps(realHash) {
const chunkHashMap = {};
const chunkContentHashMap = {};
const chunkNameMap = {};
for (const chunk of this.getAllAsyncChunks()) {
const id = chunk.id;
if (!id) continue;
const chunkHash = realHash ? chunk.hash : chunk.renderedHash;
if (chunkHash) {
chunkHashMap[id] = chunkHash;
}
for (const key of Object.keys(chunk.contentHash)) {
if (!chunkContentHashMap[key]) {
chunkContentHashMap[key] = {};
}
chunkContentHashMap[key][id] = chunk.contentHash[key];
}
if (chunk.name) {
chunkNameMap[id] = chunk.name;
}
}
return {
hash: chunkHashMap,
contentHash: chunkContentHashMap,
name: chunkNameMap
};
}
getAllAsyncChunks() {
return new Set(
this.#inner.getAllAsyncChunks().map((binding9) => _Chunk.__from_binding(binding9))
);
}
getAllInitialChunks() {
return new Set(
this.#inner.getAllInitialChunks().map((binding9) => _Chunk.__from_binding(binding9))
);
}
getAllReferencedChunks() {
return new Set(
this.#inner.getAllReferencedChunks().map((binding9) => _Chunk.__from_binding(binding9))
);
}
getEntryOptions() {
return this.#inner.getEntryOptions();
}
};
// src/util/runtime.ts
function toJsRuntimeSpec(runtime) {
if (runtime instanceof Set) {
return Array.from(runtime);
}
return runtime;
}
// src/ChunkGraph.ts
var ChunkGraph = class _ChunkGraph {
#inner;
static __from_binding(binding9) {
return new _ChunkGraph(binding9);
}
constructor(binding9) {
this.#inner = binding9;
}
getChunkModules(chunk) {
return this.#inner.getChunkModules(Chunk.__to_binding(chunk)).map((binding9) => Module.__from_binding(binding9));
}
getChunkModulesIterable(chunk) {
return this.#inner.getChunkModules(Chunk.__to_binding(chunk)).map((binding9) => Module.__from_binding(binding9));
}
getChunkEntryModulesIterable(chunk) {
return this.#inner.getChunkEntryModules(Chunk.__to_binding(chunk)).map((binding9) => Module.__from_binding(binding9));
}
getNumberOfEntryModules(chunk) {
return this.#inner.getNumberOfEntryModules(Chunk.__to_binding(chunk));
}
getChunkEntryDependentChunksIterable(chunk) {
return this.#inner.getChunkEntryDependentChunksIterable(Chunk.__to_binding(chunk)).map((binding9) => Chunk.__from_binding(binding9));
}
getChunkModulesIterableBySourceType(chunk, sourceType) {
return this.#inner.getChunkModulesIterableBySourceType(
Chunk.__to_binding(chunk),
sourceType
).map((binding9) => Module.__from_binding(binding9));
}
getModuleChunks(module2) {
return this.#inner.getModuleChunks(Module.__to_binding(module2)).map((binding9) => Chunk.__from_binding(binding9));
}
getModuleChunksIterable(module2) {
return this.#inner.getModuleChunks(Module.__to_binding(module2)).map((binding9) => Chunk.__from_binding(binding9));
}
getModuleId(module2) {
return this.#inner.getModuleId(Module.__to_binding(module2));
}
getModuleHash(module2, runtime) {
return this.#inner.getModuleHash(
Module.__to_binding(module2),
toJsRuntimeSpec(runtime)
);
}
getBlockChunkGroup(depBlock) {
const binding9 = this.#inner.getBlockChunkGroup(
DependenciesBlock.__to_binding(depBlock)
);
return binding9 ? ChunkGroup.__from_binding(binding9) : null;
}
};
// src/Entrypoint.ts
var ENTRYPOINT_MAPPINGS = /* @__PURE__ */ new WeakMap();
var Entrypoint = class _Entrypoint extends ChunkGroup {
#inner;
static __from_binding(binding9) {
let entrypoint = ENTRYPOINT_MAPPINGS.get(binding9);
if (entrypoint) {
return entrypoint;
}
entrypoint = new _Entrypoint(binding9);
ENTRYPOINT_MAPPINGS.set(binding9, entrypoint);
return entrypoint;
}
constructor(binding9) {
super(binding9);
this.#inner = binding9;
}
getRuntimeChunk() {
const chunkBinding = this.#inner.getRuntimeChunk();
return chunkBinding ? Chunk.__from_binding(chunkBinding) : null;
}
};
// src/ErrorHelpers.ts
var loaderFlag = "LOADER_EXECUTION";
var cutOffByFlag = (stack, flag) => {
const stacks = stack.split("\n");
for (let i = 0; i < stacks.length; i++) {
if (stacks[i].includes(flag)) {
stacks.length = i;
}
}
return stacks.join("\n");
};
var cutOffLoaderExecution = (stack) => cutOffByFlag(stack, loaderFlag);
// src/ExportsInfo.ts
var ExportsInfo = class _ExportsInfo {
#inner;
static __from_binding(binding9) {
return new _ExportsInfo(binding9);
}
constructor(binding9) {
this.#inner = binding9;
}
isUsed(runtime) {
return this.#inner.isUsed(toJsRuntimeSpec(runtime));
}
isModuleUsed(runtime) {
return this.#inner.isModuleUsed(toJsRuntimeSpec(runtime));
}
setUsedInUnknownWay(runtime) {
return this.#inner.setUsedInUnknownWay(toJsRuntimeSpec(runtime));
}
getUsed(name2, runtime) {
return this.#inner.getUsed(name2, toJsRuntimeSpec(runtime));
}
};
// src/ModuleGraphConnection.ts
var MODULE_GRAPH_CONNECTION_MAPPINGS = /* @__PURE__ */ new WeakMap();
var ModuleGraphConnection = class _ModuleGraphConnection {
#inner;
static __from_binding(binding9) {
let connection = MODULE_GRAPH_CONNECTION_MAPP