Socket
Socket
Sign inDemoInstall

@rspack/core

Package Overview
Dependencies
Maintainers
2
Versions
1083
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rspack/core - npm Package Compare versions

Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4

16

compiled/graceful-fs/index.js
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 132:
/***/ 577:
/***/ ((module) => {

@@ -35,9 +35,9 @@

/***/ 552:
/***/ 500:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var fs = __nccwpck_require__(147)
var polyfills = __nccwpck_require__(290)
var legacy = __nccwpck_require__(410)
var clone = __nccwpck_require__(132)
var polyfills = __nccwpck_require__(722)
var legacy = __nccwpck_require__(89)
var clone = __nccwpck_require__(577)

@@ -491,3 +491,3 @@ var util = __nccwpck_require__(837)

/***/ 410:
/***/ 89:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -617,3 +617,3 @@

/***/ 290:
/***/ 722:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -1062,3 +1062,3 @@

/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(552);
/******/ var __webpack_exports__ = __nccwpck_require__(500);
/******/ module.exports = __webpack_exports__;

@@ -1065,0 +1065,0 @@ /******/

@@ -5,3 +5,3 @@ /******/ (() => { // webpackBootstrap

/***/ 245:
/***/ 218:
/***/ ((module) => {

@@ -190,3 +190,3 @@

/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(245);
/******/ var __webpack_exports__ = __nccwpck_require__(218);
/******/ module.exports = __webpack_exports__;

@@ -193,0 +193,0 @@ /******/

/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 140:
/***/ 584:
/***/ ((module) => {

@@ -141,3 +141,3 @@

/***/ 238:
/***/ 757:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -156,3 +156,3 @@

const watchEventSource = __nccwpck_require__(511);
const watchEventSource = __nccwpck_require__(178);

@@ -938,3 +938,3 @@ const EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({});

/***/ 669:
/***/ 391:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -1054,3 +1054,3 @@

/***/ 399:
/***/ 380:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -1066,3 +1066,3 @@

const path = __nccwpck_require__(17);
const DirectoryWatcher = __nccwpck_require__(238);
const DirectoryWatcher = __nccwpck_require__(757);

@@ -1116,3 +1116,3 @@ class WatcherManager {

/***/ 385:
/***/ 883:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -1263,3 +1263,3 @@

/***/ 511:
/***/ 178:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {

@@ -1277,3 +1277,3 @@

const { EventEmitter } = __nccwpck_require__(361);
const reducePlan = __nccwpck_require__(385);
const reducePlan = __nccwpck_require__(883);

@@ -1606,3 +1606,3 @@ const IS_OSX = (__nccwpck_require__(37).platform)() === "darwin";

/***/ 375:
/***/ 619:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

@@ -1617,7 +1617,7 @@

const getWatcherManager = __nccwpck_require__(399);
const LinkResolver = __nccwpck_require__(669);
const getWatcherManager = __nccwpck_require__(380);
const LinkResolver = __nccwpck_require__(391);
const EventEmitter = (__nccwpck_require__(361).EventEmitter);
const globToRegExp = __nccwpck_require__(140);
const watchEventSource = __nccwpck_require__(511);
const globToRegExp = __nccwpck_require__(584);
const watchEventSource = __nccwpck_require__(178);

@@ -2081,3 +2081,3 @@ const EMPTY_ARRAY = [];

/******/ // This entry module is referenced by other modules so it can't be inlined
/******/ var __webpack_exports__ = __nccwpck_require__(375);
/******/ var __webpack_exports__ = __nccwpck_require__(619);
/******/ module.exports = __webpack_exports__;

@@ -2084,0 +2084,0 @@ /******/

@@ -5,3 +5,3 @@ /******/ (() => { // webpackBootstrap

/***/ 353:
/***/ 479:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

@@ -36,4 +36,4 @@

const zod = __importStar(__nccwpck_require__(934));
const joinPath_1 = __nccwpck_require__(991);
const NonEmptyArray_1 = __nccwpck_require__(355);
const joinPath_1 = __nccwpck_require__(14);
const NonEmptyArray_1 = __nccwpck_require__(80);
class ValidationError extends Error {

@@ -109,3 +109,3 @@ details;

/***/ 355:
/***/ 80:
/***/ ((__unused_webpack_module, exports) => {

@@ -124,3 +124,3 @@

/***/ 991:
/***/ 14:
/***/ ((__unused_webpack_module, exports) => {

@@ -210,3 +210,3 @@

exports.fromZodError = exports.isValidationErrorLike = exports.isValidationError = exports.toValidationError = exports.ValidationError = void 0;
var ValidationError_1 = __nccwpck_require__(353);
var ValidationError_1 = __nccwpck_require__(479);
Object.defineProperty(exports, "ValidationError", ({ enumerable: true, get: function () { return ValidationError_1.ValidationError; } }));

@@ -213,0 +213,0 @@ Object.defineProperty(exports, "toValidationError", ({ enumerable: true, get: function () { return ValidationError_1.toValidationError; } }));

@@ -25,3 +25,3 @@ "use strict";

apply(compiler) {
let raw = this.raw(compiler);
const raw = this.raw(compiler);
if (raw) {

@@ -28,0 +28,0 @@ raw.canInherentFromParent = canInherentFromParent(this.affectedHooks);

@@ -56,3 +56,3 @@ "use strict";

this._module.type === "css/module")) {
let e = new Error(`use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`);
const e = new Error(`use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`);
e.stack = undefined;

@@ -121,4 +121,4 @@ this.emitWarning(e);

.map(([id, content, media, sourceMap, supports, layer]) => {
let identifier = id;
let context = this.rootContext;
const identifier = id;
const context = this.rootContext;
const count = identifierCountMap.get(identifier) || 0;

@@ -125,0 +125,0 @@ identifierCountMap.set(identifier, count + 1);

@@ -7,3 +7,3 @@ "use strict";

exports.DefinePlugin = (0, base_1.create)(binding_1.BuiltinPluginName.DefinePlugin, function (define) {
let supportsBigIntLiteral = this.options.output.environment?.bigIntLiteral ?? false;
const supportsBigIntLiteral = this.options.output.environment?.bigIntLiteral ?? false;
return normalizeValue(define, supportsBigIntLiteral);

@@ -41,3 +41,3 @@ }, "compilation");

else if (define && typeof define === "object") {
let keys = Object.keys(define);
const keys = Object.keys(define);
return Object.fromEntries(keys.map(k => [k, normalizeObject(define[k])]));

@@ -44,0 +44,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

exports.EntryPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.EntryPlugin, (context, entry, options = "") => {
let entryOptions = typeof options === "string" ? { name: options } : options;
const entryOptions = typeof options === "string" ? { name: options } : options;
return {

@@ -12,0 +12,0 @@ context,

import { BuiltinPluginName } from "@rspack/binding";
type MinifyCondition = string | RegExp;
type MinifyConditions = MinifyCondition | MinifyCondition[];
export type SwcCssMinimizerRspackPluginOptions = {
test?: MinifyConditions;
exclude?: MinifyConditions;
include?: MinifyConditions;
};
export declare const SwcCssMinimizerRspackPlugin: {
new (options?: any): {
new (options?: SwcCssMinimizerRspackPluginOptions | undefined): {
name: BuiltinPluginName;
_args: [options?: any];
_args: [options?: SwcCssMinimizerRspackPluginOptions | undefined];
affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;

@@ -11,1 +18,2 @@ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;

};
export {};

@@ -6,2 +6,8 @@ "use strict";

const base_1 = require("./base");
exports.SwcCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcCssMinimizerRspackPlugin, (options /* TODO: extend more options */) => undefined);
exports.SwcCssMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcCssMinimizerRspackPlugin, (options) => {
return {
test: options?.test,
include: options?.include,
exclude: options?.exclude
};
});

@@ -59,4 +59,4 @@ "use strict";

let compress = options?.compress ?? true;
let mangle = options?.mangle ?? true;
let format = {
const mangle = options?.mangle ?? true;
const format = {
comments: false,

@@ -63,0 +63,0 @@ ...options?.format

@@ -9,3 +9,7 @@ "use strict";

class WorkerPlugin extends base_1.RspackBuiltinPlugin {
constructor(chunkLoading, wasmLoading, module, workerPublicPath) {
constructor(chunkLoading, wasmLoading,
// @ts-expect-error not implemented
module,
// @ts-expect-error not implemented
workerPublicPath) {
super();

@@ -12,0 +16,0 @@ this.chunkLoading = chunkLoading;

@@ -47,3 +47,3 @@ "use strict";

const Entrypoint_1 = require("./Entrypoint");
const ErrorHelpers_1 = __importDefault(require("./ErrorHelpers"));
const ErrorHelpers_1 = require("./ErrorHelpers");
const Module_1 = require("./Module");

@@ -517,3 +517,3 @@ const Stats_1 = require("./Stats");

case Logger_1.LogType.trace:
trace = ErrorHelpers_1.default.cutOffLoaderExecution(new Error("Trace").stack)
trace = (0, ErrorHelpers_1.cutOffLoaderExecution)(new Error("Trace").stack)
.split("\n")

@@ -527,3 +527,2 @@ .slice(3);

args,
// @ts-expect-error
trace

@@ -530,0 +529,0 @@ };

@@ -5,3 +5,3 @@ import type { RawLibraryOptions, RawOptions } from "@rspack/binding";

import type { RspackOptionsNormalized } from "./normalization";
import { type ChunkLoading, type LibraryOptions, type Resolve } from "./zod";
import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };

@@ -8,0 +8,0 @@ export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;

@@ -265,3 +265,3 @@ "use strict";

if (typeof rule.use === "function") {
let use = rule.use;
const use = rule.use;
funcUse = (rawContext) => {

@@ -276,3 +276,3 @@ const context = {

}
let rawModuleRule = {
const rawModuleRule = {
test: rule.test ? getRawRuleSetCondition(rule.test) : undefined,

@@ -397,6 +397,10 @@ include: rule.include ? getRawRuleSetCondition(rule.include) : undefined,

function getRawParserOptionsByModuleType(parser) {
return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawParserOptions(v, k)]));
return Object.fromEntries(Object.entries(parser)
.map(([k, v]) => [k, getRawParserOptions(v, k)])
.filter(([k, v]) => v !== undefined));
}
function getRawGeneratorOptionsByModuleType(parser) {
return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawGeneratorOptions(v, k)]));
return Object.fromEntries(Object.entries(parser)
.map(([k, v]) => [k, getRawGeneratorOptions(v, k)])
.filter(([k, v]) => v !== undefined));
}

@@ -411,6 +415,4 @@ function getRawParserOptions(parser, type) {

else if (type === "javascript") {
return {
type: "javascript",
javascript: getRawJavascriptParserOptions(parser)
};
// Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
return;
}

@@ -477,3 +479,4 @@ else if (type === "javascript/auto") {

strictExportPresence: parser.strictExportPresence ?? false,
worker: getRawJavascriptParserOptionsWorker(parser.worker)
worker: getRawJavascriptParserOptionsWorker(parser.worker),
overrideStrict: parser.overrideStrict
};

@@ -554,2 +557,10 @@ }

}
if ([
"javascript",
"javascript/auto",
"javascript/dynamic",
"javascript/esm"
].includes(type)) {
return undefined;
}
throw new Error(`unreachable: unknow module type: ${type}`);

@@ -556,0 +567,0 @@ }

@@ -18,3 +18,3 @@ "use strict";

if (o && typeof o === "object" && o.rspackExperiments) {
let expr = o.rspackExperiments;
const expr = o.rspackExperiments;
if (expr.import || expr.pluginImport) {

@@ -21,0 +21,0 @@ expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);

@@ -86,3 +86,3 @@ /**

parsedVersion === "TP"
? [Infinity, Infinity]
? [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
: parsedVersion.includes("-")

@@ -89,0 +89,0 @@ ? parsedVersion.split("-")[0].split(".")

@@ -33,3 +33,3 @@ "use strict";

(0, assert_1.default)(!(0, util_1.isNil)(target));
let targetProperties = target === false
const targetProperties = target === false
? false

@@ -155,2 +155,3 @@ : typeof target === "string"

D(parserOptions, "worker", fallback?.worker ?? ["..."]);
D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
};

@@ -731,4 +732,4 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {

// F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000));
F(splitChunks, "maxAsyncRequests", () => (production ? 30 : Infinity));
F(splitChunks, "maxInitialRequests", () => (production ? 30 : Infinity));
F(splitChunks, "maxAsyncRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
F(splitChunks, "maxInitialRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
D(splitChunks, "automaticNameDelimiter", "-");

@@ -735,0 +736,0 @@ const { cacheGroups } = splitChunks;

@@ -348,2 +348,3 @@ "use strict";

const worker = zod_1.z.array(zod_1.z.string()).or(zod_1.z.boolean());
const overrideStrict = zod_1.z.enum(["strict", "non-strict"]);
const javascriptParserOptions = zod_1.z.strictObject({

@@ -361,3 +362,4 @@ dynamicImportMode: dynamicImportMode.optional(),

strictExportPresence: strictExportPresence.optional(),
worker: worker.optional()
worker: worker.optional(),
overrideStrict: overrideStrict.optional()
});

@@ -447,40 +449,41 @@ const parserOptionsByModuleTypeKnown = zod_1.z.strictObject({

//#region Target
const allowTarget = zod_1.z
.enum([
"web",
"webworker",
"es3",
"es5",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"es2021",
"es2022",
"browserslist"
])
.or(zod_1.z.literal("node"))
.or(zod_1.z.literal("async-node"))
.or(zod_1.z.custom(value => typeof value === "string" && /^node\d+$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^async-node\d+$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^node\d+\.\d+$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^async-node\d+\.\d+$/.test(value)))
.or(zod_1.z.literal("electron-main"))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+-main$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-main$/.test(value)))
.or(zod_1.z.literal("electron-renderer"))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+-renderer$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-renderer$/.test(value)))
.or(zod_1.z.literal("electron-preload"))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+-preload$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-preload$/.test(value)))
.or(zod_1.z.literal("nwjs"))
.or(zod_1.z.custom(value => typeof value === "string" && /^nwjs\d+$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^nwjs\d+\.\d+$/.test(value)))
.or(zod_1.z.literal("node-webkit"))
.or(zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+$/.test(value)))
.or(zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+\.\d+$/.test(value)));
const target = zod_1.z.literal(false).or(allowTarget).or(allowTarget.array());
const allowTarget = zod_1.z.union([
zod_1.z.enum([
"web",
"webworker",
"es3",
"es5",
"es2015",
"es2016",
"es2017",
"es2018",
"es2019",
"es2020",
"es2021",
"es2022",
"browserslist"
]),
zod_1.z.literal("node"),
zod_1.z.literal("async-node"),
zod_1.z.custom(value => typeof value === "string" && /^node\d+$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^async-node\d+$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^node\d+\.\d+$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^async-node\d+\.\d+$/.test(value)),
zod_1.z.literal("electron-main"),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+-main$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-main$/.test(value)),
zod_1.z.literal("electron-renderer"),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+-renderer$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-renderer$/.test(value)),
zod_1.z.literal("electron-preload"),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+-preload$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^electron\d+\.\d+-preload$/.test(value)),
zod_1.z.literal("nwjs"),
zod_1.z.custom(value => typeof value === "string" && /^nwjs\d+$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^nwjs\d+\.\d+$/.test(value)),
zod_1.z.literal("node-webkit"),
zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+$/.test(value)),
zod_1.z.custom(value => typeof value === "string" && /^node-webkit\d+\.\d+$/.test(value))
]);
const target = zod_1.z.union([zod_1.z.literal(false), allowTarget, allowTarget.array()]);
//#endregion

@@ -487,0 +490,0 @@ //#region ExternalsType

@@ -74,4 +74,4 @@ "use strict";

const remoteInfos = {};
for (let [key, config] of remotes) {
for (let external of config.external) {
for (const [key, config] of remotes) {
for (const external of config.external) {
const [externalType, externalRequest] = getExternal(external);

@@ -78,0 +78,0 @@ remoteInfos[key] ??= [];

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

export function cutOffByFlag(stack: any, flag: any): any;
export function cutOffLoaderExecution(stack: any): any;
export function cutOffWebpackOptions(stack: any): any;
export function cutOffMultilineMessage(stack: any, message: any): string;
export function cutOffMessage(stack: any, message: any): any;
export function cleanUp(stack: any, message: any): any;
export function cleanUpWebpackOptions(stack: any, message: any): any;
/**
* The following code is modified based on
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/ErrorHelpers.js
*
* MIT Licensed
* Author Tobias Koppers @sokra
* Copyright (c) JS Foundation and other contributors
* https://github.com/webpack/webpack/blob/main/LICENSE
*/
export declare const cutOffByFlag: (stack: string, flag: string) => string;
export declare const cutOffLoaderExecution: (stack: string) => string;
export declare const cutOffWebpackOptions: (stack: string) => string;
export declare const cutOffMultilineMessage: (stack: string, message: string) => string;
export declare const cutOffMessage: (stack: string, message: string) => string;
export declare const cleanUp: (stack: string, message: string) => string;
export declare const cleanUpWebpackOptions: (stack: string, message: string) => string;

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

"use strict";
/**

@@ -10,35 +11,32 @@ * The following code is modified based on

*/
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanUpWebpackOptions = exports.cleanUp = exports.cutOffMessage = exports.cutOffMultilineMessage = exports.cutOffWebpackOptions = exports.cutOffLoaderExecution = exports.cutOffByFlag = void 0;
const loaderFlag = "LOADER_EXECUTION";
const webpackOptionsFlag = "WEBPACK_OPTIONS";
// @ts-expect-error
exports.cutOffByFlag = (stack, flag) => {
stack = stack.split("\n");
for (let i = 0; i < stack.length; i++) {
if (stack[i].includes(flag)) {
stack.length = i;
const 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 stack.join("\n");
return stacks.join("\n");
};
// @ts-expect-error
exports.cutOffLoaderExecution = stack => exports.cutOffByFlag(stack, loaderFlag);
// @ts-expect-error
exports.cutOffWebpackOptions = stack => exports.cutOffByFlag(stack, webpackOptionsFlag);
// @ts-expect-error
exports.cutOffMultilineMessage = (stack, message) => {
stack = stack.split("\n");
message = message.split("\n");
// @ts-expect-error
exports.cutOffByFlag = cutOffByFlag;
const cutOffLoaderExecution = (stack) => (0, exports.cutOffByFlag)(stack, loaderFlag);
exports.cutOffLoaderExecution = cutOffLoaderExecution;
const cutOffWebpackOptions = (stack) => (0, exports.cutOffByFlag)(stack, webpackOptionsFlag);
exports.cutOffWebpackOptions = cutOffWebpackOptions;
const cutOffMultilineMessage = (stack, message) => {
const stacks = stack.split("\n");
const messages = message.split("\n");
const result = [];
// @ts-expect-error
stack.forEach((line, idx) => {
if (!line.includes(message[idx]))
stacks.forEach((line, idx) => {
if (!line.includes(messages[idx]))
result.push(line);
});
// @ts-expect-error
return result.join("\n");
};
// @ts-expect-error
exports.cutOffMessage = (stack, message) => {
exports.cutOffMultilineMessage = cutOffMultilineMessage;
const cutOffMessage = (stack, message) => {
const nextLine = stack.indexOf("\n");

@@ -53,13 +51,16 @@ if (nextLine === -1) {

};
// @ts-expect-error
exports.cleanUp = (stack, message) => {
stack = exports.cutOffLoaderExecution(stack);
stack = exports.cutOffMessage(stack, message);
return stack;
exports.cutOffMessage = cutOffMessage;
const cleanUp = (stack, message) => {
let str = stack;
str = (0, exports.cutOffLoaderExecution)(str);
str = (0, exports.cutOffMessage)(str, message);
return str;
};
// @ts-expect-error
exports.cleanUpWebpackOptions = (stack, message) => {
stack = exports.cutOffWebpackOptions(stack);
stack = exports.cutOffMultilineMessage(stack, message);
return stack;
exports.cleanUp = cleanUp;
const cleanUpWebpackOptions = (stack, message) => {
let str = stack;
str = (0, exports.cutOffWebpackOptions)(str);
str = (0, exports.cutOffMultilineMessage)(str, message);
return str;
};
exports.cleanUpWebpackOptions = cleanUpWebpackOptions;

@@ -22,3 +22,3 @@ "use strict";

catch (e) {
let err = e instanceof Error ? e : new Error(e);
const err = e instanceof Error ? e : new Error(e);
err.stack += printGeneratedCodeForStack(moduleObject.id, source);

@@ -25,0 +25,0 @@ throw err;

@@ -62,6 +62,6 @@ "use strict";

set: value => {
var splittedRequest = (0, identifier_1.parseResourceWithoutFragment)(value.request);
const splittedRequest = (0, identifier_1.parseResourceWithoutFragment)(value.request);
obj.path = splittedRequest.path;
obj.query = splittedRequest.query;
obj.fragment = splittedRequest.fragment || "";
obj.fragment = "";
obj.options =

@@ -235,3 +235,3 @@ obj.options === null

// use string for napi getter
let err = e;
const err = e;
if ("hideStack" in err && err.hideStack) {

@@ -519,3 +519,3 @@ err.hideStack = "true";

}
let hasStack = !!error.stack;
const hasStack = !!error.stack;
error.name = "ModuleError";

@@ -535,3 +535,3 @@ error.message = `${error.message} (from: ${(0, util_2.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;

}
let hasStack = !!warning.stack;
const hasStack = !!warning.stack;
warning.name = "ModuleWarning";

@@ -693,3 +693,3 @@ warning.message = `${warning.message} (from: ${(0, util_2.stringifyLoaderObject)(loaderContext.loaders[loaderContext.loaderIndex])})`;

continue;
let args = [content, sourceMap, additionalData];
const args = [content, sourceMap, additionalData];
convertArgs(args, !!currentLoaderObject.raw);

@@ -696,0 +696,0 @@ [content, sourceMap, additionalData] =

@@ -17,3 +17,3 @@ "use strict";

/** @type {createConsoleLogger.LoggerOptions} */
let currentDefaultLoggerOptions = {
const currentDefaultLoggerOptions = {
level: "info",

@@ -20,0 +20,0 @@ debug: false,

@@ -70,4 +70,3 @@ import type { JsCodegenerationResult, JsCodegenerationResults, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";

export declare class CodeGenerationResults {
#private;
constructor(result: JsCodegenerationResults);
constructor(_result: JsCodegenerationResults);
}

@@ -13,3 +13,3 @@ "use strict";

};
var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner, _CodeGenerationResults_inner;
var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -74,8 +74,4 @@ exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;

class CodeGenerationResults {
constructor(result) {
_CodeGenerationResults_inner.set(this, void 0);
__classPrivateFieldSet(this, _CodeGenerationResults_inner, result, "f");
}
constructor(_result) { }
}
exports.CodeGenerationResults = CodeGenerationResults;
_CodeGenerationResults_inner = new WeakMap();

@@ -70,3 +70,3 @@ "use strict";

this._options = {
parallelism: options?.parallelism || Infinity
parallelism: options?.parallelism || Number.POSITIVE_INFINITY
};

@@ -73,0 +73,0 @@ this.dependencies = new WeakMap();

import * as binding from "@rspack/binding";
import { Resolver } from "./Resolver";
type ResolveOptionsWithDependencyType = binding.RawResolveOptionsWithDependencyType;
import { type Resolve } from "./config";
type ResolveOptionsWithDependencyType = Resolve & {
dependencyCategory?: string;
resolveToContext?: boolean;
};
export declare class ResolverFactory {

@@ -5,0 +9,0 @@ #private;

@@ -41,2 +41,3 @@ "use strict";

const Resolver_1 = require("./Resolver");
const config_1 = require("./config");
class ResolverFactory {

@@ -51,3 +52,8 @@ static __to_binding(resolver_factory) {

get(type, resolveOptions) {
const binding = __classPrivateFieldGet(this, _ResolverFactory_binding, "f").get(type, resolveOptions);
const { dependencyCategory, resolveToContext, ...resolve } = resolveOptions || {};
const binding = __classPrivateFieldGet(this, _ResolverFactory_binding, "f").get(type, {
...(0, config_1.getRawResolve)(resolve),
dependencyCategory,
resolveToContext
});
return new Resolver_1.Resolver(binding);

@@ -54,0 +60,0 @@ }

@@ -71,3 +71,3 @@ "use strict";

try {
for (let o of (0, util_2.asArray)(options)) {
for (const o of (0, util_2.asArray)(options)) {
(0, validate_1.validate)(o, config_1.rspackOptions);

@@ -74,0 +74,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

const res = new Set();
for (let flag of runtimeRequirements.value) {
for (const flag of runtimeRequirements.value) {
if (flag in exports.RuntimeGlobals) {

@@ -32,3 +32,3 @@ res.add(exports.RuntimeGlobals[flag]);

};
for (let flag of Array.from(runtimeRequirements)) {
for (const flag of Array.from(runtimeRequirements)) {
const item = REVERSE_RUNTIME_GLOBALS.get(flag);

@@ -357,4 +357,4 @@ if (typeof item === "string") {

};
for (let entry of Object.entries(exports.RuntimeGlobals)) {
for (const entry of Object.entries(exports.RuntimeGlobals)) {
REVERSE_RUNTIME_GLOBALS.set(entry[1], entry[0]);
}

@@ -17,3 +17,3 @@ "use strict";

throw new Error("Unexpected array in options");
let result = item === key || !(0, utils_1.isRequiredVersion)(item)
const result = item === key || !(0, utils_1.isRequiredVersion)(item)
? // item is a request/key

@@ -20,0 +20,0 @@ {

@@ -105,3 +105,3 @@ "use strict";

else {
let obj = { ...presetToOptions(options.preset), ...options };
const obj = { ...presetToOptions(options.preset), ...options };
delete obj.preset;

@@ -122,3 +122,3 @@ return obj;

all: true,
modulesSpace: Infinity
modulesSpace: Number.POSITIVE_INFINITY
};

@@ -130,4 +130,4 @@ case "errors-only":

errorsCount: true,
logging: "error"
// TODO: moduleTrace: true,
logging: "error",
moduleTrace: true
};

@@ -134,0 +134,0 @@ case "errors-warnings":

@@ -60,18 +60,10 @@ "use strict";

"module.modules[]": "module",
"module.children[]": "module"
// "moduleTrace[]": "moduleTraceItem",
"module.children[]": "module",
"moduleTrace[]": "moduleTraceItem"
// "moduleTraceItem.dependencies[]": "moduleTraceDependency"
};
// const MERGER: Record<
// string,
// (
// items: {
// [key: string]: any;
// name: string;
// }[]
// ) => any
// > = {
// "compilation.entrypoints": mergeToObject,
// "compilation.namedChunkGroups": mergeToObject
// };
const MERGER = {
"compilation.entrypoints": statsFactoryUtils_1.mergeToObject,
"compilation.namedChunkGroups": statsFactoryUtils_1.mergeToObject
};
const ASSETS_GROUPERS = {

@@ -153,6 +145,70 @@ _: (groupConfigs, context, options) => {

}
},
groupAssetsByInfo: groupConfigs => {
const groupByAssetInfoFlag = (name) => {
groupConfigs.push({
getKeys: asset => {
return asset.info && asset.info[name] ? ["1"] : undefined;
},
// @ts-expect-error
createGroup: (key, children) => {
return {
type: "assets by info",
info: {
[name]: !!key
},
children,
...(0, statsFactoryUtils_1.assetGroup)(children)
};
}
});
};
groupByAssetInfoFlag("immutable");
groupByAssetInfoFlag("development");
groupByAssetInfoFlag("hotModuleReplacement");
},
groupAssetsByChunk: groupConfigs => {
const groupByNames = (name) => {
groupConfigs.push({
getKeys: asset => {
return asset[name];
},
// @ts-expect-error
createGroup: (key, children) => {
return {
type: "assets by chunk",
[name]: [key],
children,
...(0, statsFactoryUtils_1.assetGroup)(children)
};
}
});
};
groupByNames("chunkNames");
// groupByNames("auxiliaryChunkNames");
// groupByNames("chunkIdHints");
// groupByNames("auxiliaryChunkIdHints");
},
excludeAssets: (groupConfigs, context, { excludeAssets }) => {
groupConfigs.push({
getKeys: asset => {
const ident = asset.name;
const excluded = excludeAssets.some(fn => fn(ident, asset));
if (excluded)
return ["excluded"];
},
getOptions: () => ({
groupChildren: false,
force: true
}),
// @ts-expect-error
createGroup: (key, children, assets) => ({
type: "hidden assets",
filteredChildren: assets.length,
...(0, statsFactoryUtils_1.assetGroup)(children)
})
});
}
// not support groupAssetsByInfo / groupAssetsByChunk / excludeAssets
};
const MODULES_GROUPERS = (_type) => ({
const MODULES_GROUPERS = (type) => ({
_: (groupConfigs, context, options) => {

@@ -181,3 +237,3 @@ const groupByFlag = (name, type, exclude) => {

};
const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType } = options;
const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType, groupModulesByPath, groupModulesByExtension } = options;
if (groupModulesByAttributes) {

@@ -234,5 +290,72 @@ groupByFlag("errors", "modules with errors");

}
// not support groupModulesByLayer / groupModulesByPath / groupModulesByExtension
// not support groupModulesByLayer
if (groupModulesByPath || groupModulesByExtension) {
groupConfigs.push({
getKeys: module => {
if (!module.name)
return;
const resource = (0, identifier_1.parseResource)(module.name.split("!").pop()).path;
const dataUrl = /^data:[^,;]+/.exec(resource);
if (dataUrl)
return [dataUrl[0]];
const extensionMatch = groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
const extension = extensionMatch ? extensionMatch[1] : "";
const pathMatch = groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
const keys = [];
if (groupModulesByPath) {
if (extension)
keys.push(path.length
? `${path.join("/")}/*${extension}`
: `*${extension}`);
while (path.length > 0) {
keys.push(path.join("/") + "/");
path.pop();
}
}
else {
if (extension)
keys.push(`*${extension}`);
}
return keys;
},
// @ts-expect-error
createGroup: (key, children, modules) => {
const isDataUrl = key.startsWith("data:");
return {
type: isDataUrl
? "modules by mime type"
: groupModulesByPath
? "modules by path"
: "modules by extension",
name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
children,
...(0, statsFactoryUtils_1.moduleGroup)(children)
};
}
});
}
},
excludeModules: (groupConfigs, context, { excludeModules }) => {
groupConfigs.push({
getKeys: module => {
const name = module.name;
if (name) {
const excluded = excludeModules.some(fn => fn(name, module, type));
if (excluded)
return ["1"];
}
},
getOptions: () => ({
groupChildren: false,
force: true
}),
// @ts-expect-error
createGroup: (key, children, modules) => ({
type: "hidden modules",
filteredChildren: children.length,
...(0, statsFactoryUtils_1.moduleGroup)(children)
})
});
}
// not support excludeModules
});

@@ -302,2 +425,27 @@ const RESULT_GROUPERS = {

};
const EXTRACT_ERROR = {
_: (object, error) => {
object.message = error.message;
object.chunkName = error.chunkName;
object.chunkEntry = error.chunkEntry;
object.chunkInitial = error.chunkInitial;
object.file = error.file;
object.moduleIdentifier = error.moduleIdentifier;
object.moduleName = error.moduleName;
},
ids: (object, error) => {
object.chunkId = error.chunkId;
object.moduleId = error.moduleId;
},
moduleTrace: (object, error, context, _, factory) => {
const { type } = context;
object.moduleTrace = factory.create(`${type}.moduleTrace`, error.moduleTrace, context);
},
errorDetails: (object, error) => {
object.details = error.details;
},
errorStack: (object, error) => {
object.stack = error.stack;
}
};
const SIMPLE_EXTRACTORS = {

@@ -495,3 +643,3 @@ compilation: {

});
const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Infinity);
const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Number.POSITIVE_INFINITY);
// object.filteredAssets = limited.filteredChildren;

@@ -518,31 +666,42 @@ // const limited = spaceLimited(groupedAssets, options.assetsSpace);

},
entrypoints: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, _factory) => {
// const { type } = context;
entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
const { type } = context;
const array = context
.getInner(compilation)
.getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren);
// object.entrypoints = factory.create(
// `${type}.entrypoints`,
// array,
// context
// );
object.entrypoints = array.reduce((acc, cur) => {
acc[cur.name] = cur;
return acc;
.getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren)
.map(entrypoint => ({
name: entrypoint.name,
chunkGroup: entrypoint
}));
const chunks = Array.from(compilation.chunks).reduce((res, chunk) => {
res[chunk.id] = chunk;
return res;
}, {});
if (entrypoints === "auto" && !chunkGroups) {
if (array.length > 5)
return;
if (!chunkGroupChildren &&
array.every(({ chunkGroup }) => {
if (chunkGroup.chunks.length !== 1)
return false;
const chunk = chunks[chunkGroup.chunks[0]];
return (chunk &&
chunk.files.size === 1 &&
(!chunkGroupAuxiliary || chunk.auxiliaryFiles.size === 0));
})) {
return;
}
}
object.entrypoints = factory.create(`${type}.entrypoints`, array, context);
},
chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
// const { type } = context;
const { type } = context;
const namedChunkGroups = context
.getInner(compilation)
.getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren);
// object.namedChunkGroups = factory.create(
// `${type}.namedChunkGroups`,
// namedChunkGroups,
// context
// );
object.namedChunkGroups = namedChunkGroups.reduce((acc, cur) => {
acc[cur.name] = cur;
return acc;
}, {});
.getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren)
.map(cg => ({
name: cg.name,
chunkGroup: cg
}));
object.namedChunkGroups = factory.create(`${type}.namedChunkGroups`, namedChunkGroups, context);
},

@@ -581,2 +740,4 @@ errors: (object, compilation, context, _options, _factory) => {

};
// - comparedForEmit
// - cached
Object.assign(object, factory.create(`${context.type}$visible`, asset, context));

@@ -588,7 +749,29 @@ }

object.chunkNames = asset.chunkNames;
// - chunkIdHints
// - auxiliaryChunkNames
// - auxiliaryChunkIdHints
// - filteredRelated
},
// relatedAssets
ids: (object, asset) => {
object.chunks = asset.chunks;
// - auxiliaryChunks
}
},
chunkGroup: {
_: (object, { name, chunkGroup }, _context, { chunkGroupMaxAssets }) => {
object.name = name;
object.chunks = chunkGroup.chunks;
object.assets = chunkGroup.assets;
object.filteredAssets =
chunkGroup.assets.length <= chunkGroupMaxAssets
? 0
: chunkGroup.assets.length;
object.assetsSize = chunkGroup.assetsSize;
object.auxiliaryAssets = chunkGroup.auxiliaryAssets;
object.auxiliaryAssetsSize = chunkGroup.auxiliaryAssetsSize;
object.children = chunkGroup.children;
// - childAssets
}
},
module: {

@@ -647,2 +830,3 @@ _: (object, module, context, options, factory) => {

object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.reasons, context);
// object.filteredReasons
},

@@ -758,3 +942,19 @@ source: (object, module) => {

}
},
// chunkOrigin
error: EXTRACT_ERROR,
warning: EXTRACT_ERROR,
moduleTraceItem: {
_: (object, { origin, module }, context, { requestShortener }, factory) => {
object.originIdentifier = origin.identifier;
object.originName = origin.name;
object.moduleIdentifier = module.identifier;
object.moduleName = module.name;
},
ids: (object, { origin, module }) => {
object.originId = origin.id;
object.moduleId = module.id;
}
}
// moduleTraceDependency
};

@@ -811,6 +1011,6 @@ /**

}
// for (const key of Object.keys(MERGER)) {
// const merger = MERGER[key];
// stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
// }
for (const key of Object.keys(MERGER)) {
const merger = MERGER[key];
stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
}
});

@@ -817,0 +1017,0 @@ });

@@ -19,3 +19,3 @@ "use strict";

builtAt: true,
// relatedAssets: true,
relatedAssets: true,
entrypoints: true,

@@ -28,6 +28,6 @@ chunkGroups: true,

chunkModules: true,
// dependentModules: true,
// chunkOrigins: true,
dependentModules: true,
chunkOrigins: true,
depth: true,
// env: true,
env: true,
reasons: true,

@@ -37,4 +37,4 @@ usedExports: true,

optimizationBailout: true,
// errorDetails: true,
// errorStack: true,
errorDetails: true,
errorStack: true,
publicPath: true,

@@ -47,3 +47,3 @@ logging: "verbose",

// warningsSpace: Infinity,
modulesSpace: Infinity,
modulesSpace: Number.POSITIVE_INFINITY,
// chunkModulesSpace: Infinity,

@@ -57,3 +57,3 @@ // assetsSpace: Infinity,

builtAt: true,
// relatedAssets: true,
relatedAssets: true,
entrypoints: true,

@@ -65,3 +65,3 @@ chunkGroups: true,

chunkModules: false,
// chunkOrigins: true,
chunkOrigins: true,
depth: true,

@@ -71,3 +71,3 @@ usedExports: true,

optimizationBailout: true,
// errorDetails: true,
errorDetails: true,
publicPath: true,

@@ -104,3 +104,3 @@ logging: true,

// errorsSpace: Infinity,
// moduleTrace: true,
moduleTrace: true,
logging: "error"

@@ -158,3 +158,3 @@ },

chunkGroupChildren: OFF_FOR_TO_STRING,
chunkGroupMaxAssets: (o, { forToString }) => (forToString ? 5 : Infinity),
chunkGroupMaxAssets: (o, { forToString }) => forToString ? 5 : Number.POSITIVE_INFINITY,
chunks: OFF_FOR_TO_STRING,

@@ -190,5 +190,5 @@ chunkRelations: OFF_FOR_TO_STRING,

groupModulesByExtension: ON_FOR_TO_STRING,
modulesSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
chunkModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
nestedModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
modulesSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
chunkModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
nestedModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
relatedAssets: OFF_FOR_TO_STRING,

@@ -200,3 +200,3 @@ groupAssetsByEmitStatus: ON_FOR_TO_STRING,

groupAssetsByChunk: ON_FOR_TO_STRING,
assetsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
assetsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
orphanModules: OFF_FOR_TO_STRING,

@@ -214,3 +214,3 @@ runtimeModules: ({ all, runtime }, { forToString }) => runtime !== undefined

reasons: OFF_FOR_TO_STRING,
reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
reasonsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
groupReasonsByOrigin: ON_FOR_TO_STRING,

@@ -217,0 +217,0 @@ usedExports: OFF_FOR_TO_STRING,

@@ -370,3 +370,3 @@ "use strict";

// "error.stack": stack => stack,
// "error.moduleTrace": moduleTrace => undefined,
"error.moduleTrace": moduleTrace => undefined,
"error.separator!": () => "\n",

@@ -373,0 +373,0 @@ "loggingEntry(error).loggingEntry.message": (message, { red }) => mapLines(message, x => `<e> ${red(x)}`),

@@ -37,2 +37,10 @@ import type * as binding from "@rspack/binding";

export type StatsWarnings = binding.JsStatsWarning & Record<string, any>;
export type StatsModuleTraceItem = {
originIdentifier?: string;
originName?: string;
moduleIdentifier?: string;
moduleName?: string;
originId?: string;
moduleId?: string;
};
export type StatsModuleReason = binding.JsStatsModuleReason & Record<string, any>;

@@ -103,2 +111,6 @@ export type KnownStatsCompilation = {

asset: ExtractorsByOption<PreprocessedAsset, StatsAsset>;
chunkGroup: ExtractorsByOption<{
name: string;
chunkGroup: binding.JsStatsChunkGroup;
}, StatsChunkGroup>;
module: ExtractorsByOption<binding.JsStatsModule, StatsModule>;

@@ -110,2 +122,5 @@ module$visible: ExtractorsByOption<binding.JsStatsModule, StatsModule>;

chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
error: ExtractorsByOption<binding.JsStatsError, StatsError>;
warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
};

@@ -112,0 +127,0 @@ export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];

@@ -249,4 +249,4 @@ /*

static getModulesArrayBounds(modules) {
let maxId = -Infinity;
let minId = Infinity;
let maxId = Number.NEGATIVE_INFINITY;
let minId = Number.POSITIVE_INFINITY;
for (const module of modules) {

@@ -253,0 +253,0 @@ const moduleId = module.id;

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

/**
* @param {string} context context used to create relative path
* @param {string} identifier identifier used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} the returned relative path
*/
export function makePathsRelative(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
export namespace makePathsRelative {
interface ParsedResource {
resource: string;
path: string;
query: string;
fragment: string;
}
type ParsedResourceWithoutFragment = Omit<ParsedResource, "fragment">;
export declare const makePathsRelative: {
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
/**

@@ -13,3 +14,3 @@ * @param {Object=} associatedObjectForCache an object to which the cache will be attached

*/
function bindCache(associatedObjectForCache?: Object | undefined): (arg0: string, arg1: string) => string;
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
/**

@@ -20,59 +21,61 @@ * @param {string} context context used to create relative path

*/
function bindContextCache(context: string, associatedObjectForCache?: Object | undefined): (arg0: string) => string;
}
/**
* @param {string} context context used to create relative path
* @param {string} identifier identifier used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} the returned relative path
*/
export function makePathsAbsolute(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
export namespace makePathsAbsolute { }
/**
* @param {string} str the path with query and fragment
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {ParsedResource} parsed parts
*/
export function parseResource(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
export namespace parseResource {
function bindCache(associatedObjectForCache: any): (str: any) => any;
}
/**
* @param {string} str the path with query and fragment
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {ParsedResource} parsed parts
*/
export function parseResourceWithoutFragment(str: string, associatedObjectForCache?: Object | undefined): ParsedResource;
export namespace parseResourceWithoutFragment { }
export function getUndoPath(filename: string, outputPath: string, enforceRelative: boolean): string;
export type MakeRelativePathsCache = {
relativePaths?: Map<string, Map<string, string>> | undefined;
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
};
export type ParsedResource = {
resource: string;
path: string;
query: string;
fragment: string;
export declare const makePathsAbsolute: {
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
/**
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string, string): string} cached function
*/
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
/**
* @param {string} context context used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string): string} cached function
*/
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
};
export type ParsedResourceWithoutFragment = {
resource: string;
path: string;
query: string;
export declare const contextify: {
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
/**
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string, string): string} cached function
*/
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
/**
* @param {string} context context used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string): string} cached function
*/
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
};
export declare const absolutify: {
(context: string, identifier: string, associatedObjectForCache: object | undefined): string;
/**
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string, string): string} cached function
*/
bindCache(associatedObjectForCache: object | undefined): (arg0: string, arg1: string) => string;
/**
* @param {string} context context used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {function(string): string} cached function
*/
bindContextCache(context: string, associatedObjectForCache: object | undefined): (arg0: string) => string;
};
export declare const parseResource: {
(str: string, associatedObjectForCache?: object): ParsedResource;
bindCache(associatedObjectForCache: object): (str: string) => ParsedResource;
};
export declare const parseResourceWithoutFragment: {
(str: string, associatedObjectForCache?: object): ParsedResourceWithoutFragment;
bindCache(associatedObjectForCache: object): (str: string) => ParsedResourceWithoutFragment;
};
/**
* @param {string} context context used to create relative path
* @param {string} identifier identifier used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} the returned relative path
* @param {string} filename the filename which should be undone
* @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
* @param {boolean} enforceRelative true returns ./ for empty paths
* @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
*/
export function contextify(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
export namespace contextify { }
/**
* @param {string} context context used to create relative path
* @param {string} identifier identifier used to create relative path
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {string} the returned relative path
*/
export function absolutify(context: string, identifier: string, associatedObjectForCache?: Object | undefined): string;
export namespace absolutify { }
import path = require("path");
export declare const getUndoPath: (filename: string, outputPath: string, enforceRelative: boolean) => string;
export {};

@@ -0,15 +1,15 @@

"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict";
const path = require("path");
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUndoPath = exports.parseResourceWithoutFragment = exports.parseResource = exports.absolutify = exports.contextify = exports.makePathsAbsolute = exports.makePathsRelative = void 0;
const path_1 = __importDefault(require("path"));
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
/**
* @typedef {Object} MakeRelativePathsCache
* @property {Map<string, Map<string, string>>=} relativePaths
*/
// @ts-expect-error
const relativePathToRequest = relativePath => {
const relativePathToRequest = (relativePath) => {
if (relativePath === "")

@@ -40,3 +40,3 @@ return "./.";

: maybeAbsolutePath.slice(0, querySplitPos);
resource = relativePathToRequest(path.posix.relative(context, resource));
resource = relativePathToRequest(path_1.default.posix.relative(context, resource));
return querySplitPos === -1

@@ -51,3 +51,3 @@ ? resource

: maybeAbsolutePath.slice(0, querySplitPos);
resource = path.win32.relative(context, resource);
resource = path_1.default.win32.relative(context, resource);
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {

@@ -70,15 +70,11 @@ resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));

if (relativePath.startsWith("./") || relativePath.startsWith("../"))
return path.join(context, relativePath);
return path_1.default.join(context, relativePath);
return relativePath;
};
// @ts-expect-error
const makeCacheable = realFn => {
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
const makeCacheable = (realFn) => {
const cache = new WeakMap();
// @ts-expect-error
const getCache = associatedObjectForCache => {
const getCache = (associatedObjectForCache) => {
const entry = cache.get(associatedObjectForCache);
if (entry !== undefined)
return entry;
/** @type {Map<string, ParsedResource>} */
const map = new Map();

@@ -88,7 +84,2 @@ cache.set(associatedObjectForCache, map);

};
/**
* @param {string} str the path with query and fragment
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {ParsedResource} parsed parts
*/
const fn = (str, associatedObjectForCache) => {

@@ -105,7 +96,5 @@ if (!associatedObjectForCache)

};
// @ts-expect-error
fn.bindCache = associatedObjectForCache => {
fn.bindCache = (associatedObjectForCache) => {
const cache = getCache(associatedObjectForCache);
// @ts-expect-error
return str => {
return (str) => {
const entry = cache.get(str);

@@ -121,5 +110,3 @@ if (entry !== undefined)

};
// @ts-expect-error
const makeCacheableWithContext = fn => {
/** @type {WeakMap<object, Map<string, Map<string, string>>>} */
const makeCacheableWithContext = (fn) => {
const cache = new WeakMap();

@@ -135,2 +122,3 @@ /**

return fn(context, identifier);
/** @type {Map<string, Map<string, string>> | undefined} */
let innerCache = cache.get(associatedObjectForCache);

@@ -162,4 +150,3 @@ if (innerCache === undefined) {

*/
cachedFn.bindCache = associatedObjectForCache => {
// @ts-expect-error
cachedFn.bindCache = (associatedObjectForCache) => {
let innerCache;

@@ -183,7 +170,6 @@ if (associatedObjectForCache) {

let cachedResult;
// @ts-expect-error
let innerSubCache = innerCache.get(context);
let innerSubCache = innerCache?.get(context);
if (innerSubCache === undefined) {
// @ts-expect-error
innerCache.set(context, (innerSubCache = new Map()));
innerSubCache = new Map();
innerCache?.set(context, innerSubCache);
}

@@ -210,3 +196,2 @@ else {

cachedFn.bindContextCache = (context, associatedObjectForCache) => {
// @ts-expect-error
let innerSubCache;

@@ -231,5 +216,4 @@ if (associatedObjectForCache) {

*/
const boundFn = identifier => {
// @ts-expect-error
const cachedResult = innerSubCache.get(identifier);
const boundFn = (identifier) => {
const cachedResult = innerSubCache?.get(identifier);
if (cachedResult !== undefined) {

@@ -240,4 +224,3 @@ return cachedResult;

const result = fn(context, identifier);
// @ts-expect-error
innerSubCache.set(identifier, result);
innerSubCache?.set(identifier, result);
return result;

@@ -287,4 +270,3 @@ }

};
const contextify = makeCacheableWithContext(_contextify);
exports.contextify = contextify;
exports.contextify = makeCacheableWithContext(_contextify);
/**

@@ -301,8 +283,5 @@ * @param {string} context absolute context path

};
const absolutify = makeCacheableWithContext(_absolutify);
exports.absolutify = absolutify;
exports.absolutify = makeCacheableWithContext(_absolutify);
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
const PATH_QUERY_REGEXP = /^((?:\u200b.|[^?\u200b])*)(\?.*)?$/;
/** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
/** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
/**

@@ -312,11 +291,8 @@ * @param {string} str the path with query and fragment

*/
const _parseResource = str => {
const _parseResource = (str) => {
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
return {
resource: str,
// @ts-expect-error
path: match[1].replace(/\u200b(.)/g, "$1"),
// @ts-expect-error
query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : "",
// @ts-expect-error
fragment: match[3] || ""

@@ -331,9 +307,7 @@ };

*/
const _parseResourceWithoutFragment = str => {
const _parseResourceWithoutFragment = (str) => {
const match = PATH_QUERY_REGEXP.exec(str);
return {
resource: str,
// @ts-expect-error
path: match[1].replace(/\u200b(.)/g, "$1"),
// @ts-expect-error
query: match[2] ? match[2].replace(/\u200b(.)/g, "$1") : ""

@@ -349,3 +323,3 @@ };

*/
exports.getUndoPath = (filename, outputPath, enforceRelative) => {
const getUndoPath = (filename, outputPath, enforceRelative) => {
let depth = -1;

@@ -379,1 +353,2 @@ let append = "";

};
exports.getUndoPath = getUndoPath;
{
"name": "@rspack/core",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"webpackVersion": "5.75.0",

@@ -42,2 +42,3 @@ "license": "MIT",

"@types/watchpack": "^2.4.0",
"@types/webpack-sources": "3.2.3",
"browserslist": "^4.21.3",

@@ -47,2 +48,3 @@ "cross-env": "^7.0.3",

"graceful-fs": "4.2.10",
"@types/graceful-fs": "4.1.9",
"json-parse-even-better-errors": "^3.0.0",

@@ -54,2 +56,3 @@ "neo-async": "2.6.2",

"webpack-sources": "3.2.3",
"webpack-dev-server": "4.13.1",
"zod": "^3.21.4",

@@ -61,4 +64,4 @@ "zod-validation-error": "1.3.1"

"caniuse-lite": "^1.0.30001616",
"@rspack/binding": "1.0.0-alpha.3",
"@rspack/lite-tapable": "1.0.0-alpha.3"
"@rspack/lite-tapable": "1.0.0-alpha.4",
"@rspack/binding": "1.0.0-alpha.4"
},

@@ -65,0 +68,0 @@ "peerDependencies": {

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

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

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

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc