Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serwist/webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serwist/webpack-plugin - npm Package Compare versions

Comparing version 8.0.3 to 8.0.4

dist/index.internal.old.d.cts

105

dist/index.js
import path from 'node:path';
import { transformManifest, getSourceMapURL, validateWebpackInjectManifestOptions, escapeRegExp, replaceAndUpdateSourceMap } from '@serwist/build';
import stringify from 'fast-json-stable-stringify';
import prettyBytes from 'pretty-bytes';
import upath from 'upath';

@@ -9,2 +8,106 @@ import webpack from 'webpack';

const BYTE_UNITS = [
'B',
'kB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
];
const BIBYTE_UNITS = [
'B',
'KiB',
'MiB',
'GiB',
'TiB',
'PiB',
'EiB',
'ZiB',
'YiB'
];
const BIT_UNITS = [
'b',
'kbit',
'Mbit',
'Gbit',
'Tbit',
'Pbit',
'Ebit',
'Zbit',
'Ybit'
];
const BIBIT_UNITS = [
'b',
'kibit',
'Mibit',
'Gibit',
'Tibit',
'Pibit',
'Eibit',
'Zibit',
'Yibit'
];
/*
Formats the given number using `Number#toLocaleString`.
- If locale is a string, the value is expected to be a locale-key (for example: `de`).
- If locale is true, the system default locale is used for translation.
- If no value for locale is specified, the number is returned unmodified.
*/ const toLocaleString = (number, locale, options)=>{
let result = number;
if (typeof locale === 'string' || Array.isArray(locale)) {
result = number.toLocaleString(locale, options);
} else if (locale === true || options !== undefined) {
result = number.toLocaleString(undefined, options);
}
return result;
};
function prettyBytes(number, options) {
if (!Number.isFinite(number)) {
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
}
options = {
bits: false,
binary: false,
space: true,
...options
};
const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
const separator = options.space ? ' ' : '';
if (options.signed && number === 0) {
return ` 0${separator}${UNITS[0]}`;
}
const isNegative = number < 0;
const prefix = isNegative ? '-' : options.signed ? '+' : '';
if (isNegative) {
number = -number;
}
let localeOptions;
if (options.minimumFractionDigits !== undefined) {
localeOptions = {
minimumFractionDigits: options.minimumFractionDigits
};
}
if (options.maximumFractionDigits !== undefined) {
localeOptions = {
maximumFractionDigits: options.maximumFractionDigits,
...localeOptions
};
}
if (number < 1) {
const numberString = toLocaleString(number, options.locale, localeOptions);
return prefix + numberString + separator + UNITS[0];
}
const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
number /= (options.binary ? 1024 : 1000) ** exponent;
if (!localeOptions) {
number = number.toPrecision(3);
}
const numberString = toLocaleString(Number(number), options.locale, localeOptions);
const unit = UNITS[exponent];
return prefix + numberString + separator + unit;
}
/**

@@ -11,0 +114,0 @@ * @param asset

34

package.json
{
"name": "@serwist/webpack-plugin",
"version": "8.0.3",
"version": "8.0.4",
"type": "module",

@@ -40,10 +40,20 @@ "description": "A plugin for your Webpack build process, helping you generate a manifest of local files that should be precached.",

".": {
"import": "./dist/index.js",
"require": "./dist/index.old.cjs",
"types": "./dist/index.d.ts"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.old.d.cts",
"default": "./dist/index.old.cjs"
}
},
"./internal": {
"import": "./dist/index.internal.js",
"require": "./dist/index.internal.old.cjs",
"types": "./dist/index.internal.d.ts"
"import": {
"types": "./dist/index.internal.d.ts",
"default": "./dist/index.internal.js"
},
"require": {
"types": "./dist/index.internal.old.d.cts",
"default": "./dist/index.internal.old.cjs"
}
},

@@ -54,6 +64,5 @@ "./package.json": "./package.json"

"fast-json-stable-stringify": "2.1.0",
"pretty-bytes": "6.1.1",
"rollup": "3.28.1",
"upath": "2.0.1",
"@serwist/build": "8.0.3"
"@serwist/build": "8.0.4"
},

@@ -64,5 +73,6 @@ "peerDependencies": {

"devDependencies": {
"@types/node": "20.8.7",
"@types/webpack": "5.28.3",
"@serwist/constants": "8.0.3"
"@types/node": "20.10.4",
"@types/webpack": "5.28.5",
"pretty-bytes": "6.1.1",
"@serwist/constants": "8.0.4"
},

@@ -69,0 +79,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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