Skip to content
Merged
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
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm exec oxfmt --write src/
9 changes: 9 additions & 0 deletions .oxfmtrc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 100,
"singleQuote": true,
"semi": false,
"sortPackageJson": false,
"sortImports": true,
"ignorePatterns": ["dist", "node_modules"],
}
14 changes: 14 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "unicorn", "oxc"],
"categories": {
"correctness": "error"
},
"rules": {
"no-async-promise-executor": "off"
},
"env": {
"builtin": true
},
"ignorePatterns": ["dist", "node_modules"]
}
6 changes: 0 additions & 6 deletions .prettierignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc.js

This file was deleted.

5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.tsdk.path": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Two workarounds are in place (TODO: remove once [tsx#782](https://github.com/pri
2. **`dynamicAbsoluteImport`** in `sourceRelativeRspackModules.ts` — uses `new Function('specifier', 'return import(specifier)')` to preserve native `import()` at runtime, preventing tsc (CommonJS target) from converting `import()` to `require()`.

Related issues:

- https://github.com/privatenumber/tsx/issues/781
- https://github.com/web-infra-dev/rspack/issues/13420

Expand Down
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ npm install -D cypress-rspack-dev-server
## Usage

```ts
import { devServer } from "cypress-rspack-dev-server";
import { defineConfig } from "cypress";
import { devServer } from 'cypress-rspack-dev-server'
import { defineConfig } from 'cypress'

export default defineConfig({
component: {
devServer(devServerConfig) {
return devServer({
...devServerConfig,
framework: "react",
rspackConfig: require("./rspack.config.js"),
});
framework: 'react',
rspackConfig: require('./rspack.config.js'),
})
},
},
});
})
```

