Skip to content

Commit

Permalink
Replace globby with tinyglobby (#372)
Browse files Browse the repository at this point in the history
* Replace `globby` with `tinyglobby`

* Update references in the README
  • Loading branch information
ziebam authored Sep 9, 2024
1 parent 8d8bb51 commit 58d9f37
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ If you use Size Limit to track the size of CSS files, make sure to set
inserts `style-loader` runtime (≈2 kB) into the bundle.
[Statoscope docs]: https://github.com/statoscope/statoscope/tree/master/packages/webpack-plugin#optionsreports-report
[pattern]: https://github.com/sindresorhus/globby#globbing-patterns
[pattern]: https://github.com/SuperchupuDev/tinyglobby
## Analyze with `--why`
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions packages/size-limit/get-config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import bytes from 'bytes-iec'
import { globby } from 'globby'
import { lilconfig } from 'lilconfig'
import { createRequire } from 'node:module'
import { dirname, isAbsolute, join, relative } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'
import { glob } from 'tinyglobby'

import { SizeLimitError } from './size-limit-error.js'

Expand Down Expand Up @@ -154,7 +154,8 @@ export default async function getConfig(plugins, process, args, pkg) {
result.config.map(async check => {
let processed = { ...check }
if (check.path) {
processed.files = await globby(check.path, { cwd: config.cwd })
let patterns = Array.isArray(check.path) ? check.path : [check.path]
processed.files = await glob(patterns, { cwd: config.cwd })
} else if (!check.entry) {
if (pkg.packageJson.main) {
processed.files = [
Expand Down
2 changes: 1 addition & 1 deletion packages/size-limit/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface Check {
/**
* Relative paths to files. The only mandatory option.
* It could be a path `"index.js"`, a
* {@link https://github.com/sindresorhus/globby#globbing-patterns pattern}
* {@link https://github.com/SuperchupuDev/tinyglobby pattern}
* `"dist/app-*.js"` or an array
* `["index.js", "dist/app-*.js", "!dist/app-exclude.js"]`.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/size-limit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"dependencies": {
"bytes-iec": "^3.1.1",
"chokidar": "^3.6.0",
"globby": "^14.0.1",
"jiti": "^1.21.0",
"lilconfig": "^3.1.1",
"nanospinner": "^1.1.0",
"picocolors": "^1.0.1"
"picocolors": "^1.0.1",
"tinyglobby": "^0.2.6"
},
"devDependencies": {
"@size-limit/esbuild": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions packages/size-limit/test/__snapshots__/run.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ exports[`supports import and ignore for esbuild and gzip 1`] = `

exports[`supports path without dot 1`] = `
"
[42m[30mPackage size is 77 B less than limit[39m[49m
[42m[30mPackage size is 73 B less than limit[39m[49m
Size limit: 200 B
Size: [32m[1m123 B[22m[39m [90mwith all dependencies, minified and brotlied[39m
Size: [32m[1m127 B[22m[39m [90mwith all dependencies, minified and brotlied[39m
"
`;
Expand Down
10 changes: 5 additions & 5 deletions packages/size-limit/test/get-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ it('creates config by CLI arguments', async () => {
})
})

it('supports globby and main field', async () => {
expect(await check('globby')).toEqual({
it('supports tinyglobby and main field', async () => {
expect(await check('tinyglobby')).toEqual({
checks: [
{
files: [fixture('globby', 'a1.js'), fixture('globby', 'a2.js')],
files: [fixture('tinyglobby', 'a1.js'), fixture('tinyglobby', 'a2.js')],
limit: '1 kB',
name: 'a',
path: ['a*.js'],
sizeLimit: 1000
},
{
files: [fixture('globby', 'b1.js')],
files: [fixture('tinyglobby', 'b1.js')],
name: 'b'
}
],
configPath: 'package.json',
cwd: fixture('globby')
cwd: fixture('tinyglobby')
})
})

Expand Down
37 changes: 34 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58d9f37

Please sign in to comment.