Skip to content

Commit

Permalink
build: size stat plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
fanhaoyuan committed Oct 24, 2024
1 parent 9fff3b8 commit 671033c
Show file tree
Hide file tree
Showing 17 changed files with 399 additions and 183 deletions.
10 changes: 6 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"extends": ["@fansy/eslint-config", "plugin:prettier/recommended"],
"parserOptions": {
"sourceType": "module"
},
"plugins": ["@typescript-eslint/eslint-plugin"],
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": "latest", "sourceType": "module" },
"rules": {
"no-bitwise": "off"
"no-bitwise": "off",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-explicit-any": "warn"
}
}
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"prepare": "husky install",
"clean": "pnpm -r clean",
"build": "pnpm -r build",
"ci": "npm run eslint && npx tsc && npm run build && npm run test",
"ci": "npm run eslint && npx tsc --noEmit && npm run build && npm run test",
"test": "pnpm -r run test",
"test:cov": "pnpm -r run test:cov",
"eslint": "eslint ."
"eslint": "eslint . --fix"
},
"devDependencies": {
"@fansy/eslint-config": "^1.4.2",
Expand All @@ -20,18 +20,23 @@
"@rollup/plugin-strip": "^3.0.0",
"@types/jest": "^29.1.2",
"@types/node": "^18.15.1",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"esbuild": "^0.18.11",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.57.1",
"eslint-plugin-prettier": "^5.2.1",
"husky": "^8.0.3",
"jest": "^29.2.0",
"jest-fetch-mock": "^3.0.3",
"lint-staged": "^13.2.0",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"rimraf": "^5.0.0",
"rollup": "^2.79.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-dts": "^4.2.3",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-output-size": "^1.4.2",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-aborter/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-cache/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-form-data/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-json/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-parameter/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-progress/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher-middleware-progress/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ProgressOptions } from './types';

async function readStreamByChunk(
readableStream: ReadableStream,
callback: (value: string) => Promise<void> | void
callback: (value: string) => Promise<void> | void,
) {
async function read(reader: ReadableStreamDefaultReader) {
const { value, done } = await reader.read();
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import nodeResolver from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import strip from '@rollup/plugin-strip';
import { defineConfig } from 'rollup';
import bundleSize from 'rollup-plugin-bundle-size';
import dts from 'rollup-plugin-dts';
import esbuild, { minify } from 'rollup-plugin-esbuild';
import bundleSize from 'rollup-plugin-output-size';
import { browser, main, module, typings } from './package.json';

const input = 'src/index.ts';
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher/src/composeMiddlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function composeMiddlewares(middlewares: FatcherMiddleware[]) {

async function dispatch(
index: number,
patch?: Partial<FatcherRequest>
patch?: Partial<FatcherRequest>,
): Promise<FatcherResponse> {
if (index <= currentIndex) {
return response;
Expand Down
2 changes: 1 addition & 1 deletion packages/fatcher/src/merge.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function merge<
T extends Record<string, any>,
R extends Record<string, any>,
V extends Record<string, any>
V extends Record<string, any>,
>(target: T, source?: R, source1?: V): T {
if (!source) {
return target;
Expand Down
5 changes: 2 additions & 3 deletions packages/fatcher/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-interface */
/* eslint-disable no-use-before-define */

export interface FatcherOptions extends RequestInit {
Expand All @@ -12,12 +11,12 @@ export interface FatcherRequest extends Request {
export interface FatcherResponse extends Response {}

export type FatcherMiddlewareNext = (
request?: Partial<FatcherRequest>
request?: Partial<FatcherRequest>,
) => Promise<FatcherResponse> | FatcherResponse;

export type FatcherMiddleware = (
request: FatcherRequest,
next: FatcherMiddlewareNext
next: FatcherMiddlewareNext,
) => Promise<FatcherResponse> | FatcherResponse;

export interface ExceptionOptions {
Expand Down
Loading

0 comments on commit 671033c

Please sign in to comment.