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

size-limit

Package Overview
Dependencies
Maintainers
1
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

size-limit - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

39

calc.js

@@ -1,10 +0,25 @@

module.exports = async function calc (plugins, config) {
async function exec (step) {
module.exports = async function calc (plugins, config, createSpinner) {
process.setMaxListeners(config.checks.reduce((a, i) => a + i.path.length, 0))
async function step (number) {
for (let plugin of plugins.list) {
if (plugin[step]) {
process.setMaxListeners(config.checks.reduce((all, check) => {
return all + check.path.length
}, 0))
await Promise.all(config.checks.map(i => plugin[step](config, i)))
let spinner
if (plugin['wait' + number] && createSpinner) {
spinner = createSpinner(plugin['wait' + number]).start()
}
if (plugin['step' + number] || plugin['all' + number]) {
try {
if (plugin['all' + number]) {
await plugin['all' + number](config)
} else {
await Promise.all(config.checks.map(i => {
return plugin['step' + number](config, i)
}))
}
} catch (e) {
if (spinner) spinner.fail()
throw e
}
}
if (spinner) spinner.succeed()
}

@@ -14,5 +29,11 @@ }

try {
for (let i = 0; i <= 100; i++) await exec(`step${ i }`)
for (let i = 0; i <= 100; i++) await step(i)
} finally {
exec('finally')
for (let plugin of plugins.list) {
if (plugin.finally) {
await Promise.all(config.checks.map(i => {
return plugin.finally(config, i)
}))
}
}
}

@@ -19,0 +40,0 @@ for (let check of config.checks) {

@@ -68,3 +68,3 @@ let { isAbsolute, dirname, join, relative } = require('path')

function makeAbsolute (file, cwd) {
function toAbsolute (file, cwd) {
return isAbsolute(file) ? file : join(cwd, file)

@@ -78,3 +78,5 @@ }

module.exports = async function getConfig (plugins, process, args, pkg) {
let config = { }
let config = {
cwd: process.cwd()
}
if (args.why) {

@@ -85,8 +87,6 @@ config.project = pkg.packageJson.name

if (args.saveBundle) {
config.saveBundle = makeAbsolute(args.saveBundle, process.cwd())
config.saveBundle = toAbsolute(args.saveBundle, process.cwd())
}
let cwd
if (args.files.length > 0) {
cwd = process.cwd()
config.checks = [{ path: args.files }]

@@ -108,6 +108,6 @@ } else {

config.configPath = relative(process.cwd(), result.filepath)
cwd = dirname(result.filepath)
config.cwd = dirname(result.filepath)
config.checks = await Promise.all(result.config.map(async check => {
if (check.path) {
check.path = await globby(check.path, { cwd: dirname(result.filepath) })
check.path = await globby(check.path, { cwd: config.cwd })
} else if (!check.entry) {

@@ -130,3 +130,3 @@ if (pkg.packageJson.main) {

if (check.entry && !Array.isArray(check.entry)) check.entry = [check.entry]
if (!check.name) check.name = toName(check.entry || check.path, cwd)
if (!check.name) check.name = toName(check.entry || check.path, config.cwd)
if (args.limit) check.limit = args.limit

@@ -145,4 +145,4 @@ if (check.limit) {

}
if (check.path) check.path = check.path.map(i => makeAbsolute(i, cwd))
if (check.config) check.config = makeAbsolute(check.config, cwd)
if (check.path) check.path = check.path.map(i => toAbsolute(i, config.cwd))
if (check.config) check.config = toAbsolute(check.config, config.cwd)
}

@@ -149,0 +149,0 @@

@@ -19,3 +19,3 @@ let { Plugins } = require('./load-plugins')

await calc(pluginList, files)
await calc(pluginList, files, false)

@@ -22,0 +22,0 @@ return files.checks.map(i => {

{
"name": "size-limit",
"version": "4.1.1",
"version": "4.2.0",
"description": "CLI tool for Size Limit",

@@ -8,2 +8,3 @@ "keywords": [

"cli",
"esm",
"performance",

@@ -26,4 +27,5 @@ "budget",

"globby": "^11.0.0",
"ora": "^4.0.3",
"read-pkg-up": "^7.0.1"
}
}
let readPkgUp = require('read-pkg-up')
let ora = require('ora')

@@ -45,3 +46,3 @@ let SizeLimitError = require('./size-limit-error')

await calc(plugins, config)
await calc(plugins, config, ora)

@@ -48,0 +49,0 @@ debug.results(process, args, config)

@@ -54,2 +54,5 @@ const MESSAGES = {

'Update your Node.js to version >= v11.7.0 to use Brotli'
),
cmdError: (cmd, error) => (
error ? `${ cmd } error: ${ error }` : `${ cmd } error`
)

@@ -56,0 +59,0 @@ }

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