@rspack/core
Advanced tools
Comparing version 0.0.0-760f8b6f15-20221110061725 to 0.0.0-8aa81b497b-20221110072134
@@ -222,11 +222,4 @@ "use strict"; | ||
let stats = new stats_1.Stats(rawStats); | ||
if (stats.hasErrors()) { | ||
console.log(stats.toString({ | ||
all: false, | ||
warnings: true, | ||
errors: true, | ||
...this.options.stats | ||
})); | ||
} | ||
// TODO: log stats string should move to cli | ||
console.log(stats.toString(this.options.stats)); | ||
console.log("build success, time cost", Date.now() - begin, "ms"); | ||
@@ -253,10 +246,3 @@ let pendingChangedFilepaths = new Set(); | ||
// TODO: log stats string should move to cli | ||
if (stats.hasErrors()) { | ||
console.log(stats.toString({ | ||
all: false, | ||
warnings: true, | ||
errors: true, | ||
...this.options.stats | ||
})); | ||
} | ||
console.log(stats.toString(this.options.stats)); | ||
isBuildFinished = true; | ||
@@ -263,0 +249,0 @@ const hasPending = Boolean(pendingChangedFilepaths.size); |
@@ -56,2 +56,3 @@ import type { Context, ResolvedContext } from "./context"; | ||
export { resolveWatchOption } from "./watch"; | ||
export type { StatsOptions } from "./stats"; | ||
//# sourceMappingURL=index.d.ts.map |
import * as binding from "@rspack/binding"; | ||
export declare type ResolvedStatsOptions = binding.RawStatsOptions; | ||
export interface StatsOptions { | ||
colors?: boolean; | ||
export interface StatsOptionsObj { | ||
all?: boolean; | ||
preset?: "normal" | "none" | "verbose" | "errors-only" | "errors-warnings"; | ||
assets?: boolean; | ||
chunks?: boolean; | ||
modules?: boolean; | ||
entrypoints?: boolean; | ||
warnings?: boolean; | ||
warningsCount?: boolean; | ||
errors?: boolean; | ||
errorsCount?: boolean; | ||
colors?: boolean; | ||
} | ||
export declare function resolveStatsOptions(options?: StatsOptions): ResolvedStatsOptions; | ||
export declare type StatsOptions = StatsOptionsObj | boolean | string; | ||
/** | ||
* resolve `StatsOptions` to `binding.RawStatsOptions`. | ||
*/ | ||
export declare function resolveStatsOptions(opts?: StatsOptions): ResolvedStatsOptions; | ||
//# sourceMappingURL=stats.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveStatsOptions = void 0; | ||
function resolveStatsOptions(options = {}) { | ||
const colors = optionsOrFallback(options.colors, false); | ||
const stats_1 = require("../stats"); | ||
/** | ||
* resolve `StatsOptions` to `binding.RawStatsOptions`. | ||
*/ | ||
function resolveStatsOptions(opts = {}) { | ||
const options = (0, stats_1.normalizeStatsPreset)(opts); | ||
const colors = (0, stats_1.optionsOrFallback)(options.colors, false); | ||
return { | ||
...options, | ||
colors | ||
@@ -11,7 +17,2 @@ }; | ||
exports.resolveStatsOptions = resolveStatsOptions; | ||
const optionsOrFallback = (...args) => { | ||
let optionValues = []; | ||
optionValues.push(...args); | ||
return optionValues.find(optionValue => optionValue !== undefined); | ||
}; | ||
//# sourceMappingURL=stats.js.map |
import * as binding from "@rspack/binding"; | ||
import { StatsOptions } from "./config/stats"; | ||
export declare type StatsCompilation = Omit<binding.StatsCompilation, "entrypoints"> & { | ||
import { StatsOptions, StatsOptionsObj } from "./config/stats"; | ||
declare type StatsCompilationInner = Omit<binding.StatsCompilation, "entrypoints"> & { | ||
entrypoints: Record<string, binding.StatsEntrypoint>; | ||
}; | ||
export declare type StatsCompilation = Partial<StatsCompilationInner> & { | ||
filteredModules?: number; | ||
}; | ||
export declare class Stats { | ||
@@ -10,6 +13,10 @@ #private; | ||
hasErrors(): boolean; | ||
toJson(options?: StatsOptions): StatsCompilation; | ||
toString(options?: StatsOptions): string; | ||
hasWarnings(): boolean; | ||
toJson(opts?: StatsOptions, forToString?: boolean): StatsCompilation; | ||
toString(opts?: StatsOptions): string; | ||
static jsonToString(obj: any, useColors: boolean): string; | ||
} | ||
export declare const optionsOrFallback: (...args: any[]) => any; | ||
export declare function normalizeStatsPreset(options?: StatsOptions): StatsOptionsObj; | ||
export {}; | ||
//# sourceMappingURL=stats.d.ts.map |
@@ -15,4 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Stats = void 0; | ||
const stats_1 = require("./config/stats"); | ||
exports.normalizeStatsPreset = exports.optionsOrFallback = exports.Stats = void 0; | ||
const Logger_1 = require("./logging/Logger"); | ||
@@ -34,12 +33,54 @@ class Stats { | ||
} | ||
toJson(options) { | ||
return __classPrivateFieldGet(this, _Stats_statsJson, "f"); | ||
hasWarnings() { | ||
return __classPrivateFieldGet(this, _Stats_statsJson, "f").warningsCount > 0; | ||
} | ||
toString(options) { | ||
options = (0, stats_1.resolveStatsOptions)(options); | ||
const obj = this.toJson(options); | ||
obj.filteredModules = obj.modules.length - 15; | ||
obj.modules = obj.modules.slice(0, 15); | ||
return Stats.jsonToString(obj, options.colors); | ||
toJson(opts, forToString) { | ||
const options = normalizeStatsPreset(opts); | ||
const all = options.all; | ||
const optionOrLocalFallback = (v, def) => v !== undefined ? v : all !== undefined ? all : def; | ||
const showAssets = optionOrLocalFallback(options.assets, true); | ||
const showChunks = optionOrLocalFallback(options.chunks, !forToString); | ||
const showModules = optionOrLocalFallback(options.modules, true); | ||
const showEntrypoints = optionOrLocalFallback(options.entrypoints, true); | ||
const showErrors = optionOrLocalFallback(options.errors, true); | ||
const showErrorsCount = optionOrLocalFallback(options.errorsCount, true); | ||
const showWarninigs = optionOrLocalFallback(options.warnings, true); | ||
const showWarningsCount = optionOrLocalFallback(options.warningsCount, true); | ||
let obj = {}; | ||
if (showAssets) { | ||
obj.assets = __classPrivateFieldGet(this, _Stats_statsJson, "f").assets; | ||
} | ||
if (showChunks) { | ||
obj.chunks = __classPrivateFieldGet(this, _Stats_statsJson, "f").chunks; | ||
} | ||
if (showModules) { | ||
obj.modules = __classPrivateFieldGet(this, _Stats_statsJson, "f").modules; | ||
} | ||
if (showEntrypoints) { | ||
obj.entrypoints = __classPrivateFieldGet(this, _Stats_statsJson, "f").entrypoints; | ||
} | ||
if (showErrors) { | ||
obj.errors = __classPrivateFieldGet(this, _Stats_statsJson, "f").errors; | ||
} | ||
if (showErrorsCount) { | ||
obj.errorsCount = __classPrivateFieldGet(this, _Stats_statsJson, "f").errorsCount; | ||
} | ||
if (showWarninigs) { | ||
obj.warnings = __classPrivateFieldGet(this, _Stats_statsJson, "f").warnings; | ||
} | ||
if (showWarningsCount) { | ||
obj.warningsCount = __classPrivateFieldGet(this, _Stats_statsJson, "f").warningsCount; | ||
} | ||
if (obj.modules && forToString) { | ||
obj.filteredModules = obj.modules.length - 15; | ||
obj.modules = obj.modules.slice(0, 15); | ||
} | ||
return obj; | ||
} | ||
toString(opts) { | ||
const options = normalizeStatsPreset(opts); | ||
const useColors = (0, exports.optionsOrFallback)(options.colors, false); | ||
const obj = this.toJson(options, true); | ||
return Stats.jsonToString(obj, useColors); | ||
} | ||
static jsonToString(obj, useColors) { | ||
@@ -781,2 +822,52 @@ var _a, _b, _c; | ||
}; | ||
const optionsOrFallback = (...args) => { | ||
let optionValues = []; | ||
optionValues.push(...args); | ||
return optionValues.find(optionValue => optionValue !== undefined); | ||
}; | ||
exports.optionsOrFallback = optionsOrFallback; | ||
function normalizeStatsPreset(options) { | ||
if (typeof options === "boolean" || typeof options === "string") | ||
return presetToOptions(options); | ||
else if (!options) | ||
return {}; | ||
else { | ||
let obj = { ...presetToOptions(options.preset), ...options }; | ||
delete obj.preset; | ||
return obj; | ||
} | ||
} | ||
exports.normalizeStatsPreset = normalizeStatsPreset; | ||
function presetToOptions(name) { | ||
const pn = (typeof name === "string" && name.toLowerCase()) || name; | ||
switch (pn) { | ||
case "none": | ||
return { | ||
all: false | ||
}; | ||
case "verbose": | ||
return { | ||
all: true | ||
}; | ||
case "errors-only": | ||
return { | ||
all: false, | ||
errors: true, | ||
errorsCount: true | ||
// TODO: moduleTrace: true, | ||
// TODO: logging: "error" | ||
}; | ||
case "errors-warnings": | ||
return { | ||
all: false, | ||
errors: true, | ||
errorsCount: true, | ||
warnings: true, | ||
warningsCount: true | ||
// TODO: logging: "warn" | ||
}; | ||
default: | ||
return {}; | ||
} | ||
} | ||
//# sourceMappingURL=stats.js.map |
{ | ||
"name": "@rspack/core", | ||
"version": "0.0.0-760f8b6f15-20221110061725", | ||
"version": "0.0.0-8aa81b497b-20221110072134", | ||
"main": "./dist/index.js", | ||
@@ -10,3 +10,3 @@ "types": "./dist/index.d.ts", | ||
"devDependencies": { | ||
"@rspack/core": "0.0.0-760f8b6f15-20221110061725", | ||
"@rspack/core": "0.0.0-8aa81b497b-20221110072134", | ||
"@swc/helpers": "^0.4.12", | ||
@@ -28,6 +28,6 @@ "@types/jest": "29.0.2", | ||
"dependencies": { | ||
"@rspack/binding": "0.0.0-760f8b6f15-20221110061725", | ||
"@rspack/dev-client": "0.0.0-760f8b6f15-20221110061725", | ||
"@rspack/plugin-less": "^0.0.0-760f8b6f15-20221110061725", | ||
"@rspack/plugin-postcss": "^0.0.0-760f8b6f15-20221110061725", | ||
"@rspack/binding": "0.0.0-8aa81b497b-20221110072134", | ||
"@rspack/dev-client": "0.0.0-8aa81b497b-20221110072134", | ||
"@rspack/plugin-less": "^0.0.0-8aa81b497b-20221110072134", | ||
"@rspack/plugin-postcss": "^0.0.0-8aa81b497b-20221110072134", | ||
"browserslist": "^4.21.3", | ||
@@ -34,0 +34,0 @@ "chokidar": "3.5.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
283779
4107
+ Added@rspack/binding@0.0.0-8aa81b497b-20221110072134(transitive)
+ Added@rspack/dev-client@0.0.0-8aa81b497b-20221110072134(transitive)
- Removed@rspack/binding@0.0.0-760f8b6f15-20221110061725(transitive)
- Removed@rspack/dev-client@0.0.0-760f8b6f15-20221110061725(transitive)
Updated@rspack/plugin-postcss@^0.0.0-8aa81b497b-20221110072134