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

Add support for TypeScript config files (.size-limit.ts, .size-limit.mts, .size-limit.cts) #355

Merged
merged 28 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
724c896
Add `jiti` to dependencies
aryaemami59 Mar 12, 2024
cd4418f
Add support for loading TypeScript config files dynamically
aryaemami59 Mar 12, 2024
9cc2224
Test all config file extension/module type combos with fixtures.
aryaemami59 Mar 12, 2024
99b3d50
Manually define `__filename`
aryaemami59 Mar 12, 2024
3556e71
Increase the `timeout` to accommodate the new added number of tests
aryaemami59 Mar 12, 2024
fa1d20a
Shorten test descriptions in `get-config.test.js`
aryaemami59 Mar 12, 2024
9bc6149
Add very loose type definitions
aryaemami59 Mar 12, 2024
27ebf6f
Add types definition file to `package.json`
aryaemami59 Mar 12, 2024
cdd617d
Copy documentation from `README.md` and paste as JSDocs
aryaemami59 Mar 12, 2024
0cc29e1
Add `SizeLimitConfig` type to `index.d.ts`
aryaemami59 Mar 12, 2024
ee94b70
Fix minor type issue in JSDocs
aryaemami59 Mar 12, 2024
97c5eaa
Add `satisfies SizeLimitConfig` to TS fixtures
aryaemami59 Mar 12, 2024
b5971a4
Rename `_jiti` to `buildJiti` in `get-config.js`
aryaemami59 Mar 12, 2024
881cb12
Remove manually defined `__filename`
aryaemami59 Mar 12, 2024
15064e6
Run ESLint fix on all files
aryaemami59 Mar 12, 2024
23c47b7
Change `Config` from a `type` to an `interface`
aryaemami59 Mar 12, 2024
1055880
Rename `Config` interface to `Check`
aryaemami59 Mar 12, 2024
d778dd8
Add new lines between properties of `Check` interface
aryaemami59 Mar 12, 2024
afc1998
Run ESLint fix on all files
aryaemami59 Mar 12, 2024
c6174ba
Add `sizeLimitAPI` function to `index.d.ts`
aryaemami59 Mar 12, 2024
8a40708
Dynamically import `jiti`
aryaemami59 Mar 12, 2024
42c1757
Exclude `.d.ts` files from coverage
aryaemami59 Mar 13, 2024
3852851
Merge branch 'main' of https://github.com/ai/size-limit into support-…
aryaemami59 Mar 13, 2024
453dbdf
Replace the deprecated `test.watchExclude` with `server.watch.ignored`
aryaemami59 Mar 13, 2024
26903bb
Retry failed tests during CI
aryaemami59 Mar 13, 2024
37f412e
Add JSDocs for the `Check` interface
aryaemami59 Mar 13, 2024
76348aa
Disable `fileParallelism` during CI
aryaemami59 Mar 13, 2024
ee68efb
Run ESLint fix on all files
aryaemami59 Mar 13, 2024
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
5 changes: 5 additions & 0 deletions fixtures/cjs-config-file-cjs/.size-limit.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/cjs-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/cjs-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "cjs-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
5 changes: 5 additions & 0 deletions fixtures/cjs-config-file-esm/.size-limit.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/cjs-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/cjs-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "cjs-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/cts-config-file-cjs/.size-limit.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/cts-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/cts-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "cts-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/cts-config-file-esm/.size-limit.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

export default [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/cts-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/cts-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "cts-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/cts-config-file/.size-limit.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/cts-config-file/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/cts-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "cts-config-file",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
5 changes: 5 additions & 0 deletions fixtures/js-config-file-cjs/.size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/js-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/js-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "js-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
5 changes: 5 additions & 0 deletions fixtures/js-config-file-esm/.size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/js-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/js-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "js-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
5 changes: 5 additions & 0 deletions fixtures/mjs-config-file-cjs/.size-limit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/mjs-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/mjs-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "mjs-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
5 changes: 5 additions & 0 deletions fixtures/mjs-config-file-esm/.size-limit.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default [
{
path: 'index.js'
}
]
5 changes: 5 additions & 0 deletions fixtures/mjs-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/mjs-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "mjs-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/mts-config-file-cjs/.size-limit.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
aryaemami59 marked this conversation as resolved.
Show resolved Hide resolved
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/mts-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/mts-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "mts-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/mts-config-file-esm/.size-limit.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

export default [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/mts-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/mts-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "mts-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/mts-config-file/.size-limit.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

export default [
aryaemami59 marked this conversation as resolved.
Show resolved Hide resolved
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/mts-config-file/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/mts-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "mts-config-file",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/ts-config-file-cjs/.size-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
aryaemami59 marked this conversation as resolved.
Show resolved Hide resolved
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/ts-config-file-cjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/ts-config-file-cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "ts-config-file-cjs",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/ts-config-file-esm/.size-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

export default [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/ts-config-file-esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/ts-config-file-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "ts-config-file-esm",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/ts-config-file-with-type-module/.size-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

export default [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/ts-config-file-with-type-module/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
10 changes: 10 additions & 0 deletions fixtures/ts-config-file-with-type-module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"private": true,
"name": "ts-config-file-with-type-module",
"type": "module",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
7 changes: 7 additions & 0 deletions fixtures/ts-config-file/.size-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SizeLimitConfig } from '../../packages/size-limit'

module.exports = [
{
path: 'index.js'
}
] satisfies SizeLimitConfig
5 changes: 5 additions & 0 deletions fixtures/ts-config-file/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const first = 'first'

const second = 'second'

export { first, second }
9 changes: 9 additions & 0 deletions fixtures/ts-config-file/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"private": true,
"name": "ts-config-file",
"devDependencies": {
"@size-limit/webpack": ">= 0.0.0",
"@size-limit/webpack-why": ">= 0.0.0",
"size-limit": ">= 0.0.0"
}
}
Loading
Loading