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 9.0.0 to 10.0.0

4

bin.js
#!/usr/bin/env node
require('./run.js')(process)
import run from './run.js'
run(process)

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

module.exports = async function calc(plugins, config, createSpinner) {
export default async function calc(plugins, config, createSpinner) {
process.setMaxListeners(config.checks.reduce((a, i) => a + i.files.length, 1))

@@ -10,13 +10,9 @@

}
if (plugin['step' + number] || plugin['all' + number]) {
if (plugin['step' + 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)
})
)
}
await Promise.all(
config.checks.map(i => {
return plugin['step' + number](config, i)
})
)
} catch (e) {

@@ -23,0 +19,0 @@ if (spinner) spinner.error()

@@ -1,6 +0,9 @@

let { bold: b, red, yellow: y } = require('picocolors')
let { existsSync } = require('fs')
let { join } = require('path')
import { existsSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import pc from 'picocolors'
const require = createRequire(import.meta.url)
let ownPackage = require('./package.json')
const { bold: b, red, yellow: y } = pc
const ownPackage = require('./package.json')

@@ -20,3 +23,3 @@ function npmCommands(pkg) {

module.exports = process => {
export default process => {
function print(...lines) {

@@ -23,0 +26,0 @@ process.stdout.write(lines.join('\n') + '\n')

@@ -1,14 +0,7 @@

let {
bgGreen,
bgRed,
black,
bold,
gray,
green,
red,
yellow
} = require('picocolors')
let { join } = require('path')
let bytes = require('bytes-iec')
import bytes from 'bytes-iec'
import { join } from 'node:path'
import pc from 'picocolors'
const { bgGreen, bgRed, black, bold, gray, green, red, yellow } = pc
function createJsonReporter(process) {

@@ -201,3 +194,3 @@ function print(data) {

module.exports = (process, isJSON, isSilentMode) => {
export default (process, isJSON, isSilentMode) => {
if (isJSON) {

@@ -204,0 +197,0 @@ return createJsonReporter(process)

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

module.exports = {
export default {
error(process, args, config) {

@@ -3,0 +3,0 @@ if (args && args.debug) {

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

let { dirname, isAbsolute, join, relative } = require('path')
let { lilconfig } = require('lilconfig')
let globby = require('globby')
let bytes = require('bytes-iec')
import bytes from 'bytes-iec'
import { globby } from 'globby'
import { lilconfig } from 'lilconfig'
import { dirname, isAbsolute, join, relative } from 'node:path'
let SizeLimitError = require('./size-limit-error')
import { SizeLimitError } from './size-limit-error.js'

@@ -82,3 +82,3 @@ let OPTIONS = {

module.exports = async function getConfig(plugins, process, args, pkg) {
export default async function getConfig(plugins, process, args, pkg) {
let config = {

@@ -85,0 +85,0 @@ cwd: process.cwd()

@@ -1,3 +0,3 @@

let { Plugins } = require('./load-plugins')
let calc = require('./calc')
import calc from './calc'
import { Plugins } from './load-plugins'

@@ -11,3 +11,3 @@ /**

*/
module.exports = async function (plugins, files) {
export default async function (plugins, files) {
let pluginList = new Plugins(plugins.reduce((all, i) => all.concat(i), []))

@@ -14,0 +14,0 @@ if (Array.isArray(files)) {

@@ -0,1 +1,4 @@

import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
function toArray(obj) {

@@ -5,3 +8,3 @@ return typeof obj === 'object' ? Object.keys(obj) : []

class Plugins {
export class Plugins {
constructor(list) {

@@ -19,22 +22,20 @@ this.list = list

module.exports = function loadPlugins(pkg) {
export default async function loadPlugins(pkg) {
if (!pkg || !pkg.packageJson) return new Plugins([])
let list = toArray(pkg.packageJson.dependencies)
.concat(toArray(pkg.packageJson.devDependencies))
.concat(toArray(pkg.packageJson.optionalDependencies))
.filter(i => i.startsWith('@size-limit/') || i.startsWith('size-limit-'))
.reduce(
(all, i) =>
all.concat(
require(require.resolve(i, {
let list = await Promise.all(
toArray(pkg.packageJson.dependencies)
.concat(toArray(pkg.packageJson.devDependencies))
.concat(toArray(pkg.packageJson.optionalDependencies))
.filter(i => i.startsWith('@size-limit/') || i.startsWith('size-limit-'))
.map(i =>
import(
require.resolve(i, {
paths: [process.cwd()]
}))
),
[]
)
})
).then(module => module.default)
)
).then(arr => arr.flat())
return new Plugins(list)
}
module.exports.Plugins = Plugins
{
"name": "size-limit",
"version": "9.0.0",
"version": "10.0.0",
"description": "CLI tool for Size Limit",
"type": "module",
"keywords": [

@@ -23,3 +24,3 @@ "size-limit",

"chokidar": "^3.5.3",
"globby": "^11.1.0",
"globby": "^13.2.2",
"lilconfig": "^2.1.0",

@@ -26,0 +27,0 @@ "nanospinner": "^1.1.0",

@@ -1,4 +0,4 @@

let SizeLimitError = require('./size-limit-error')
import { SizeLimitError } from './size-limit-error.js'
module.exports = function parseArgs(plugins, argv) {
export default function parseArgs(plugins, argv) {
let args = { files: [] }

@@ -51,3 +51,8 @@ for (let i = 2; i < argv.length; i++) {

if (!plugins.has('webpack') || !plugins.has('webpack-why')) {
throw new SizeLimitError('argWithoutAnalyzer', 'compare-with', 'webpack', 'webpack-why')
throw new SizeLimitError(
'argWithoutAnalyzer',
'compare-with',
'webpack',
'webpack-why'
)
}

@@ -63,3 +68,3 @@ if (!args.why) {

} else if (arg === '--watch') {
/* istanbul ignore next */
/* c8 ignore next */
args.watch = true

@@ -66,0 +71,0 @@ } else if (arg === '--highlight-less') {

@@ -1,5 +0,5 @@

let { mkdir, writeFile } = require('fs').promises
let { join } = require('path')
import { mkdir, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
module.exports = async function processImport(check, output) {
export default async function processImport(check, output) {
if (!check.import) {

@@ -6,0 +6,0 @@ return

@@ -1,4 +0,4 @@

let { dirname, parse, resolve } = require('path')
let { existsSync } = require('fs')
let { readFile } = require('fs').promises
import { existsSync } from 'node:fs'
import { readFile } from 'node:fs/promises'
import { dirname, parse, resolve } from 'node:path'

@@ -15,3 +15,3 @@ async function readPkg(cwd) {

while (true) {
let foundPath = await resolve(directory, name)
let foundPath = resolve(directory, name)

@@ -30,3 +30,3 @@ if (existsSync(foundPath)) {

module.exports = async cwd => {
export default async cwd => {
let filePath = await findUp('package.json', cwd)

@@ -33,0 +33,0 @@

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

let { existsSync } = require('fs')
let fs = require('fs').promises
import { existsSync } from 'node:fs'
import fs from 'node:fs/promises'
module.exports = async function rm(dir) {
export default async function rm(dir) {
if (!fs.rm) {
/* istanbul ignore next */
/* c8 ignore next 3 */
if (existsSync(dir)) {

@@ -8,0 +8,0 @@ await fs.rmdir(dir, { recursive: true })

@@ -1,18 +0,18 @@

let { createSpinner } = require('nanospinner')
let { resolve } = require('path')
let chokidar = require('chokidar')
import chokidar from 'chokidar'
import { createSpinner } from 'nanospinner'
import { resolve } from 'node:path'
let SizeLimitError = require('./size-limit-error')
let createReporter = require('./create-reporter')
let loadPlugins = require('./load-plugins')
let createHelp = require('./create-help')
let readPkgUp = require('./read-pkg-up')
let getConfig = require('./get-config')
let parseArgs = require('./parse-args')
let debug = require('./debug')
let calc = require('./calc')
import calc from './calc.js'
import createHelp from './create-help.js'
import createReporter from './create-reporter.js'
import debug from './debug.js'
import getConfig from './get-config.js'
import loadPlugins from './load-plugins.js'
import parseArgs from './parse-args.js'
import readPkgUp from './read-pkg-up.js'
import { SizeLimitError } from './size-limit-error.js'
/* c8 ignore next 10 */
function throttle(fn) {
let next, running
// istanbul ignore next
return () => {

@@ -28,3 +28,3 @@ clearTimeout(next)

async function findPlugins(parentPkg) {
let plugins = loadPlugins(parentPkg)
let plugins = await loadPlugins(parentPkg)

@@ -42,3 +42,3 @@ if (!parentPkg || !plugins.isEmpty) return plugins

module.exports = async process => {
export default async process => {
function hasArg(arg) {

@@ -87,3 +87,3 @@ return process.argv.includes(arg)

/* istanbul ignore if */
/* c8 ignore next 6 */
if (hasArg('--watch')) {

@@ -90,0 +90,0 @@ let watcher = chokidar.watch(['**/*'], {

@@ -55,3 +55,3 @@ const MESSAGES = {

class SizeLimitError extends Error {
export class SizeLimitError extends Error {
constructor(type, ...args) {

@@ -71,3 +71,1 @@ super(MESSAGES[type](...args))

}
module.exports = SizeLimitError
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