Skip to content
Open
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
19 changes: 3 additions & 16 deletions apps/code-infra-dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
{
"extends": ["../../tsconfig.base.json", "../../tsconfig.node.json"],
"compilerOptions": {
"target": "ES2022",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"outDir": "./build",
"composite": true
"outDir": "build",
"skipLibCheck": true
},
"include": ["src", "functions"]
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"eslint": "eslint . --cache --report-unused-disable-directives --ext .js,.ts,.tsx --max-warnings 0",
"eslint:ci": "eslint . --report-unused-disable-directives --ext .js,.ts,.tsx --max-warnings 0",
"eslint": "eslint . --cache --report-unused-disable-directives --max-warnings 0",
"eslint:ci": "eslint . --report-unused-disable-directives --max-warnings 0",
"prettier": "pretty-quick --ignore-path .lintignore --branch master",
"prettier:all": "prettier --write . --ignore-path .lintignore",
"update-netlify-ignore": "node ./update-netlify-ignore.mjs @apps/code-infra-dashboard",
Expand Down Expand Up @@ -44,6 +44,7 @@
"@octokit/rest": "^22.0.0",
"@tsconfig/node22": "^22.0.2",
"@types/node": "^22.18.13",
"@types/babel__core": "^7.20.5",
"@types/semver": "^7.7.1",
"@typescript-eslint/eslint-plugin": "8.46.2",
"@typescript-eslint/parser": "^8.46.2",
Expand Down
17 changes: 3 additions & 14 deletions packages/babel-plugin-minify-errors/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
{
"extends": ["../../tsconfig.base.json", "../../tsconfig.node.json"],
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "./build",
"noEmit": true,
"composite": true
"outDir": "build"
},
"include": ["."],
"include": ["**/*.js"],
"exclude": ["node_modules", "build", "__fixtures__"]
}
17 changes: 3 additions & 14 deletions packages/babel-plugin-resolve-imports/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
{
"extends": ["../../tsconfig.base.json", "../../tsconfig.node.json"],
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"allowJs": true,
"checkJs": true,
"skipLibCheck": true,
"strict": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"outDir": "./build",
"noEmit": true,
"composite": true
"outDir": "build"
},
"include": ["."],
"include": ["**/*.js"],
"exclude": ["node_modules", "build", "__fixtures__"]
}
9 changes: 8 additions & 1 deletion packages/bundle-size-checker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,12 @@
"@types/env-ci": "^3.1.4",
"@types/micromatch": "^4.0.10",
"@types/yargs": "^17.0.34"
}
},
"files": [
"bin",
"build",
"src",
"README.md",
"!**/*.tsbuildinfo"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, didn't know this supported negative patterns

]
}
3 changes: 3 additions & 0 deletions packages/bundle-size-checker/src/browser.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/**
* @typedef {import('./sizeDiff.js').Size} Size
*/
export { calculateSizeDiff } from './sizeDiff.js';
export { fetchSnapshot } from './fetchSnapshot.js';
18 changes: 11 additions & 7 deletions packages/bundle-size-checker/src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function createReplacePlugin(replacements) {

/**
* Creates vite configuration for bundle size checking
* @param {ObjectEntry} entry - Entry point (string or object)
* @param {CommandLineArgs} args
* @param {import('./types.js').ObjectEntry} entry - Entry point (string or object)
* @param {import('./types.js').CommandLineArgs} args
* @param {Record<string, string>} [replacements] - String replacements to apply
* @returns {Promise<{ config:import('vite').InlineConfig, treemapPath: string }>}
*/
Expand Down Expand Up @@ -217,7 +217,7 @@ function walkDependencyTree(chunkKey, manifest, visited = new Set()) {
* Process vite output to extract bundle sizes
* @param {import('vite').Rollup.RollupOutput['output']} output - The Vite output
* @param {string} entryName - The entry name
* @returns {Promise<Map<string, SizeSnapshotEntry>>} - Map of bundle names to size information
* @returns {Promise<Map<string, import('./types.js').SizeSnapshotEntry>>} - Map of bundle names to size information
*/
async function processBundleSizes(output, entryName) {
const chunksByFileName = new Map(output.map((chunk) => [chunk.fileName, chunk]));
Expand Down Expand Up @@ -270,15 +270,19 @@ async function processBundleSizes(output, entryName) {
});

const chunkEntries = await Promise.all(chunkPromises);
return new Map(/** @type {[string, SizeSnapshotEntry][]} */ (chunkEntries.filter(Boolean)));
return new Map(
/** @type {[string, import('./types.js').SizeSnapshotEntry][]} */ (
chunkEntries.filter(Boolean)
),
);
}

/**
* Get sizes for a vite bundle
* @param {ObjectEntry} entry - The entry configuration
* @param {CommandLineArgs} args - Command line arguments
* @param {import('./types.js').ObjectEntry} entry - The entry configuration
* @param {import('./types.js').CommandLineArgs} args - Command line arguments
* @param {Record<string, string>} [replacements] - String replacements to apply
* @returns {Promise<{ sizes: Map<string, SizeSnapshotEntry>, treemapPath: string }>}
* @returns {Promise<{ sizes: Map<string, import('./types.js').SizeSnapshotEntry>, treemapPath: string }>}
*/
export async function getBundleSizes(entry, args, replacements) {
// Create vite configuration
Expand Down
14 changes: 7 additions & 7 deletions packages/bundle-size-checker/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ const rootDir = process.cwd();

/**
* creates size snapshot for every bundle
* @param {CommandLineArgs} args
* @param {NormalizedBundleSizeCheckerConfig} config - The loaded configuration
* @returns {Promise<Array<[string, SizeSnapshotEntry]>>}
* @param {import('./types.js').CommandLineArgs} args
* @param {import('./types.js').NormalizedBundleSizeCheckerConfig} config - The loaded configuration
* @returns {Promise<Array<[string, import('./types.js').SizeSnapshotEntry]>>}
*/
async function getBundleSizes(args, config) {
const worker = new Piscina({
Expand Down Expand Up @@ -158,7 +158,7 @@ async function postInitialPrComment() {

/**
* Report command handler
* @param {ReportCommandArgs} argv - Command line arguments
* @param {import('./types.js').ReportCommandArgs} argv - Command line arguments
*/
async function reportCommand(argv) {
const { pr, owner: argOwner, repo: argRepo } = argv;
Expand Down Expand Up @@ -204,7 +204,7 @@ async function reportCommand(argv) {

/**
* Main runner function
* @param {CommandLineArgs} argv - Command line arguments
* @param {import('./types.js').CommandLineArgs} argv - Command line arguments
*/
async function run(argv) {
const { output, concurrency } = argv;
Expand Down Expand Up @@ -304,7 +304,7 @@ async function run(argv) {

yargs(process.argv.slice(2))
.command(
/** @type {import('yargs').CommandModule<{}, CommandLineArgs>} */ ({
/** @type {import('yargs').CommandModule<{}, import('./types.js').CommandLineArgs>} */ ({
command: '$0',
describe: 'Saves a size snapshot in size-snapshot.json',
builder: (cmdYargs) => {
Expand Down Expand Up @@ -347,7 +347,7 @@ yargs(process.argv.slice(2))
}),
)
.command(
/** @type {import('yargs').CommandModule<{}, ReportCommandArgs>} */ ({
/** @type {import('yargs').CommandModule<{}, import('./types.js').ReportCommandArgs>} */ ({
command: 'report',
describe: 'Generate a markdown report for a pull request',
builder: (cmdYargs) => {
Expand Down
20 changes: 10 additions & 10 deletions packages/bundle-size-checker/src/configLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as url from 'node:url';
/**
* Attempts to load and parse a single config file
* @param {string} configPath - Path to the configuration file
* @returns {Promise<BundleSizeCheckerConfigObject | null>} The parsed config or null if file doesn't exist
* @returns {Promise<import('./types').BundleSizeCheckerConfigObject | null>} The parsed config or null if file doesn't exist
* @throws {Error} If the file exists but has invalid format
*/
async function loadConfigFile(configPath) {
Expand All @@ -20,7 +20,7 @@ async function loadConfigFile(configPath) {
const configUrl = new URL(`file://${configPath}`);
const { default: config } = await import(configUrl.href);

/** @type {BundleSizeCheckerConfigObject | null} */
/** @type {import('./types').BundleSizeCheckerConfigObject | null} */
let resolvedConfig = null;
// Handle configs that might be Promise-returning functions
if (config instanceof Promise) {
Expand All @@ -44,13 +44,13 @@ async function loadConfigFile(configPath) {

/**
* Validates and normalizes an upload configuration object
* @param {UploadConfig} uploadConfig - The upload configuration to normalize
* @param {import('./types').UploadConfig} uploadConfig - The upload configuration to normalize
* @param {Object} ciInfo - CI environment information
* @param {string} [ciInfo.branch] - Branch name from CI environment
* @param {boolean} [ciInfo.isPr] - Whether this is a pull request from CI environment
* @param {string} [ciInfo.prBranch] - PR branch name from CI environment
* @param {string} [ciInfo.slug] - Repository slug from CI environment
* @returns {NormalizedUploadConfig} - Normalized upload config
* @returns {import('./types').NormalizedUploadConfig} - Normalized upload config
* @throws {Error} If required fields are missing
*/
export function applyUploadConfigDefaults(uploadConfig, ciInfo) {
Expand Down Expand Up @@ -123,9 +123,9 @@ function isPackageTopLevel(importSrc) {

/**
* Normalizes entries to ensure they have a consistent format and ids are unique
* @param {EntryPoint[]} entries - The array of entries from the config
* @param {import('./types').EntryPoint[]} entries - The array of entries from the config
* @param {string} configPath - The path to the configuration file
* @returns {Promise<ObjectEntry[]>} - Normalized entries with uniqueness enforced
* @returns {Promise<import('./types').ObjectEntry[]>} - Normalized entries with uniqueness enforced
*/
async function normalizeEntries(entries, configPath) {
const usedIds = new Set();
Expand Down Expand Up @@ -201,9 +201,9 @@ async function normalizeEntries(entries, configPath) {

/**
* Apply default values to the configuration using CI environment
* @param {BundleSizeCheckerConfigObject} config - The loaded configuration
* @param {import('./types').BundleSizeCheckerConfigObject} config - The loaded configuration
* @param {string} configPath - The path to the configuration file
* @returns {Promise<NormalizedBundleSizeCheckerConfig>} Configuration with defaults applied
* @returns {Promise<import('./types').NormalizedBundleSizeCheckerConfig>} Configuration with defaults applied
* @throws {Error} If required fields are missing
*/
async function applyConfigDefaults(config, configPath) {
Expand All @@ -220,7 +220,7 @@ async function applyConfigDefaults(config, configPath) {
}

// Clone the config to avoid mutating the original
/** @type {NormalizedBundleSizeCheckerConfig} */
/** @type {import('./types').NormalizedBundleSizeCheckerConfig} */
const result = {
entrypoints: await normalizeEntries(config.entrypoints, configPath),
upload: null, // Default to disabled
Expand Down Expand Up @@ -261,7 +261,7 @@ async function applyConfigDefaults(config, configPath) {
/**
* Attempts to load the config file from the given directory
* @param {string} rootDir - The directory to search for the config file
* @returns {Promise<NormalizedBundleSizeCheckerConfig>} A promise that resolves to the normalized config object
* @returns {Promise<import('./types').NormalizedBundleSizeCheckerConfig>} A promise that resolves to the normalized config object
*/
export async function loadConfig(rootDir) {
const configPaths = [
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-size-checker/src/defineConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Define a configuration for the bundle size checker.
* This is just a pass-through function for better TypeScript typing.
*
* @param {BundleSizeCheckerConfig} config - Configuration object
* @returns {BundleSizeCheckerConfig} The configuration object
* @param {import("./types").BundleSizeCheckerConfig} config - Configuration object
* @returns {import("./types").BundleSizeCheckerConfig} The configuration object
*/
export default function defineConfig(config) {
return config;
Expand Down
2 changes: 0 additions & 2 deletions packages/bundle-size-checker/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="./types.d.ts" />

import defineConfig from './defineConfig.js';
import { loadConfig } from './configLoader.js';
import { renderMarkdownReport } from './renderMarkdownReport.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-size-checker/src/renderMarkdownReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export function renderMarkdownReportContent(

/**
*
* @param {PrInfo} prInfo
* @param {import('./types.js').PrInfo} prInfo
* @param {Object} [options] - Optional parameters
* @param {string | null} [options.actualBaseCommit] - The actual commit SHA used for comparison (may differ from prInfo.base.sha)
* @returns {URL}
Expand All @@ -214,7 +214,7 @@ function getDetailsUrl(prInfo, options = {}) {

/**
*
* @param {PrInfo} prInfo
* @param {import('./types.js').PrInfo} prInfo
* @param {Object} [options] - Additional options
* @param {string[]} [options.track] - Array of bundle IDs to track
* @param {number} [options.fallbackDepth=3] - How many parent commits to try as fallback when base snapshot is missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('renderMarkdownReport', () => {
);
const mockGetMergeBase = vi.mocked(gitModule.getMergeBase);

/** @type {PrInfo} */
/** @type {import('./types.js').PrInfo} */
const mockPrInfo = {
number: 42,
base: {
Expand Down
4 changes: 2 additions & 2 deletions packages/bundle-size-checker/src/sizeDiff.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @description Represents a single bundle size snapshot
* @typedef {Object.<string, SizeSnapshotEntry>} SizeSnapshot
* @typedef {Object.<string, import('./types').SizeSnapshotEntry>} SizeSnapshot
*
* @description Represents a single bundle size comparison
* @typedef {Object} Size
Expand Down Expand Up @@ -31,7 +31,7 @@
* @property {number} fileCounts.total - Total number of files
*/

/** @type {SizeSnapshotEntry} */
/** @type {import('./types').SizeSnapshotEntry} */
const nullSnapshot = { parsed: 0, gzip: 0 };

/**
Expand Down
Loading
Loading