From fb265013bfbb74b7dd2ccfd5f9409a0984275635 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Thu, 30 Jul 2026 14:49:30 +0100 Subject: [PATCH 1/3] chore: upgrade @biomejs/biome to 2.x - migrate biome.jsonc to the v2 schema; replace the removed useImportExtensions 'suggestedExtensions' option with 'forceJsExtensions', and carry the organizeImports ignore list over as assist.includes - exclude the ESM redirect stubs in packages/repack/client and packages/repack/mf from biome, since v2 infers module type from package.json and refuses to parse them as modules - disable noSvgWithoutTitle for static .svg assets and noUnknownAtRules for tailwind at-rules in CSS - apply safe fixes: new import sort order, @ts-ignore -> @ts-expect-error conversions - give forEach callbacks block bodies and make map returns explicit to satisfy useIterableCallbackReturn; convert a side-effect-only map to forEach in the rspack Compiler - drop biome-ignore suppressions that v2 reports as unused - remove the write-only timer field in WebSocketServer and the unused config constructor property on JsonConsoleReporter; keep runtime-exposed ModuleFederationPlugin fields with suppressions - replace non-null-asserted optional chains in babelSwcLoader --- apps/tester-app/__tests__/bundle.test.ts | 2 +- apps/tester-app/__tests__/start.test.ts | 2 +- apps/tester-app/src/nativewind/ui/Button.tsx | 4 +- apps/tester-app/src/ui/Section.tsx | 2 +- .../configs/rspack.host-app.mts | 2 +- .../configs/rspack.mini-app.mts | 2 +- .../configs/webpack.host-app.mts | 6 +- .../configs/webpack.mini-app.mts | 6 +- .../src/host/navigation/MainNavigator.tsx | 2 +- .../src/mini/navigation/MainNavigator.tsx | 2 +- .../configs/rspack.host-app.mts | 2 +- .../configs/rspack.mini-app.mts | 2 +- .../configs/webpack.host-app.mts | 4 +- .../configs/webpack.mini-app.mts | 4 +- .../src/host/navigation/MainNavigator.tsx | 2 +- .../src/mini/navigation/MainNavigator.tsx | 2 +- biome.jsonc | 71 +++++++++++------ package.json | 2 +- packages/dev-server/package.json | 13 +++- packages/dev-server/src/createServer.ts | 1 - .../src/plugins/compiler/compilerPlugin.ts | 3 +- .../src/plugins/symbolicate/index.ts | 2 +- .../src/plugins/wss/WebSocketServer.ts | 4 +- packages/dev-server/src/plugins/wss/index.ts | 4 +- .../wss/servers/WebSocketMessageServer.ts | 2 +- .../dev-server/src/plugins/wss/wssPlugin.ts | 4 +- packages/dev-server/src/types.ts | 2 +- packages/init/package.json | 11 ++- .../init/src/tasks/checkPackageManager.ts | 2 +- packages/plugin-expo-modules/package.json | 4 +- packages/plugin-nativewind/package.json | 9 ++- packages/plugin-reanimated/package.json | 5 +- packages/plugin-reanimated/src/loader.ts | 2 +- packages/plugin-reanimated/src/rules.ts | 2 +- .../__tests__/makeCompilerConfig.test.ts | 7 +- packages/repack/src/commands/common/index.ts | 3 +- .../repack/src/commands/rspack/Compiler.ts | 10 ++- packages/repack/src/commands/rspack/bundle.ts | 2 +- .../commands/rspack/profile/profile-1.4.ts | 3 +- .../commands/rspack/profile/profile-legacy.ts | 1 - packages/repack/src/commands/rspack/start.ts | 4 +- .../repack/src/commands/webpack/Compiler.ts | 4 +- packages/repack/src/commands/webpack/start.ts | 4 +- packages/repack/src/index.ts | 2 +- .../src/loaders/babelLoader/babelLoader.ts | 2 +- .../babelSwcLoader/__tests__/swc.test.ts | 2 +- .../loaders/babelSwcLoader/babelSwcLoader.ts | 2 +- .../repack/src/loaders/babelSwcLoader/swc.ts | 3 +- .../src/loaders/babelSwcLoader/utils.ts | 4 +- packages/repack/src/logging/helpers.ts | 12 ++- packages/repack/src/logging/reporters.ts | 6 +- .../FederationRuntimePlugins/CorePlugin.ts | 4 +- .../modules/ScriptManager/ScriptManager.ts | 3 +- .../repack/src/modules/ScriptManager/index.ts | 6 +- .../src/plugins/CodeSigningPlugin/index.ts | 2 +- .../repack/src/plugins/DevelopmentPlugin.ts | 10 +-- .../src/plugins/HermesBytecodePlugin/index.ts | 2 +- packages/repack/src/plugins/LoggerPlugin.ts | 2 +- .../src/plugins/ModuleFederationPlugin.ts | 5 +- .../src/plugins/ModuleFederationPluginV1.ts | 2 +- .../src/plugins/NativeEntryPlugin/index.ts | 2 +- .../src/plugins/OutputPlugin/OutputPlugin.ts | 28 +++++-- .../plugins/__tests__/OutputPlugin.test.ts | 6 +- packages/repack/src/plugins/index.ts | 10 +-- .../repack/src/types/runtime-globals.d.ts | 4 +- .../__tests__/getAssetTransformRules.test.ts | 10 +-- packages/repack/src/utils/index.ts | 10 +-- pnpm-lock.yaml | 76 +++++++++---------- tests/integration/src/helpers.ts | 2 +- .../src/plugins/NativeEntryPlugin.test.ts | 6 +- .../__fixtures__/react-native/package.json | 4 +- website/theme/index.tsx | 3 +- 72 files changed, 263 insertions(+), 194 deletions(-) diff --git a/apps/tester-app/__tests__/bundle.test.ts b/apps/tester-app/__tests__/bundle.test.ts index 57d42b255..f217dda34 100644 --- a/apps/tester-app/__tests__/bundle.test.ts +++ b/apps/tester-app/__tests__/bundle.test.ts @@ -144,7 +144,7 @@ describe('bundle command', () => { webpackConfig: path.join(__dirname, 'configs', configFile), }; - // @ts-ignore + // @ts-expect-error await bundleCommand.func([''], config, args); const files = await globby(['**/*'], { cwd: TMP_DIR, dot: true }); diff --git a/apps/tester-app/__tests__/start.test.ts b/apps/tester-app/__tests__/start.test.ts index cc45941f9..b83073bbe 100644 --- a/apps/tester-app/__tests__/start.test.ts +++ b/apps/tester-app/__tests__/start.test.ts @@ -110,7 +110,7 @@ describe('start command', () => { webpackConfig: path.join(__dirname, 'configs', configFile), }; - // @ts-ignore + // @ts-expect-error const { stop } = await startCommand.func([], config, args); stopServer = stop; }); diff --git a/apps/tester-app/src/nativewind/ui/Button.tsx b/apps/tester-app/src/nativewind/ui/Button.tsx index e8a191954..af8b01563 100644 --- a/apps/tester-app/src/nativewind/ui/Button.tsx +++ b/apps/tester-app/src/nativewind/ui/Button.tsx @@ -1,4 +1,4 @@ -import { type VariantProps, cva } from 'class-variance-authority'; +import { cva, type VariantProps } from 'class-variance-authority'; import * as React from 'react'; import { Pressable } from 'react-native'; import { TextClassContext } from './Text'; @@ -88,5 +88,5 @@ const Button = React.forwardRef< }); Button.displayName = 'Button'; -export { Button, buttonTextVariants, buttonVariants }; export type { ButtonProps }; +export { Button, buttonTextVariants, buttonVariants }; diff --git a/apps/tester-app/src/ui/Section.tsx b/apps/tester-app/src/ui/Section.tsx index 0d39d1946..925a0f940 100644 --- a/apps/tester-app/src/ui/Section.tsx +++ b/apps/tester-app/src/ui/Section.tsx @@ -1,6 +1,6 @@ import { StyleSheet, View } from 'react-native'; -import { Text } from './Text'; import { Colors } from './colors'; +import { Text } from './Text'; import type { WithChildren } from './types'; type SectionProps = WithChildren<{ diff --git a/apps/tester-federation-v2/configs/rspack.host-app.mts b/apps/tester-federation-v2/configs/rspack.host-app.mts index f58d46903..43fedabe2 100644 --- a/apps/tester-federation-v2/configs/rspack.host-app.mts +++ b/apps/tester-federation-v2/configs/rspack.host-app.mts @@ -1,7 +1,7 @@ import * as Repack from '@callstack/repack'; import rspack from '@rspack/core'; -import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import reactPkg from 'react/package.json' with { type: 'json' }; +import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import pkg from '../package.json' with { type: 'json' }; export default Repack.defineRspackConfig((env) => { diff --git a/apps/tester-federation-v2/configs/rspack.mini-app.mts b/apps/tester-federation-v2/configs/rspack.mini-app.mts index 4fa3fcbc8..c8043906c 100644 --- a/apps/tester-federation-v2/configs/rspack.mini-app.mts +++ b/apps/tester-federation-v2/configs/rspack.mini-app.mts @@ -1,7 +1,7 @@ import * as Repack from '@callstack/repack'; import rspack from '@rspack/core'; -import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import reactPkg from 'react/package.json' with { type: 'json' }; +import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import pkg from '../package.json' with { type: 'json' }; export default Repack.defineRspackConfig((env) => { diff --git a/apps/tester-federation-v2/configs/webpack.host-app.mts b/apps/tester-federation-v2/configs/webpack.host-app.mts index fd2a7f5ac..32dc1ac25 100644 --- a/apps/tester-federation-v2/configs/webpack.host-app.mts +++ b/apps/tester-federation-v2/configs/webpack.host-app.mts @@ -1,7 +1,7 @@ // @ts-check import * as Repack from '@callstack/repack'; -import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import reactPkg from 'react/package.json' with { type: 'json' }; +import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import webpack from 'webpack'; import pkg from '../package.json' with { type: 'json' }; @@ -30,7 +30,7 @@ export default Repack.defineWebpackConfig((env) => { ], }, plugins: [ - // @ts-ignore + // @ts-expect-error new Repack.RepackPlugin({ extraChunks: [ { @@ -40,7 +40,7 @@ export default Repack.defineWebpackConfig((env) => { }, ], }), - // @ts-ignore + // @ts-expect-error new Repack.plugins.ModuleFederationPluginV2({ name: 'HostApp', filename: 'HostApp.container.js.bundle', diff --git a/apps/tester-federation-v2/configs/webpack.mini-app.mts b/apps/tester-federation-v2/configs/webpack.mini-app.mts index a7e6cadb0..fedc3334f 100644 --- a/apps/tester-federation-v2/configs/webpack.mini-app.mts +++ b/apps/tester-federation-v2/configs/webpack.mini-app.mts @@ -1,6 +1,6 @@ import * as Repack from '@callstack/repack'; -import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import reactPkg from 'react/package.json' with { type: 'json' }; +import reactNativePkg from 'react-native/package.json' with { type: 'json' }; import webpack from 'webpack'; import pkg from '../package.json' with { type: 'json' }; @@ -29,7 +29,7 @@ export default Repack.defineWebpackConfig((env) => { ], }, plugins: [ - // @ts-ignore + // @ts-expect-error new Repack.RepackPlugin({ extraChunks: [ { @@ -39,7 +39,7 @@ export default Repack.defineWebpackConfig((env) => { }, ], }), - // @ts-ignore + // @ts-expect-error new Repack.plugins.ModuleFederationPluginV2({ name: 'MiniApp', filename: 'MiniApp.container.js.bundle', diff --git a/apps/tester-federation-v2/src/host/navigation/MainNavigator.tsx b/apps/tester-federation-v2/src/host/navigation/MainNavigator.tsx index 04978a2e0..2c544c03e 100644 --- a/apps/tester-federation-v2/src/host/navigation/MainNavigator.tsx +++ b/apps/tester-federation-v2/src/host/navigation/MainNavigator.tsx @@ -1,6 +1,6 @@ import { - type NativeStackNavigationProp, createNativeStackNavigator, + type NativeStackNavigationProp, } from '@react-navigation/native-stack'; import { StyleSheet } from 'react-native'; diff --git a/apps/tester-federation-v2/src/mini/navigation/MainNavigator.tsx b/apps/tester-federation-v2/src/mini/navigation/MainNavigator.tsx index c74f5ab49..7d97eadcf 100644 --- a/apps/tester-federation-v2/src/mini/navigation/MainNavigator.tsx +++ b/apps/tester-federation-v2/src/mini/navigation/MainNavigator.tsx @@ -1,6 +1,6 @@ import { - type NativeStackNavigationProp, createNativeStackNavigator, + type NativeStackNavigationProp, } from '@react-navigation/native-stack'; import { StyleSheet } from 'react-native'; diff --git a/apps/tester-federation/configs/rspack.host-app.mts b/apps/tester-federation/configs/rspack.host-app.mts index 6b228c3df..238dc550a 100644 --- a/apps/tester-federation/configs/rspack.host-app.mts +++ b/apps/tester-federation/configs/rspack.host-app.mts @@ -98,7 +98,7 @@ export default Repack.defineRspackConfig((env) => { }; if (process.env.RSDOCTOR) { - // @ts-ignore + // @ts-expect-error config.plugins?.push(new RsdoctorRspackPlugin()); } diff --git a/apps/tester-federation/configs/rspack.mini-app.mts b/apps/tester-federation/configs/rspack.mini-app.mts index 72c2d3345..0e867a2c1 100644 --- a/apps/tester-federation/configs/rspack.mini-app.mts +++ b/apps/tester-federation/configs/rspack.mini-app.mts @@ -98,7 +98,7 @@ export default Repack.defineRspackConfig((env) => { }; if (process.env.RSDOCTOR) { - // @ts-ignore + // @ts-expect-error config.plugins?.push(new RsdoctorRspackPlugin()); } diff --git a/apps/tester-federation/configs/webpack.host-app.mts b/apps/tester-federation/configs/webpack.host-app.mts index b4d3619bd..299887b48 100644 --- a/apps/tester-federation/configs/webpack.host-app.mts +++ b/apps/tester-federation/configs/webpack.host-app.mts @@ -27,7 +27,7 @@ export default Repack.defineWebpackConfig((env) => { ], }, plugins: [ - // @ts-ignore + // @ts-expect-error new Repack.RepackPlugin({ extraChunks: [ { @@ -37,7 +37,7 @@ export default Repack.defineWebpackConfig((env) => { }, ], }), - // @ts-ignore + // @ts-expect-error new Repack.plugins.ModuleFederationPluginV1({ name: 'HostApp', shared: { diff --git a/apps/tester-federation/configs/webpack.mini-app.mts b/apps/tester-federation/configs/webpack.mini-app.mts index 1abdf348e..72710e5f1 100644 --- a/apps/tester-federation/configs/webpack.mini-app.mts +++ b/apps/tester-federation/configs/webpack.mini-app.mts @@ -27,7 +27,7 @@ export default Repack.defineWebpackConfig((env) => { ], }, plugins: [ - // @ts-ignore + // @ts-expect-error new Repack.RepackPlugin({ extraChunks: [ { @@ -37,7 +37,7 @@ export default Repack.defineWebpackConfig((env) => { }, ], }), - // @ts-ignore + // @ts-expect-error new Repack.plugins.ModuleFederationPluginV1({ name: 'MiniApp', filename: 'MiniApp.container.bundle', diff --git a/apps/tester-federation/src/host/navigation/MainNavigator.tsx b/apps/tester-federation/src/host/navigation/MainNavigator.tsx index 72a63bc4c..1533b563a 100644 --- a/apps/tester-federation/src/host/navigation/MainNavigator.tsx +++ b/apps/tester-federation/src/host/navigation/MainNavigator.tsx @@ -1,6 +1,6 @@ import { - type NativeStackNavigationProp, createNativeStackNavigator, + type NativeStackNavigationProp, } from '@react-navigation/native-stack'; import { StyleSheet } from 'react-native'; diff --git a/apps/tester-federation/src/mini/navigation/MainNavigator.tsx b/apps/tester-federation/src/mini/navigation/MainNavigator.tsx index c74f5ab49..7d97eadcf 100644 --- a/apps/tester-federation/src/mini/navigation/MainNavigator.tsx +++ b/apps/tester-federation/src/mini/navigation/MainNavigator.tsx @@ -1,6 +1,6 @@ import { - type NativeStackNavigationProp, createNativeStackNavigator, + type NativeStackNavigationProp, } from '@react-navigation/native-stack'; import { StyleSheet } from 'react-native'; diff --git a/biome.jsonc b/biome.jsonc index 802f920b5..4eebd5f81 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,12 +1,21 @@ { - "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "$schema": "https://biomejs.dev/schemas/2.5.6/schema.json", "vcs": { "enabled": true, "clientKind": "git", "defaultBranch": "main", "useIgnoreFile": true }, - "files": { "ignoreUnknown": false, "ignore": [] }, + "files": { + "ignoreUnknown": false, + "includes": [ + "**", + // ESM redirect stubs in a commonjs package - biome 2 infers module type + // from package.json and refuses to parse them as modules + "!packages/repack/client/*.js", + "!packages/repack/mf/*.js" + ] + }, "formatter": { "enabled": true, "useEditorconfig": true, @@ -17,22 +26,27 @@ "lineWidth": 80, "attributePosition": "auto", "bracketSpacing": true, - "ignore": [ - "pnpm-lock.yaml", - "tests/metro-compat/**/__tests__/**", - "website/src/2.x/**", - "website/src/3.x/**", - "website/src/4.x/**" + "includes": [ + "**", + "!**/pnpm-lock.yaml", + "!**/tests/metro-compat/**/__tests__/**", + "!**/website/src/2.x/**", + "!**/website/src/3.x/**", + "!**/website/src/4.x/**" ] }, - "organizeImports": { - "enabled": true, - "ignore": ["templates/*", "tests/metro-compat/**/__tests__/**"] + "assist": { + "actions": { "source": { "organizeImports": "on" } }, + "includes": [ + "**", + "!**/templates/**/*", + "!**/tests/metro-compat/**/__tests__/**" + ] }, "linter": { "enabled": true, "rules": { - "recommended": true, + "preset": "recommended", "complexity": { "noBannedTypes": "off", "noForEach": "off" @@ -55,7 +69,11 @@ "noConfusingVoidType": "off" } }, - "ignore": ["templates/*", "tests/metro-compat/**/__tests__/**"] + "includes": [ + "**", + "!**/templates/**/*", + "!**/tests/metro-compat/**/__tests__/**" + ] }, "javascript": { "formatter": { @@ -72,19 +90,14 @@ }, "overrides": [ { - "include": ["packages/**/*"], + "includes": ["**/packages/**/*"], "linter": { "rules": { "correctness": { "useImportExtensions": { "level": "error", "options": { - "suggestedExtensions": { - "ts": { - "module": "js", - "component": "js" - } - } + "forceJsExtensions": true } } } @@ -92,15 +105,25 @@ } }, { - "include": ["**/*.d.ts"], - "linter": { "rules": { "style": { "noVar": "off" } } } + // static SVG assets don't need accessibility titles + "includes": ["**/*.svg"], + "linter": { "rules": { "a11y": { "noSvgWithoutTitle": "off" } } } + }, + { + // tailwind at-rules (@tailwind, @apply, etc.) + "includes": ["**/*.css"], + "linter": { "rules": { "suspicious": { "noUnknownAtRules": "off" } } } + }, + { + "includes": ["**/*.d.ts"], + "linter": { "rules": { "suspicious": { "noVar": "off" } } } }, { - "include": ["website/**/*.css"], + "includes": ["**/website/**/*.css"], "formatter": { "lineWidth": 120 } }, { - "include": ["packages/repack/src/**/implementation/**"], + "includes": ["**/packages/repack/src/**/implementation/**"], "linter": { "enabled": false } } ] diff --git a/package.json b/package.json index 660155192..560acbe67 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@babel/preset-env": "^7.29.7", "@babel/preset-typescript": "^7.29.7", "@babel/runtime": "^7.29.7", - "@biomejs/biome": "^1.9.4", + "@biomejs/biome": "^2.5.6", "@changesets/changelog-github": "^0.7.0", "@changesets/cli": "^2.31.1", "husky": "^9.1.6", diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 987e41e92..a46a9dad2 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -10,13 +10,22 @@ ".": "./dist/index.js", "./package.json": "./package.json" }, - "files": ["dist", "static"], + "files": [ + "dist", + "static" + ], "homepage": "https://github.com/callstack/repack", "repository": { "type": "git", "url": "https://github.com/callstack/repack.git" }, - "keywords": ["react-native", "repack", "re.pack", "server", "dev-server"], + "keywords": [ + "react-native", + "repack", + "re.pack", + "server", + "dev-server" + ], "author": "zamotany ", "engines": { "node": ">=18" diff --git a/packages/dev-server/src/createServer.ts b/packages/dev-server/src/createServer.ts index 5fba02391..404d956d3 100644 --- a/packages/dev-server/src/createServer.ts +++ b/packages/dev-server/src/createServer.ts @@ -22,7 +22,6 @@ import { normalizeOptions } from './utils/normalizeOptions.js'; * @returns `start` and `stop` functions as well as an underlying Fastify `instance`. */ export async function createServer(config: Server.Config) { - // biome-ignore lint/style/useConst: needed in fastify constructor let delegate: Server.Delegate; const options = normalizeOptions(config.options); diff --git a/packages/dev-server/src/plugins/compiler/compilerPlugin.ts b/packages/dev-server/src/plugins/compiler/compilerPlugin.ts index 61a33c325..345931e03 100644 --- a/packages/dev-server/src/plugins/compiler/compilerPlugin.ts +++ b/packages/dev-server/src/plugins/compiler/compilerPlugin.ts @@ -1,7 +1,6 @@ import type { FastifyInstance } from 'fastify'; import fastifyPlugin from 'fastify-plugin'; -import type { Server } from '../../types.js'; -import type { SendProgress } from '../../types.js'; +import type { SendProgress, Server } from '../../types.js'; async function compilerPlugin( instance: FastifyInstance, diff --git a/packages/dev-server/src/plugins/symbolicate/index.ts b/packages/dev-server/src/plugins/symbolicate/index.ts index 9158b6092..e49d4c937 100644 --- a/packages/dev-server/src/plugins/symbolicate/index.ts +++ b/packages/dev-server/src/plugins/symbolicate/index.ts @@ -1,3 +1,3 @@ -export { default } from './sybmolicatePlugin.js'; export * from './Symbolicator.js'; +export { default } from './sybmolicatePlugin.js'; export * from './types.js'; diff --git a/packages/dev-server/src/plugins/wss/WebSocketServer.ts b/packages/dev-server/src/plugins/wss/WebSocketServer.ts index 635a0c03b..0524a0410 100644 --- a/packages/dev-server/src/plugins/wss/WebSocketServer.ts +++ b/packages/dev-server/src/plugins/wss/WebSocketServer.ts @@ -28,8 +28,6 @@ export abstract class WebSocketServer protected clients: Map; protected nextClientId = 0; - private timer: NodeJS.Timer | number | null = null; - /** * Create a new instance of the WebSocketServer. * Any logging information, will be passed through standard `fastify.log` API. @@ -48,7 +46,7 @@ export abstract class WebSocketServer this.clients = new Map(); // setup heartbeat timer - this.timer = setInterval(() => { + setInterval(() => { this.clients.forEach((socket) => { if (!socket.isAlive) { socket.terminate(); diff --git a/packages/dev-server/src/plugins/wss/index.ts b/packages/dev-server/src/plugins/wss/index.ts index aeb32a77b..13736c26d 100644 --- a/packages/dev-server/src/plugins/wss/index.ts +++ b/packages/dev-server/src/plugins/wss/index.ts @@ -1,3 +1,3 @@ -export { default } from './wssPlugin.js'; -export * from './WebSocketServer.js'; export * from './types.js'; +export * from './WebSocketServer.js'; +export { default } from './wssPlugin.js'; diff --git a/packages/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts b/packages/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts index d9bb183d0..027d882bd 100644 --- a/packages/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts +++ b/packages/dev-server/src/plugins/wss/servers/WebSocketMessageServer.ts @@ -355,7 +355,7 @@ export class WebSocketMessageServer extends WebSocketServer { socket.addEventListener('message', (event) => { const message = this.parseMessage( event.data.toString(), - // @ts-ignore + // @ts-expect-error event.binary ); diff --git a/packages/dev-server/src/plugins/wss/wssPlugin.ts b/packages/dev-server/src/plugins/wss/wssPlugin.ts index b3079bff4..961c5559e 100644 --- a/packages/dev-server/src/plugins/wss/wssPlugin.ts +++ b/packages/dev-server/src/plugins/wss/wssPlugin.ts @@ -2,13 +2,13 @@ import type { FastifyInstance } from 'fastify'; import fastifyPlugin from 'fastify-plugin'; import type { WebSocketServer } from 'ws'; import type { Server } from '../../types.js'; -import { WebSocketRouter } from './WebSocketRouter.js'; -import { WebSocketServerAdapter } from './WebSocketServerAdapter.js'; import { WebSocketApiServer } from './servers/WebSocketApiServer.js'; import { WebSocketDevClientServer } from './servers/WebSocketDevClientServer.js'; import { WebSocketEventsServer } from './servers/WebSocketEventsServer.js'; import { WebSocketHMRServer } from './servers/WebSocketHMRServer.js'; import { WebSocketMessageServer } from './servers/WebSocketMessageServer.js'; +import { WebSocketRouter } from './WebSocketRouter.js'; +import { WebSocketServerAdapter } from './WebSocketServerAdapter.js'; declare module 'fastify' { interface FastifyInstance { diff --git a/packages/dev-server/src/types.ts b/packages/dev-server/src/types.ts index 67f994dd7..d273664e6 100644 --- a/packages/dev-server/src/types.ts +++ b/packages/dev-server/src/types.ts @@ -39,9 +39,9 @@ export type Middleware< | MiddlewareObject | MiddlewareHandler; -export type { CompilerDelegate }; export type { CodeFrame, + CompilerDelegate, InputStackFrame, ReactNativeStackFrame, StackFrame, diff --git a/packages/init/package.json b/packages/init/package.json index f047de7c7..0adf3e06a 100644 --- a/packages/init/package.json +++ b/packages/init/package.json @@ -9,14 +9,21 @@ "type": "git", "url": "https://github.com/callstack/repack.git" }, - "keywords": ["repack", "re.pack", "init", "repack-init"], + "keywords": [ + "repack", + "re.pack", + "init", + "repack-init" + ], "publishConfig": { "registry": "https://registry.npmjs.org/", "access": "public" }, "bin": "dist/bin.js", "main": "dist/bin.js", - "files": ["dist"], + "files": [ + "dist" + ], "engineStrict": true, "engines": { "node": ">=18" diff --git a/packages/init/src/tasks/checkPackageManager.ts b/packages/init/src/tasks/checkPackageManager.ts index 0a991103c..873d250df 100644 --- a/packages/init/src/tasks/checkPackageManager.ts +++ b/packages/init/src/tasks/checkPackageManager.ts @@ -1,6 +1,6 @@ import preferredPM from 'preferred-pm'; import whichPmRuns from 'which-pm-runs'; -import type { PM, PackageManager } from '../types/pm.js'; +import type { PackageManager, PM } from '../types/pm.js'; import logger from '../utils/logger.js'; const PM_COMMANDS: Record = { diff --git a/packages/plugin-expo-modules/package.json b/packages/plugin-expo-modules/package.json index 8587710f9..0f485f16d 100644 --- a/packages/plugin-expo-modules/package.json +++ b/packages/plugin-expo-modules/package.json @@ -12,7 +12,9 @@ "type": "commonjs", "main": "dist/index.js", "types": "dist/index.d.ts", - "files": ["dist"], + "files": [ + "dist" + ], "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/plugin-nativewind/package.json b/packages/plugin-nativewind/package.json index 0fd4cc708..f4d3b6516 100644 --- a/packages/plugin-nativewind/package.json +++ b/packages/plugin-nativewind/package.json @@ -3,7 +3,9 @@ "version": "5.2.5", "description": "A plugin for @callstack/repack that integrates NativeWind", "author": "Boris Yankov ", - "contributors": ["Jakub Romańczyk "], + "contributors": [ + "Jakub Romańczyk " + ], "license": "MIT", "homepage": "https://github.com/callstack/repack", "repository": { @@ -13,7 +15,10 @@ "type": "commonjs", "main": "dist/index.js", "types": "dist/index.d.ts", - "files": ["dist", "loader"], + "files": [ + "dist", + "loader" + ], "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/plugin-reanimated/package.json b/packages/plugin-reanimated/package.json index 0f3d51ec6..fe4899d22 100644 --- a/packages/plugin-reanimated/package.json +++ b/packages/plugin-reanimated/package.json @@ -12,7 +12,10 @@ "type": "commonjs", "main": "dist/index.js", "types": "dist/index.d.ts", - "files": ["dist", "loader"], + "files": [ + "dist", + "loader" + ], "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/plugin-reanimated/src/loader.ts b/packages/plugin-reanimated/src/loader.ts index ad8561972..5be948d3c 100644 --- a/packages/plugin-reanimated/src/loader.ts +++ b/packages/plugin-reanimated/src/loader.ts @@ -67,7 +67,7 @@ export default function reanimatedLoader( return; } - // @ts-ignore + // @ts-expect-error callback(null, result.code, result.map); return; } diff --git a/packages/plugin-reanimated/src/rules.ts b/packages/plugin-reanimated/src/rules.ts index 783936a35..8e5eee4c5 100644 --- a/packages/plugin-reanimated/src/rules.ts +++ b/packages/plugin-reanimated/src/rules.ts @@ -73,7 +73,7 @@ const reanimated4ModuleRules = createReanimatedModuleRules(4); const reanimatedModuleRules = reanimated3ModuleRules; export { - reanimatedModuleRules, reanimated3ModuleRules, reanimated4ModuleRules, + reanimatedModuleRules, }; diff --git a/packages/repack/src/commands/common/config/__tests__/makeCompilerConfig.test.ts b/packages/repack/src/commands/common/config/__tests__/makeCompilerConfig.test.ts index 644391257..407d243e5 100644 --- a/packages/repack/src/commands/common/config/__tests__/makeCompilerConfig.test.ts +++ b/packages/repack/src/commands/common/config/__tests__/makeCompilerConfig.test.ts @@ -1,5 +1,8 @@ -import type { ConfigurationObject, StartArguments } from '../../../types.js'; -import type { BundleArguments } from '../../../types.js'; +import type { + BundleArguments, + ConfigurationObject, + StartArguments, +} from '../../../types.js'; import * as getConfigFilePathModule from '../getConfigFilePath.js'; import * as loadProjectConfigModule from '../loadProjectConfig.js'; import { makeCompilerConfig } from '../makeCompilerConfig.js'; diff --git a/packages/repack/src/commands/common/index.ts b/packages/repack/src/commands/common/index.ts index ce61289b7..2d8bbb858 100644 --- a/packages/repack/src/commands/common/index.ts +++ b/packages/repack/src/commands/common/index.ts @@ -1,3 +1,4 @@ +export * from './config/makeCompilerConfig.js'; export * from './getDevMiddleware.js'; export * from './getMaxWorkers.js'; export * from './getMimeType.js'; @@ -8,5 +9,3 @@ export * from './runAdbReverse.js'; export * from './setupEnvironment.js'; export * from './setupInteractions.js'; export * from './setupStatsWriter.js'; - -export * from './config/makeCompilerConfig.js'; diff --git a/packages/repack/src/commands/rspack/Compiler.ts b/packages/repack/src/commands/rspack/Compiler.ts index 3dc6ce2cb..18d4b8b51 100644 --- a/packages/repack/src/commands/rspack/Compiler.ts +++ b/packages/repack/src/commands/rspack/Compiler.ts @@ -1,14 +1,14 @@ import fs from 'node:fs'; import path from 'node:path'; import type { SendProgress, Server } from '@callstack/repack-dev-server'; -import { rspack } from '@rspack/core'; import type { MultiCompiler, MultiRspackOptions, StatsCompilation, } from '@rspack/core'; +import { rspack } from '@rspack/core'; import memfs from 'memfs'; -import { CLIError, adaptFilenameToPlatform } from '../../helpers/index.js'; +import { adaptFilenameToPlatform, CLIError } from '../../helpers/index.js'; import type { Reporter } from '../../logging/types.js'; import type { HMRMessage } from '../../types.js'; import { runAdbReverse } from '../common/index.js'; @@ -72,7 +72,9 @@ export class Compiler { } private callPendingResolvers(platform: string, error?: Error) { - this.resolvers[platform]?.forEach((resolver) => resolver(error)); + this.resolvers[platform]?.forEach((resolver) => { + resolver(error); + }); this.resolvers[platform] = []; } @@ -135,7 +137,7 @@ export class Compiler { }); try { - stats.children!.map((childStats) => { + stats.children!.forEach((childStats) => { const platform = childStats.name!; this.devServerContext.broadcastToHmrClients({ action: 'hash', diff --git a/packages/repack/src/commands/rspack/bundle.ts b/packages/repack/src/commands/rspack/bundle.ts index 6c0975144..2bfbfb6eb 100644 --- a/packages/repack/src/commands/rspack/bundle.ts +++ b/packages/repack/src/commands/rspack/bundle.ts @@ -1,5 +1,5 @@ -import { type Configuration, rspack } from '@rspack/core'; import type { Stats } from '@rspack/core'; +import { type Configuration, rspack } from '@rspack/core'; import { CLIError } from '../../helpers/index.js'; import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js'; import { diff --git a/packages/repack/src/commands/rspack/profile/profile-1.4.ts b/packages/repack/src/commands/rspack/profile/profile-1.4.ts index 228cda3bd..9b1538c96 100644 --- a/packages/repack/src/commands/rspack/profile/profile-1.4.ts +++ b/packages/repack/src/commands/rspack/profile/profile-1.4.ts @@ -10,6 +10,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { rspack } from '@rspack/core'; + const defaultRustTraceLayer = 'perfetto'; export async function applyProfile( @@ -38,11 +39,9 @@ export async function applyProfile( ? defaultRustTracePerfettoOutput : defaultRustTraceLoggerOutput; - // biome-ignore lint/style/noParameterAssign: setting default value makes sense traceOutput = defaultTraceOutput; } else if (traceOutput !== 'stdout' && traceOutput !== 'stderr') { // if traceOutput is not stdout or stderr, we need to ensure the directory exists - // biome-ignore lint/style/noParameterAssign: setting default value makes sense traceOutput = path.resolve(defaultOutputDir, traceOutput); } diff --git a/packages/repack/src/commands/rspack/profile/profile-legacy.ts b/packages/repack/src/commands/rspack/profile/profile-legacy.ts index b28a021b1..cf98d3a1c 100644 --- a/packages/repack/src/commands/rspack/profile/profile-legacy.ts +++ b/packages/repack/src/commands/rspack/profile/profile-legacy.ts @@ -52,7 +52,6 @@ export async function applyProfile( ? defaultRustTraceChromeOutput : defaultRustTraceLoggerOutput; - // biome-ignore lint/style/noParameterAssign: setting default value makes sense traceOutput = defaultTraceOutput; } diff --git a/packages/repack/src/commands/rspack/start.ts b/packages/repack/src/commands/rspack/start.ts index dc915ab4f..c4f53f8b7 100644 --- a/packages/repack/src/commands/rspack/start.ts +++ b/packages/repack/src/commands/rspack/start.ts @@ -4,10 +4,10 @@ import { VERBOSE_ENV_KEY } from '../../env.js'; import { CLIError, isTruthyEnv } from '../../helpers/index.js'; import { ConsoleReporter, - FileReporter, - type Reporter, composeReporters, + FileReporter, makeLogEntryFromFastifyLog, + type Reporter, } from '../../logging/index.js'; import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js'; import { diff --git a/packages/repack/src/commands/webpack/Compiler.ts b/packages/repack/src/commands/webpack/Compiler.ts index 990506e5f..2683ec300 100644 --- a/packages/repack/src/commands/webpack/Compiler.ts +++ b/packages/repack/src/commands/webpack/Compiler.ts @@ -80,7 +80,9 @@ export class Compiler extends EventEmitter { }); const callPendingResolvers = (error?: Error) => { - this.resolvers[platform].forEach((resolver) => resolver(error)); + this.resolvers[platform].forEach((resolver) => { + resolver(error); + }); this.resolvers[platform] = []; }; diff --git a/packages/repack/src/commands/webpack/start.ts b/packages/repack/src/commands/webpack/start.ts index 9cb236def..bea994b5f 100644 --- a/packages/repack/src/commands/webpack/start.ts +++ b/packages/repack/src/commands/webpack/start.ts @@ -5,10 +5,10 @@ import { VERBOSE_ENV_KEY } from '../../env.js'; import { CLIError, isTruthyEnv } from '../../helpers/index.js'; import { ConsoleReporter, - FileReporter, - type Reporter, composeReporters, + FileReporter, makeLogEntryFromFastifyLog, + type Reporter, } from '../../logging/index.js'; import type { HMRMessage } from '../../types.js'; import { makeCompilerConfig } from '../common/config/makeCompilerConfig.js'; diff --git a/packages/repack/src/index.ts b/packages/repack/src/index.ts index d8f0274e8..d208972a4 100644 --- a/packages/repack/src/index.ts +++ b/packages/repack/src/index.ts @@ -1,5 +1,5 @@ +export * from './logging/index.js'; export * as plugins from './plugins/index.js'; export * from './plugins/RepackPlugin.js'; export * from './types.js'; -export * from './logging/index.js'; export * from './utils/index.js'; diff --git a/packages/repack/src/loaders/babelLoader/babelLoader.ts b/packages/repack/src/loaders/babelLoader/babelLoader.ts index ef9de6e20..e9ba968f6 100644 --- a/packages/repack/src/loaders/babelLoader/babelLoader.ts +++ b/packages/repack/src/loaders/babelLoader/babelLoader.ts @@ -1,8 +1,8 @@ import { type BabelFileResult, - type TransformOptions, loadOptions, parseSync, + type TransformOptions, transformFromAstSync, } from '@babel/core'; import type { LoaderContext } from '@rspack/core'; diff --git a/packages/repack/src/loaders/babelSwcLoader/__tests__/swc.test.ts b/packages/repack/src/loaders/babelSwcLoader/__tests__/swc.test.ts index c6413754c..6161d101a 100644 --- a/packages/repack/src/loaders/babelSwcLoader/__tests__/swc.test.ts +++ b/packages/repack/src/loaders/babelSwcLoader/__tests__/swc.test.ts @@ -1,4 +1,4 @@ -import { type SwcLoaderOptions, experiments } from '@rspack/core'; +import { experiments, type SwcLoaderOptions } from '@rspack/core'; import { buildFinalSwcConfig, partitionTransforms } from '../babelSwcLoader.js'; import { addSwcComplementaryTransforms, diff --git a/packages/repack/src/loaders/babelSwcLoader/babelSwcLoader.ts b/packages/repack/src/loaders/babelSwcLoader/babelSwcLoader.ts index 199a9a0ec..8caab087c 100644 --- a/packages/repack/src/loaders/babelSwcLoader/babelSwcLoader.ts +++ b/packages/repack/src/loaders/babelSwcLoader/babelSwcLoader.ts @@ -163,7 +163,7 @@ export default async function babelSwcLoader( sourceType: babelResult.sourceType, }); - const swcResult = swc.transformSync(babelResult?.code!, { + const swcResult = swc.transformSync(babelResult.code!, { ...finalSwcConfig, caller: { name: '@callstack/repack' }, filename: this.resourcePath, diff --git a/packages/repack/src/loaders/babelSwcLoader/swc.ts b/packages/repack/src/loaders/babelSwcLoader/swc.ts index 35ab889ef..858e435be 100644 --- a/packages/repack/src/loaders/babelSwcLoader/swc.ts +++ b/packages/repack/src/loaders/babelSwcLoader/swc.ts @@ -185,7 +185,8 @@ function getTransformDynamicImportConfig( ...swcConfig.jsc, parser: { ...swcConfig.jsc?.parser, - syntax: swcConfig.jsc?.parser?.syntax!, + // parser config from the loader always defines syntax; fallback is unreachable + syntax: swcConfig.jsc?.parser?.syntax ?? 'ecmascript', dynamicImport: true, }, }, diff --git a/packages/repack/src/loaders/babelSwcLoader/utils.ts b/packages/repack/src/loaders/babelSwcLoader/utils.ts index 10e19ba26..a6f67b0d4 100644 --- a/packages/repack/src/loaders/babelSwcLoader/utils.ts +++ b/packages/repack/src/loaders/babelSwcLoader/utils.ts @@ -1,10 +1,10 @@ import { loadOptions } from '@babel/core'; +import type Rspack from '@rspack/core'; import type { + experiments, LoaderContext, SwcLoaderParserConfig, - experiments, } from '@rspack/core'; -import type Rspack from '@rspack/core'; import { importDefaultESM } from '../../helpers/index.js'; type Swc = (typeof experiments)['swc']; diff --git a/packages/repack/src/logging/helpers.ts b/packages/repack/src/logging/helpers.ts index ae9f2def2..92ec926df 100644 --- a/packages/repack/src/logging/helpers.ts +++ b/packages/repack/src/logging/helpers.ts @@ -23,13 +23,19 @@ export function makeLogEntryFromFastifyLog(data: any): LogEntry { export function composeReporters(reporters: Reporter[]): Reporter { return { process: (logEntry) => { - reporters.forEach((reporter) => reporter.process(logEntry)); + reporters.forEach((reporter) => { + reporter.process(logEntry); + }); }, flush: () => { - reporters.forEach((reporter) => reporter.flush()); + reporters.forEach((reporter) => { + reporter.flush(); + }); }, stop: () => { - reporters.forEach((reporter) => reporter.stop()); + reporters.forEach((reporter) => { + reporter.stop(); + }); }, }; } diff --git a/packages/repack/src/logging/reporters.ts b/packages/repack/src/logging/reporters.ts index a824f10fb..232503544 100644 --- a/packages/repack/src/logging/reporters.ts +++ b/packages/repack/src/logging/reporters.ts @@ -4,10 +4,10 @@ import util from 'node:util'; import * as colorette from 'colorette'; import throttle from 'throttleit'; import { - Spinner, colorizePlatformLabel, formatSecondsOneDecimal, renderProgressBar as renderBar, + Spinner, } from './internal/progress.js'; import { MultiPlatformTerminal } from './internal/terminal.js'; import type { @@ -24,7 +24,7 @@ export class ConsoleReporter implements Reporter { constructor(private config: ConsoleReporterConfig) { this.internalReporter = this.config.isWorker || this.config.asJson - ? new JsonConsoleReporter(this.config) + ? new JsonConsoleReporter() : new InteractiveConsoleReporter(this.config); } @@ -42,8 +42,6 @@ export class ConsoleReporter implements Reporter { } class JsonConsoleReporter implements Reporter { - constructor(private config: ConsoleReporterConfig) {} - process(log: LogEntry) { console.log(JSON.stringify(log)); } diff --git a/packages/repack/src/modules/FederationRuntimePlugins/CorePlugin.ts b/packages/repack/src/modules/FederationRuntimePlugins/CorePlugin.ts index 50f4c62d4..67196d99e 100644 --- a/packages/repack/src/modules/FederationRuntimePlugins/CorePlugin.ts +++ b/packages/repack/src/modules/FederationRuntimePlugins/CorePlugin.ts @@ -16,12 +16,12 @@ const RepackCorePlugin: () => FederationRuntimePlugin = () => ({ entry ); - // @ts-ignore + // @ts-expect-error if (!globalThis[entryGlobalName]) { throw new Error(); } - // @ts-ignore + // @ts-expect-error return globalThis[entryGlobalName]; } catch { console.error(`Failed to load remote entry: ${entryGlobalName}`); diff --git a/packages/repack/src/modules/ScriptManager/ScriptManager.ts b/packages/repack/src/modules/ScriptManager/ScriptManager.ts index aa3c57b40..5c4f22f24 100644 --- a/packages/repack/src/modules/ScriptManager/ScriptManager.ts +++ b/packages/repack/src/modules/ScriptManager/ScriptManager.ts @@ -1,11 +1,10 @@ -// biome-ignore lint/style/useNodejsImportProtocol: use 'events' module instead of node builtin import EventEmitter from 'events'; import { AsyncSeriesBailHook, AsyncSeriesWaterfallHook } from 'tapable'; +import { getWebpackContext } from './getWebpackContext.js'; import NativeScriptManager, { type NormalizedScriptLocator, } from './NativeScriptManager.js'; import { Script } from './Script.js'; -import { getWebpackContext } from './getWebpackContext.js'; import type { ScriptLocator, ScriptLocatorResolver, diff --git a/packages/repack/src/modules/ScriptManager/index.ts b/packages/repack/src/modules/ScriptManager/index.ts index 18478f631..fe092f0c0 100644 --- a/packages/repack/src/modules/ScriptManager/index.ts +++ b/packages/repack/src/modules/ScriptManager/index.ts @@ -1,5 +1,5 @@ -export * from './ScriptManager.js'; +export { Federated } from './federated.js'; +export * from './getWebpackContext.js'; export * from './Script.js'; +export * from './ScriptManager.js'; export * from './types.js'; -export * from './getWebpackContext.js'; -export { Federated } from './federated.js'; diff --git a/packages/repack/src/plugins/CodeSigningPlugin/index.ts b/packages/repack/src/plugins/CodeSigningPlugin/index.ts index 4146f2331..ea7576138 100644 --- a/packages/repack/src/plugins/CodeSigningPlugin/index.ts +++ b/packages/repack/src/plugins/CodeSigningPlugin/index.ts @@ -1,7 +1,7 @@ export { CodeSigningPlugin } from './CodeSigningPlugin.js'; export type { CodeSigningPluginConfig } from './config.js'; -export { embedPublicKey } from './embedPublicKey.js'; export type { EmbedPublicKeyConfig, EmbedPublicKeyResult, } from './embedPublicKey.js'; +export { embedPublicKey } from './embedPublicKey.js'; diff --git a/packages/repack/src/plugins/DevelopmentPlugin.ts b/packages/repack/src/plugins/DevelopmentPlugin.ts index be0e25ced..0f9e56286 100644 --- a/packages/repack/src/plugins/DevelopmentPlugin.ts +++ b/packages/repack/src/plugins/DevelopmentPlugin.ts @@ -52,24 +52,24 @@ export class DevelopmentPlugin { private getModuleFederationEntryChunks(plugins: Plugins) { const entrypoints = plugins.map((plugin) => { if (typeof plugin !== 'object' || !plugin) { - return; + return undefined; } if (!plugin.constructor?.name.startsWith('ModuleFederationPlugin')) { - return; + return undefined; } // repack MF plugins expose config property - if ('config' in plugin && !!plugin.config.exposes) { + if ('config' in plugin && plugin.config.exposes) { return plugin.config.name; } // official MF plugins expose _options property - if ('_options' in plugin && !!plugin.config.exposes) { + if ('_options' in plugin && plugin.config.exposes) { return plugin._options.name; } - return; + return undefined; }); return entrypoints.filter(Boolean); diff --git a/packages/repack/src/plugins/HermesBytecodePlugin/index.ts b/packages/repack/src/plugins/HermesBytecodePlugin/index.ts index e898218f6..6c4a58b16 100644 --- a/packages/repack/src/plugins/HermesBytecodePlugin/index.ts +++ b/packages/repack/src/plugins/HermesBytecodePlugin/index.ts @@ -1,2 +1,2 @@ -export * from './HermesBytecodePlugin.js'; export * from './ChunksToHermesBytecodePlugin.js'; +export * from './HermesBytecodePlugin.js'; diff --git a/packages/repack/src/plugins/LoggerPlugin.ts b/packages/repack/src/plugins/LoggerPlugin.ts index 93f4a609b..c72a9ab37 100644 --- a/packages/repack/src/plugins/LoggerPlugin.ts +++ b/packages/repack/src/plugins/LoggerPlugin.ts @@ -4,11 +4,11 @@ import { VERBOSE_ENV_KEY, WORKER_ENV_KEY } from '../env.js'; import { isTruthyEnv } from '../helpers/index.js'; import { ConsoleReporter, + composeReporters, FileReporter, type LogEntry, type LogType, type Reporter, - composeReporters, } from '../logging/index.js'; export type GenericFilter = Array; diff --git a/packages/repack/src/plugins/ModuleFederationPlugin.ts b/packages/repack/src/plugins/ModuleFederationPlugin.ts index 08bebf88b..976631347 100644 --- a/packages/repack/src/plugins/ModuleFederationPlugin.ts +++ b/packages/repack/src/plugins/ModuleFederationPlugin.ts @@ -1,6 +1,5 @@ -import type { Compiler as RspackCompiler, container } from '@rspack/core'; +import type { container, Compiler as RspackCompiler } from '@rspack/core'; import type { Compiler as WebpackCompiler } from 'webpack'; -// biome-ignore lint/correctness/noUnusedImports: needed for jsdoc import type { Federated } from '../utils/federated.js'; import { ModuleFederationPluginV1, @@ -85,7 +84,9 @@ export type ModuleFederationPluginConfig = ModuleFederationPluginV1Config; * @category Webpack Plugin */ export class ModuleFederationPlugin { + // biome-ignore lint/correctness/noUnusedPrivateClassMembers: exposed at runtime for compat with V1 plugin private config: MFPluginV1Options; + // biome-ignore lint/correctness/noUnusedPrivateClassMembers: exposed at runtime for compat with V1 plugin private deepImports: boolean; private plugin: ModuleFederationPluginV1; diff --git a/packages/repack/src/plugins/ModuleFederationPluginV1.ts b/packages/repack/src/plugins/ModuleFederationPluginV1.ts index 938cda335..81a570d7c 100644 --- a/packages/repack/src/plugins/ModuleFederationPluginV1.ts +++ b/packages/repack/src/plugins/ModuleFederationPluginV1.ts @@ -1,4 +1,4 @@ -import type { Compiler as RspackCompiler, container } from '@rspack/core'; +import type { container, Compiler as RspackCompiler } from '@rspack/core'; import type { Compiler as WebpackCompiler } from 'webpack'; import { isRspackCompiler } from '../helpers/index.js'; import { Federated } from '../utils/federated.js'; diff --git a/packages/repack/src/plugins/NativeEntryPlugin/index.ts b/packages/repack/src/plugins/NativeEntryPlugin/index.ts index 52b9bf882..261fcda1c 100644 --- a/packages/repack/src/plugins/NativeEntryPlugin/index.ts +++ b/packages/repack/src/plugins/NativeEntryPlugin/index.ts @@ -1,2 +1,2 @@ -export { NativeEntryPlugin } from './NativeEntryPlugin.js'; export type { NativeEntryPluginConfig } from './NativeEntryPlugin.js'; +export { NativeEntryPlugin } from './NativeEntryPlugin.js'; diff --git a/packages/repack/src/plugins/OutputPlugin/OutputPlugin.ts b/packages/repack/src/plugins/OutputPlugin/OutputPlugin.ts index c7270114f..49ddb2134 100644 --- a/packages/repack/src/plugins/OutputPlugin/OutputPlugin.ts +++ b/packages/repack/src/plugins/OutputPlugin/OutputPlugin.ts @@ -99,19 +99,25 @@ export class OutputPlugin { chunks .filter((chunk) => chunk.initial && chunk.entry) .filter((chunk) => chunk.id! in entryOptions) - .forEach((chunk) => localChunks.add(chunk)); + .forEach((chunk) => { + localChunks.add(chunk); + }); // Add siblings of known initial chunks as local chunks chunks .filter((chunk) => localChunks.has(chunk)) .flatMap((chunk) => chunk.siblings!) .map((chunkId) => chunksById.get(chunkId)) - .forEach((chunk) => localChunks.add(chunk!)); + .forEach((chunk) => { + localChunks.add(chunk!); + }); // Add chunks matching local specs as local chunks chunks .filter((chunk) => chunkMatcher(chunk, this.localSpecs).length) - .forEach((chunk) => localChunks.add(chunk)); + .forEach((chunk) => { + localChunks.add(chunk); + }); // Add parents of local chunks as local chunks const addParentsOfLocalChunks = () => { @@ -119,7 +125,9 @@ export class OutputPlugin { .filter((chunk) => localChunks.has(chunk)) .flatMap((chunk) => chunk.parents!) .map((chunkId) => chunksById.get(chunkId)) - .forEach((chunk) => localChunks.add(chunk!)); + .forEach((chunk) => { + localChunks.add(chunk!); + }); return localChunks.size; }; @@ -129,7 +137,9 @@ export class OutputPlugin { // Add all other chunks as remote chunks chunks .filter((chunk) => !localChunks.has(chunk)) - .forEach((chunk) => remoteChunks.add(chunk)); + .forEach((chunk) => { + remoteChunks.add(chunk); + }); return { localChunks, remoteChunks }; } @@ -146,7 +156,9 @@ export class OutputPlugin { compiler.hooks.beforeCompile.tap('RepackOutputPlugin', () => { const deprecationMessages = getDeprecationMessages(this.config); - deprecationMessages.forEach((message) => logger.warn(message)); + deprecationMessages.forEach((message) => { + logger.warn(message); + }); }); const logger = compiler.getInfrastructureLogger('RepackOutputPlugin'); @@ -210,7 +222,9 @@ export class OutputPlugin { // Collect auxiliary assets (only remote-assets for now) assets .filter((asset) => /^remote-assets/.test(asset.name)) - .forEach((asset) => auxiliaryAssets.add(asset.name)); + .forEach((asset) => { + auxiliaryAssets.add(asset.name); + }); let localAssetsCopyProcessor: AssetsCopyProcessor | undefined; diff --git a/packages/repack/src/plugins/__tests__/OutputPlugin.test.ts b/packages/repack/src/plugins/__tests__/OutputPlugin.test.ts index 90adedab0..e6984f664 100644 --- a/packages/repack/src/plugins/__tests__/OutputPlugin.test.ts +++ b/packages/repack/src/plugins/__tests__/OutputPlugin.test.ts @@ -4,8 +4,8 @@ import path from 'node:path'; import { type EntryNormalized, ModuleFilenameHelpers, - type StatsChunk, rspack, + type StatsChunk, } from '@rspack/core'; import RspackVirtualModulePlugin from 'rspack-plugin-virtual-module'; import { @@ -238,7 +238,9 @@ describe('OutputPlugin', () => { expect(localChunks.size).toBe(5); expect(remoteChunks.size).toBe(0); - chunks.forEach((chunk) => expect(localChunks.has(chunk)).toBe(true)); + chunks.forEach((chunk) => { + expect(localChunks.has(chunk)).toBe(true); + }); }); }); diff --git a/packages/repack/src/plugins/index.ts b/packages/repack/src/plugins/index.ts index 74969765c..a4c866e44 100644 --- a/packages/repack/src/plugins/index.ts +++ b/packages/repack/src/plugins/index.ts @@ -1,12 +1,12 @@ +export * from './BabelPlugin.js'; +export * from './CodeSigningPlugin/index.js'; export * from './DevelopmentPlugin.js'; +export * from './HermesBytecodePlugin/index.js'; export * from './LoggerPlugin.js'; export * from './ManifestPlugin.js'; -export * from './BabelPlugin.js'; -export * from './OutputPlugin/index.js'; -export * from './RepackTargetPlugin/index.js'; export * from './ModuleFederationPlugin.js'; export * from './ModuleFederationPluginV1.js'; export * from './ModuleFederationPluginV2.js'; -export * from './CodeSigningPlugin/index.js'; -export * from './HermesBytecodePlugin/index.js'; export * from './NativeEntryPlugin/index.js'; +export * from './OutputPlugin/index.js'; +export * from './RepackTargetPlugin/index.js'; diff --git a/packages/repack/src/types/runtime-globals.d.ts b/packages/repack/src/types/runtime-globals.d.ts index 8b6c03c55..6f4c03db3 100644 --- a/packages/repack/src/types/runtime-globals.d.ts +++ b/packages/repack/src/types/runtime-globals.d.ts @@ -40,9 +40,7 @@ declare namespace RepackRuntimeGlobals { declare interface RepackRuntimeObject { shared: { - scriptManager?: import( - '../modules/ScriptManager/ScriptManager.js' - ).ScriptManager; + scriptManager?: import('../modules/ScriptManager/ScriptManager.js').ScriptManager; enqueuedResolvers: [ import('../modules/ScriptManager/types.js').ScriptLocatorResolver, { key?: string }, diff --git a/packages/repack/src/utils/__tests__/getAssetTransformRules.test.ts b/packages/repack/src/utils/__tests__/getAssetTransformRules.test.ts index 63d20826c..fe5fa96e9 100644 --- a/packages/repack/src/utils/__tests__/getAssetTransformRules.test.ts +++ b/packages/repack/src/utils/__tests__/getAssetTransformRules.test.ts @@ -9,7 +9,7 @@ describe('getAssetTransformRules', () => { it('should return rules with inline option when provided', () => { const rules = getAssetTransformRules({ inline: true }); - // @ts-ignore + // @ts-expect-error expect(rules[0]?.use?.options?.inline).toEqual(true); expect(rules).toMatchSnapshot(); }); @@ -17,7 +17,7 @@ describe('getAssetTransformRules', () => { it('should return rules with maxInlineSize option when provided', () => { const rules = getAssetTransformRules({ maxInlineSize: 1024 }); - // @ts-ignore + // @ts-expect-error expect(rules[0]?.use?.options?.maxInlineSize).toEqual(1024); expect(rules).toMatchSnapshot(); }); @@ -26,7 +26,7 @@ describe('getAssetTransformRules', () => { const remoteOptions = { publicPath: 'https://example.com/assets' }; const rules = getAssetTransformRules({ remote: remoteOptions }); - // @ts-ignore + // @ts-expect-error expect(rules[0]?.use?.options?.remote).toHaveProperty('enabled', true); expect(rules).toMatchSnapshot(); }); @@ -43,7 +43,7 @@ describe('getAssetTransformRules', () => { const rules = getAssetTransformRules({ svg: 'xml' }); expect(rules).toHaveLength(2); - // @ts-ignore + // @ts-expect-error expect(rules[1]?.type).toEqual('asset/source'); expect(rules).toMatchSnapshot(); }); @@ -52,7 +52,7 @@ describe('getAssetTransformRules', () => { const rules = getAssetTransformRules({ svg: 'uri' }); expect(rules).toHaveLength(2); - // @ts-ignore + // @ts-expect-error expect(rules[1]?.type).toEqual('asset/inline'); expect(rules).toMatchSnapshot(); }); diff --git a/packages/repack/src/utils/index.ts b/packages/repack/src/utils/index.ts index 0dfdb06cf..46fe65969 100644 --- a/packages/repack/src/utils/index.ts +++ b/packages/repack/src/utils/index.ts @@ -1,12 +1,12 @@ export * from './assetExtensions.js'; export * from './defineConfig.js'; export * from './federated.js'; +export * from './getAssetTransformRules.js'; +export * from './getCodegenTransformRules.js'; export * from './getDirname.js'; +export * from './getFlowTransformRules.js'; +export * from './getJsTransformRules.js'; +export * from './getModulePaths.js'; export * from './getPublicPath.js'; export * from './getResolveOptions.js'; -export * from './getModulePaths.js'; -export * from './getJsTransformRules.js'; export * from './getSwcLoaderOptions.js'; -export * from './getFlowTransformRules.js'; -export * from './getCodegenTransformRules.js'; -export * from './getAssetTransformRules.js'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6af9f345b..f74dd3e12 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,8 +95,8 @@ importers: specifier: ^7.29.7 version: 7.29.7 '@biomejs/biome': - specifier: ^1.9.4 - version: 1.9.4 + specifier: ^2.5.6 + version: 2.5.6 '@changesets/changelog-github': specifier: ^0.7.0 version: 0.7.0 @@ -1617,59 +1617,59 @@ packages: '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} - '@biomejs/biome@1.9.4': - resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==} + '@biomejs/biome@2.5.6': + resolution: {integrity: sha512-lxVNjv7UF6KfhMJfL9gaUHbWdJdHbsAj6OSmwSYNdhRuG67NxNQ4Xdvh3TUxsSK9sBzJBQhEJj3AopmmNJ5pSA==} engines: {node: '>=14.21.3'} hasBin: true - '@biomejs/cli-darwin-arm64@1.9.4': - resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==} + '@biomejs/cli-darwin-arm64@2.5.6': + resolution: {integrity: sha512-zMOLZP4oMrjh6m1zcSj1ud2awUPgTuMVbmQhYYWL7J8HwCnbHHBvTm7VBTRuY7epT5bez76IpKYQ11ZAqHFlnw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [darwin] - '@biomejs/cli-darwin-x64@1.9.4': - resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==} + '@biomejs/cli-darwin-x64@2.5.6': + resolution: {integrity: sha512-JAC1VqzvO7Th5ZplU0G2uGfkZbxEe9uDDektPAhF0JLusoz1w+T4okp2bkykI0bbaO2vslKiRfj4gU43JaGreA==} engines: {node: '>=14.21.3'} cpu: [x64] os: [darwin] - '@biomejs/cli-linux-arm64-musl@1.9.4': - resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==} + '@biomejs/cli-linux-arm64-musl@2.5.6': + resolution: {integrity: sha512-eUa3jeeYvfMt19LBeh6E5PUZpxnTC4JqNWo+EDjTtQjAr2xLGnWaxACtVU1DQqmHYbvThlJzLX+ZsYgrqh2qVw==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] libc: [musl] - '@biomejs/cli-linux-arm64@1.9.4': - resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} + '@biomejs/cli-linux-arm64@2.5.6': + resolution: {integrity: sha512-6XsYwCFkp5sMxl85ffhgeGpGgs6A7dRYFnkceZ7WVxvycuTnGdD5xa534Z3xfrBQ0JCMK/mujT6ZNPJoghedwg==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [linux] libc: [glibc] - '@biomejs/cli-linux-x64-musl@1.9.4': - resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} + '@biomejs/cli-linux-x64-musl@2.5.6': + resolution: {integrity: sha512-2Vp13QdKysH3HIWLaYLhUUwbK+jbZonJD1K+Lr0d0RO4wH7mkYd43vJixEDm8cUWrowoRz4UUHF1nm9Ae7ym8A==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] libc: [musl] - '@biomejs/cli-linux-x64@1.9.4': - resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} + '@biomejs/cli-linux-x64@2.5.6': + resolution: {integrity: sha512-Pop9VXCFUhFTMfFefZ39S+u2rOPyNp5iHlxbZRwXGACHLy2r0jjiRgJHmaEKJzL3SyxlVeGShXhvvElvWowonA==} engines: {node: '>=14.21.3'} cpu: [x64] os: [linux] libc: [glibc] - '@biomejs/cli-win32-arm64@1.9.4': - resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} + '@biomejs/cli-win32-arm64@2.5.6': + resolution: {integrity: sha512-tDGshcm6BdkZOCGnTDX0Y8/U4IfBSlnUU7T56nNDuPEfed+aHg+u8G36NB43fJVl0Os6+QURXIE1yuD7AaEofA==} engines: {node: '>=14.21.3'} cpu: [arm64] os: [win32] - '@biomejs/cli-win32-x64@1.9.4': - resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==} + '@biomejs/cli-win32-x64@2.5.6': + resolution: {integrity: sha512-WN05KwXnTO/2J45RQPvzZMXf7tZUIofHoR35xIPfCo7pQ2RFidxI8sfb5mGsaTxdMmEOzHzOPRCdA5/fCpc7xQ==} engines: {node: '>=14.21.3'} cpu: [x64] os: [win32] @@ -9395,39 +9395,39 @@ snapshots: '@bcoe/v8-coverage@0.2.3': {} - '@biomejs/biome@1.9.4': + '@biomejs/biome@2.5.6': optionalDependencies: - '@biomejs/cli-darwin-arm64': 1.9.4 - '@biomejs/cli-darwin-x64': 1.9.4 - '@biomejs/cli-linux-arm64': 1.9.4 - '@biomejs/cli-linux-arm64-musl': 1.9.4 - '@biomejs/cli-linux-x64': 1.9.4 - '@biomejs/cli-linux-x64-musl': 1.9.4 - '@biomejs/cli-win32-arm64': 1.9.4 - '@biomejs/cli-win32-x64': 1.9.4 - - '@biomejs/cli-darwin-arm64@1.9.4': + '@biomejs/cli-darwin-arm64': 2.5.6 + '@biomejs/cli-darwin-x64': 2.5.6 + '@biomejs/cli-linux-arm64': 2.5.6 + '@biomejs/cli-linux-arm64-musl': 2.5.6 + '@biomejs/cli-linux-x64': 2.5.6 + '@biomejs/cli-linux-x64-musl': 2.5.6 + '@biomejs/cli-win32-arm64': 2.5.6 + '@biomejs/cli-win32-x64': 2.5.6 + + '@biomejs/cli-darwin-arm64@2.5.6': optional: true - '@biomejs/cli-darwin-x64@1.9.4': + '@biomejs/cli-darwin-x64@2.5.6': optional: true - '@biomejs/cli-linux-arm64-musl@1.9.4': + '@biomejs/cli-linux-arm64-musl@2.5.6': optional: true - '@biomejs/cli-linux-arm64@1.9.4': + '@biomejs/cli-linux-arm64@2.5.6': optional: true - '@biomejs/cli-linux-x64-musl@1.9.4': + '@biomejs/cli-linux-x64-musl@2.5.6': optional: true - '@biomejs/cli-linux-x64@1.9.4': + '@biomejs/cli-linux-x64@2.5.6': optional: true - '@biomejs/cli-win32-arm64@1.9.4': + '@biomejs/cli-win32-arm64@2.5.6': optional: true - '@biomejs/cli-win32-x64@1.9.4': + '@biomejs/cli-win32-x64@2.5.6': optional: true '@callstack/rspress-preset@0.6.0(@rsbuild/core@2.0.0-alpha.4(@module-federation/runtime-tools@2.8.0)(core-js@3.42.0))(@rspress/core@2.0.0(@module-federation/runtime-tools@2.8.0)(@types/react@18.3.31)(core-js@3.42.0))(react-dom@19.2.8(react@19.2.8))(react@19.2.8)': diff --git a/tests/integration/src/helpers.ts b/tests/integration/src/helpers.ts index 4ceea48f7..ea231fe62 100644 --- a/tests/integration/src/helpers.ts +++ b/tests/integration/src/helpers.ts @@ -2,7 +2,7 @@ import type { Compiler as RspackCompiler, Configuration as RspackConfiguration, } from '@rspack/core'; -import { Volume, createFsFromVolume } from 'memfs'; +import { createFsFromVolume, Volume } from 'memfs'; import { inject } from 'vitest'; import type { Compiler as WebpackCompiler, diff --git a/tests/integration/src/plugins/NativeEntryPlugin.test.ts b/tests/integration/src/plugins/NativeEntryPlugin.test.ts index 0f08026b5..5dc64768c 100644 --- a/tests/integration/src/plugins/NativeEntryPlugin.test.ts +++ b/tests/integration/src/plugins/NativeEntryPlugin.test.ts @@ -2,15 +2,15 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { plugins } from '@callstack/repack'; import type { Configuration } from '@rspack/core'; -import { Volume, createFsFromVolume } from 'memfs'; +import { createFsFromVolume, Volume } from 'memfs'; import { describe, expect, inject, it } from 'vitest'; -import { createCompiler, createVirtualModulePlugin } from '../helpers.js'; - // Webpack throws when multiple versions of @module-federation/enhanced register // serializers with the same key. Patch ObjectMiddleware.register to allow // re-registration since we externalize all MF modules and never use serialization. // @ts-expect-error no types for internal webpack module import ObjectMiddleware from 'webpack/lib/serialization/ObjectMiddleware'; +import { createCompiler, createVirtualModulePlugin } from '../helpers.js'; + const _register = ObjectMiddleware.register.bind(ObjectMiddleware); ObjectMiddleware.register = (...args: unknown[]) => { try { diff --git a/tests/integration/src/plugins/__fixtures__/react-native/package.json b/tests/integration/src/plugins/__fixtures__/react-native/package.json index a3c15a7a6..5bbefffba 100644 --- a/tests/integration/src/plugins/__fixtures__/react-native/package.json +++ b/tests/integration/src/plugins/__fixtures__/react-native/package.json @@ -1 +1,3 @@ -{ "type": "commonjs" } +{ + "type": "commonjs" +} diff --git a/website/theme/index.tsx b/website/theme/index.tsx index a131c4355..bf8d48542 100644 --- a/website/theme/index.tsx +++ b/website/theme/index.tsx @@ -40,6 +40,5 @@ const Layout = () => ( /> ); -export { Layout }; - export * from '@rspress/core/theme-original'; +export { Layout }; From 835e01396a69bd6d35ec57f636cfbba0a4c12e9b Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Thu, 30 Jul 2026 14:53:31 +0100 Subject: [PATCH 2/3] fix: clear WebSocketServer heartbeat interval on server close The heartbeat setInterval started in the WebSocketServer constructor was never cleared, keeping the event loop alive after the fastify server closes. Register an onClose hook so the interval is cleared when the dev server shuts down. --- packages/dev-server/src/plugins/wss/WebSocketServer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/dev-server/src/plugins/wss/WebSocketServer.ts b/packages/dev-server/src/plugins/wss/WebSocketServer.ts index 0524a0410..649b4f7ca 100644 --- a/packages/dev-server/src/plugins/wss/WebSocketServer.ts +++ b/packages/dev-server/src/plugins/wss/WebSocketServer.ts @@ -28,6 +28,8 @@ export abstract class WebSocketServer protected clients: Map; protected nextClientId = 0; + private heartbeatTimer: NodeJS.Timeout; + /** * Create a new instance of the WebSocketServer. * Any logging information, will be passed through standard `fastify.log` API. @@ -46,7 +48,7 @@ export abstract class WebSocketServer this.clients = new Map(); // setup heartbeat timer - setInterval(() => { + this.heartbeatTimer = setInterval(() => { this.clients.forEach((socket) => { if (!socket.isAlive) { socket.terminate(); @@ -56,6 +58,10 @@ export abstract class WebSocketServer } }); }, 30000); + + this.fastify.addHook('onClose', async () => { + clearInterval(this.heartbeatTimer); + }); } shouldUpgrade(pathname: string) { From a59f79ec00983af6c341853e57efe1d48bbe8924 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Thu, 30 Jul 2026 14:55:41 +0100 Subject: [PATCH 3/3] fix: use portable timer type for heartbeat interval packages/repack typechecks the dev-server sources with DOM libs, where setInterval returns number instead of NodeJS.Timeout. Use ReturnType so the field types correctly under both lib configurations. --- packages/dev-server/src/plugins/wss/WebSocketServer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dev-server/src/plugins/wss/WebSocketServer.ts b/packages/dev-server/src/plugins/wss/WebSocketServer.ts index 649b4f7ca..3b48be040 100644 --- a/packages/dev-server/src/plugins/wss/WebSocketServer.ts +++ b/packages/dev-server/src/plugins/wss/WebSocketServer.ts @@ -28,7 +28,7 @@ export abstract class WebSocketServer protected clients: Map; protected nextClientId = 0; - private heartbeatTimer: NodeJS.Timeout; + private heartbeatTimer: ReturnType; /** * Create a new instance of the WebSocketServer.