## Dev server parameters
Expand Down Expand Up @@ -74,15 +74,19 @@ async devServer(devServerConfig) {
}
```

## Migration to v1
## Migration

In version 1, we supports the [Cypress 14 's justInTimeCompile](https://docs.cypress.io/app/references/changelog#14-0-0), the specs structure has been updated.
### v1 (Cypress 14+)

In version 1, we support the [Cypress 14 's justInTimeCompile](https://docs.cypress.io/app/references/changelog#14-0-0), the specs structure has been updated.
If you still use Cypress <= 13, please use the version 0.0.x.

### v2 (Rspack v2 support)

In version 2, we support Rspack v2 (2.0.0-rc and above). If you are using Rspack v1, please use the version 1.x.x.

## License

[![license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cypress-io/cypress/blob/develop/LICENSE)

This project is licensed under the terms of the [MIT license](/LICENSE).

````
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

1 change: 1 addition & 0 deletions cypress/component/Test.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'

import { TestComponent } from './TestComponent'

describe('Test.cy.tsx', () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/config/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'cypress'

import { devServer } from '../../dist/devServer'

export default defineConfig({
Expand Down
24 changes: 11 additions & 13 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Components App</title>
</head>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>

<body>
<div data-cy-root></div>
</body>

</html>
<body>
<div data-cy-root></div>
</body>
</html>
3 changes: 2 additions & 1 deletion description.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
This project implements a development server for Cypress using Rspack as the bundler. Here's a comprehensive breakdown of its architecture and components:

### Core Purpose

- Development server specifically designed for Cypress component testing
- Uses Rspack (Rust-based bundler) as a faster alternative to Webpack

Expand All @@ -29,8 +30,8 @@ This project implements a development server for Cypress using Rspack as the bun
- Manages dev server instance creation and setup

### Notable Features

- Framework-agnostic design
- Smart configuration merging
- Built-in optimization
- Debug support through 'debug' library

8 changes: 3 additions & 5 deletions dist/CypressCTRspackPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.CypressCTRspackPlugin = exports.normalizeError = void 0;
const tslib_1 = require("tslib");
const lodash_1 = require("lodash");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = (0, debug_1.default)('cypress-rspack-dev-server:rspackPlugin');
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const lodash_1 = require("lodash");
const normalizeError = (error) => {
return typeof error === 'string' ? error : error.message;
};
Expand Down Expand Up @@ -41,7 +39,7 @@ class CypressCTRspackPlugin {
const exists = await fs_extra_1.default.pathExists(file.absolute);
return exists ? file : null;
}
catch (e) {
catch (_a) {
return null;
}
}));
Expand Down
2 changes: 1 addition & 1 deletion dist/createRspackDevServer.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RspackDevServer } from '@rspack/dev-server';
import type { Compiler } from '@rspack/core';
import type { RspackDevServer } from '@rspack/dev-server';
import type { DevServerConfig } from './devServer';
import type { SourceRelativeRspackResult } from './helpers/sourceRelativeRspackModules';
/**
Expand Down
6 changes: 3 additions & 3 deletions dist/devServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function isThirdPartyDefinition(framework) {
async function getPreset(devServerConfig) {
const defaultRspackModules = async () => {
const sourceRspackModulesResult = await (0, sourceRelativeRspackModules_1.sourceDefaultRspackDependencies)(devServerConfig);
return ({
sourceRspackModulesResult
});
return {
sourceRspackModulesResult,
};
};
// Third party library (eg solid-js, lit, etc)
if (devServerConfig.framework && isThirdPartyDefinition(devServerConfig.framework)) {
Expand Down
2 changes: 1 addition & 1 deletion dist/helpers/sourceRelativeRspackModules.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Module from 'module';
import type { DevServerConfig } from '../devServer';
import type { RspackDevServer } from '@rspack/dev-server';
import type { DevServerConfig } from '../devServer';
export type ModuleClass = typeof Module & {
_load(id: string, parent: Module, isMain: boolean): any;
_resolveFilename(request: string, parent: Module, isMain: boolean, options?: {
Expand Down
2 changes: 1 addition & 1 deletion dist/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = loader;
const tslib_1 = require("tslib");
const debug_1 = tslib_1.__importDefault(require("debug"));
const path = tslib_1.__importStar(require("path"));
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = (0, debug_1.default)('cypress-rspack-dev-server:rspack');
/**
* @param {ComponentSpec} file spec to create import string from.
Expand Down
2 changes: 0 additions & 2 deletions dist/makeDefaultRspackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.makeCypressRspackConfig = makeCypressRspackConfig;
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const debug_1 = tslib_1.__importDefault(require("debug"));
const core_1 = require("@rspack/core");
const CypressCTRspackPlugin_1 = require("./CypressCTRspackPlugin");
const OUTPUT_PATH = __dirname;
const OsSeparatorRE = RegExp(`\\${path_1.default.sep}`, 'g');
const posixSeparator = '/';
const debug = (0, debug_1.default)('cypress-rspack-dev-server:makeDefaultRspackConfig');
function makeCypressRspackConfig(config) {
const { devServerConfig: { cypressConfig: { justInTimeCompile, projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, }, } = config;
const optimization = {
Expand Down
6 changes: 3 additions & 3 deletions dist/makeRspackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.CYPRESS_RSPACK_ENTRYPOINT = void 0;
exports.makeRspackConfig = makeRspackConfig;
const tslib_1 = require("tslib");
const debug_1 = require("debug");
const path = tslib_1.__importStar(require("path"));
const webpack_merge_1 = require("webpack-merge");
const debug_1 = require("debug");
const local_pkg_1 = require("local-pkg");
const makeDefaultRspackConfig_1 = require("./makeDefaultRspackConfig");
const webpack_merge_1 = require("webpack-merge");
const constants_1 = require("./constants");
const dynamic_import_1 = require("./dynamic-import");
const makeDefaultRspackConfig_1 = require("./makeDefaultRspackConfig");
const debug = (0, debug_1.debug)('cypress-rspack-dev-server:makeRspackConfig');
const removeList = [
// We provide a webpack-html-plugin config pinned to a specific version (4.x)
Expand Down
25 changes: 0 additions & 25 deletions eslint.config.mjs

This file was deleted.

29 changes: 11 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-rspack-dev-server",
"version": "1.1.2",
"version": "2.0.0-rc.1",
"description": "Launches Rspack Dev Server for Component Testing",
"main": "dist/index.js",
"scripts": {
Expand All @@ -13,8 +13,11 @@
"cypress:run-with-comment": "pnpm with:comment cypress run --component --project ./cypress --browser chrome --config-file config/cypress.config.ts",
"cypress:open": "cypress open --component --project ./cypress --browser chrome --config-file config/cypress.config.ts",
"with:comment": "cross-env DEBUG=cypress-rspack-dev-server:*",
"lint": "eslint .",
"test": "jest"
"lint": "oxlint",
"fmt": "oxfmt --write .",
"fmt:check": "oxfmt --check .",
"test": "vitest run",
"prepare": "husky"
},
"dependencies": {
"find-up": "6.3.0",
Expand All @@ -23,34 +26,24 @@
"webpack-merge": "^5.10.0"
},
"devDependencies": {
"@babel/core": "^7.28.6",
"@babel/preset-env": "^7.28.6",
"@babel/preset-typescript": "^7.28.5",
"@eslint/eslintrc": "^3.3.3",
"@eslint/js": "^9.39.2",
"@jest/globals": "^29.7.0",
"@rspack/core": "2.0.0-rc.1",
"@rspack/dev-server": "2.0.0-rc.2",
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.14",
"@types/lodash": "^4.17.23",
"@typescript-eslint/parser": "^8.54.0",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"cypress": "^15.9.0",
"debug": "^4.4.3",
"eslint": "^9.39.2",
"eslint-config-prettier": "^9.1.2",
"fs-extra": "9.1.0",
"jest": "^29.7.0",
"husky": "^9.1.7",
"lodash": "^4.17.23",
"oxfmt": "^0.44.0",
"oxlint": "^1.59.0",
"path": "^0.12.7",
"prettier": "^3.8.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.9.3",
"webpack": "5.76.0"
"vitest": "^4.1.4"
},
"files": [
"dist"
Expand All @@ -69,5 +62,5 @@
"dev-server",
"component test"
],
"packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
}
Loading
Loading