Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace globby with tinyglobby #372

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`] = `
"
Package size is 77 B less than limit
Package size is 73 B less than limit
Size limit: 200 B
Size: 123 B with all dependencies, minified and brotlied
Size: 127 B with all dependencies, minified and brotlied

"
`;
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.

Loading