diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 4196e31..01512c3 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -1,6 +1,6 @@ { - $schema: "https://docs.renovatebot.com/renovate-schema.json", - extends: ["config:base", "schedule:monthly", "group:allNonMajor"], - rangeStrategy: "bump", - packageRules: [{ depTypeList: ["peerDependencies"], enabled: false }] + $schema: 'https://docs.renovatebot.com/renovate-schema.json', + extends: ['config:base', 'schedule:monthly', 'group:allNonMajor'], + rangeStrategy: 'bump', + packageRules: [{ depTypeList: ['peerDependencies'], enabled: false }], } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86b66ab..89e91b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,9 +5,9 @@ on: inputs: version: type: choice - description: "Release Version Type" + description: 'Release Version Type' required: true - default: "patch" + default: 'patch' options: - major - premajor @@ -19,9 +19,9 @@ on: tag: type: choice - description: "Release Npm Tag" + description: 'Release Npm Tag' required: true - default: "latest" + default: 'latest' options: - canary - nightly @@ -31,7 +31,7 @@ on: dry_run: type: boolean - description: "DryRun release" + description: 'DryRun release' required: true default: false @@ -58,7 +58,7 @@ jobs: uses: actions/setup-node@v6 with: node-version: 20 - cache: "pnpm" + cache: 'pnpm' # Update npm to the latest version to enable OIDC - name: Update npm diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ddd974b..92a8c80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,7 +43,7 @@ jobs: uses: actions/setup-node@v6 with: node-version: ${{ matrix.node }} - cache: "pnpm" + cache: 'pnpm' - name: Install Dependencies run: pnpm install @@ -70,7 +70,7 @@ jobs: uses: actions/setup-node@v6 with: node-version: 20 - cache: "pnpm" + cache: 'pnpm' - name: Install Dependencies run: pnpm install diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 475d811..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,21 +0,0 @@ -module.exports = { - useTabs: true, - tabWidth: 2, - trailingComma: "none", - arrowParens: "avoid", - overrides: [ - { - files: "*.json", - options: { - parser: "json", - useTabs: false - } - }, - { - files: "*.ts", - options: { - parser: "typescript" - } - } - ] -}; diff --git a/README.md b/README.md index 5162fb8..6e6ee2c 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,11 @@ While starting the development server, you can specify the configuration by the ```js // rspack.config.mjs export default { - // ... - devServer: { - // the configuration of the development server - port: 8080 - } + // ... + devServer: { + // the configuration of the development server + port: 8080, + }, }; ``` @@ -90,21 +90,21 @@ export default { While it's recommended to run `@rspack/dev-server` via the CLI, you may also choose to start a server via the API. ```js -import { RspackDevServer } from "@rspack/dev-server"; -import rspack from "@rspack/core"; -import rspackConfig from "./rspack.config.mjs"; +import { RspackDevServer } from '@rspack/dev-server'; +import rspack from '@rspack/core'; +import rspackConfig from './rspack.config.mjs'; const compiler = rspack(rspackConfig); const devServerOptions = { - ...rspackConfig.devServer, - // override - port: 8888 + ...rspackConfig.devServer, + // override + port: 8888, }; const server = new RspackDevServer(devServerOptions, compiler); server.startCallback(() => { - console.log("Successfully started server on http://localhost:8888"); + console.log('Successfully started server on http://localhost:8888'); }); ``` diff --git a/biome.jsonc b/biome.jsonc index f798737..3e1e9aa 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,11 +1,11 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json", - "files": { - "ignore": [ - "client-src/**/*", - "client/**/*.js", - "dist/**/*", - "tests/fixtures/**/*" - ] - } + "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json", + "files": { + "ignore": [ + "client-src/**/*", + "client/**/*.js", + "dist/**/*", + "tests/fixtures/**/*", + ], + }, } diff --git a/client-src/index.js b/client-src/index.js index e76f6a3..6c33901 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -1,21 +1,21 @@ // @ts-nocheck -import hotEmitter from "@rspack/core/hot/emitter.js"; +import hotEmitter from '@rspack/core/hot/emitter.js'; /* global __resourceQuery, __webpack_hash__ */ /* Rspack dev server runtime client */ /// -import webpackHotLog from "@rspack/core/hot/log.js"; +import webpackHotLog from '@rspack/core/hot/log.js'; import { - createOverlay, - formatProblem -} from "webpack-dev-server/client/overlay.js"; -import socket from "webpack-dev-server/client/socket.js"; + createOverlay, + formatProblem, +} from 'webpack-dev-server/client/overlay.js'; +import socket from 'webpack-dev-server/client/socket.js'; import { - defineProgressElement, - isProgressSupported -} from "webpack-dev-server/client/progress.js"; -import { log, setLogLevel } from "webpack-dev-server/client/utils/log.js"; -import sendMessage from "webpack-dev-server/client/utils/sendMessage.js"; + defineProgressElement, + isProgressSupported, +} from 'webpack-dev-server/client/progress.js'; +import { log, setLogLevel } from 'webpack-dev-server/client/utils/log.js'; +import sendMessage from 'webpack-dev-server/client/utils/sendMessage.js'; /** * @typedef {Object} OverlayOptions @@ -45,290 +45,290 @@ import sendMessage from "webpack-dev-server/client/utils/sendMessage.js"; /** * @param {boolean | { warnings?: boolean | string; errors?: boolean | string; runtimeErrors?: boolean | string; }} overlayOptions */ -const decodeOverlayOptions = overlayOptions => { - if (typeof overlayOptions === "object") { - ["warnings", "errors", "runtimeErrors"].forEach(property => { - if (typeof overlayOptions[property] === "string") { - const overlayFilterFunctionString = decodeURIComponent( - overlayOptions[property] - ); - - // eslint-disable-next-line no-new-func - overlayOptions[property] = new Function( - "message", - `var callback = ${overlayFilterFunctionString} - return callback(message)` - ); - } - }); - } +const decodeOverlayOptions = (overlayOptions) => { + if (typeof overlayOptions === 'object') { + ['warnings', 'errors', 'runtimeErrors'].forEach((property) => { + if (typeof overlayOptions[property] === 'string') { + const overlayFilterFunctionString = decodeURIComponent( + overlayOptions[property], + ); + + // eslint-disable-next-line no-new-func + overlayOptions[property] = new Function( + 'message', + `var callback = ${overlayFilterFunctionString} + return callback(message)`, + ); + } + }); + } }; /** * @param {string} resourceQuery * @returns {{ [key: string]: string | boolean }} */ -const parseURL = resourceQuery => { - /** @type {{ [key: string]: string }} */ - let result = {}; - - if (typeof resourceQuery === "string" && resourceQuery !== "") { - const searchParams = resourceQuery.slice(1).split("&"); - - for (let i = 0; i < searchParams.length; i++) { - const pair = searchParams[i].split("="); - - result[pair[0]] = decodeURIComponent(pair[1]); - } - } else { - // Else, get the url from the