Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade cypress to 14.0.0 #35

Merged
merged 2 commits into from
Jan 17, 2025
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
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export default defineConfig({
})
```

In the `Cypress-rspack-dev-server Version` column, it lists the corresponding versions that are compatible with the `Rspack` versions.

For example:

> For Rspack version 1.0.0-beta.4 or later, use Cypress-rspack-dev-server version 0.0.6.
## Dev server parameters

| Option | NOTES |
Expand Down
36 changes: 36 additions & 0 deletions description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Cypress Rspack Dev Server

## Project Overview

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

### Key Components

1. **devServer.ts**
- Main entry point
- Handles server creation and configuration
- Supports multiple frameworks
- Provides flexible configuration system

2. **makeRspackConfig.ts**
- Manages Rspack configuration generation
- Handles custom plugin management
- Merges configurations with user settings
- Addresses Cypress-specific requirements

3. **CypressCTRspackPlugin.ts**
- Custom Rspack plugin for Cypress Component Testing

4. **createRspackDevServer.ts**
- Manages dev server instance creation and setup

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

2 changes: 1 addition & 1 deletion dist/CypressCTRspackPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface CypressCTRspackPluginOptions {
devServerEvents: EventEmitter;
indexHtmlFile: string;
}
export type CypressCTContextOptions = Omit<CypressCTRspackPluginOptions, 'devServerEvents' | 'rspack'>;
export type CypressCTContextOptions = Omit<CypressCTRspackPluginOptions, 'devServerEvents'>;
export interface CypressCTRspackContext {
_cypress: CypressCTContextOptions;
}
Expand Down
6 changes: 3 additions & 3 deletions dist/CypressCTRspackPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CypressCTRspackPlugin {
indexHtmlFile: this.indexHtmlFile,
};
};
this.beforeCompile = async (compilationParams, callback) => {
this.beforeCompile = async (_compilationParams, callback) => {
if (!this.compilation) {
callback();
return;
Expand Down Expand Up @@ -62,10 +62,10 @@ class CypressCTRspackPlugin {
*/
this.onSpecsChange = async (specs) => {
var _a;
if (!this.compilation || (0, isEqual_1.default)(specs, this.files)) {
if (!this.compilation || (0, isEqual_1.default)(specs.specs, this.files)) {
return;
}
this.files = specs;
this.files = specs.specs;
const inputFileSystem = this.compilation.inputFileSystem;
// TODO: don't use a sync fs method here
const utimesSync = (_a = inputFileSystem.fileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
Expand Down
6 changes: 0 additions & 6 deletions dist/devServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ async function getPreset(devServerConfig) {
}
switch (devServerConfig.framework) {
// todo - add support for other frameworks
case 'create-react-app':
// return createReactAppHandler(devServerConfig);
case 'nuxt':
// return await nuxtHandler(devServerConfig)
case 'vue-cli':
// return await vueCliHandler(devServerConfig)
case 'next':
// return await nextHandler(devServerConfig)
case 'angular':
Expand Down
3 changes: 0 additions & 3 deletions dist/helpers/sourceRelativeRspackModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const debug = (0, debug_1.default)('cypress-rspack-dev-server:sourceRelativeRspa
const originalModuleLoad = module_1.default._load;
const originalModuleResolveFilename = module_1.default._resolveFilename;
const frameworkRspackMapper = {
'create-react-app': 'react-scripts',
'vue-cli': '@vue/cli-service',
nuxt: '@nuxt/rspack',
react: 'react',
vue: undefined,
next: 'next',
Expand Down
7 changes: 4 additions & 3 deletions dist/makeDefaultRspackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const OUTPUT_PATH = path_1.default.join(__dirname, 'dist');
const OsSeparatorRE = RegExp(`\\${path_1.default.sep}`, 'g');
const posixSeparator = '/';
function makeCypressRspackConfig(config) {
const { devServerConfig: { cypressConfig: { experimentalJustInTimeCompile, projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, }, } = config;
const { devServerConfig: { cypressConfig: { justInTimeCompile, projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, }, } = config;
const optimization = {
// To prevent files from being tree shaken by rspack, we set optimization.sideEffects: false ensuring that
// rspack does not recognize the sideEffects flag in the package.json and thus files are not unintentionally
Expand Down Expand Up @@ -48,8 +48,9 @@ function makeCypressRspackConfig(config) {
devtool: 'inline-source-map',
};
if (isRunMode) {
// if experimentalJustInTimeCompile is configured, we need to watch for file changes as the spec entries are going to be updated per test
const ignored = experimentalJustInTimeCompile ? /node_modules/ : '**/*';
// if justInTimeCompile is configured, we need to watch for file changes
// as the spec entries are going to be updated per test
const ignored = justInTimeCompile ? /node_modules/ : '**/*';
// Disable file watching when executing tests in `run` mode
finalConfig.watchOptions = { ignored };
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.0",
"@typescript-eslint/parser": "^8.18.2",
"@typescript-eslint/parser": "^8.20.0",
"babel-jest": "^29.7.0",
"cross-env": "^7.0.3",
"cypress": "^13.17.0",
"cypress": "^14.0.0",
"debug": "^4.3.4",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
78 changes: 39 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions src/CypressCTRspackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ type UtimesSync = (
mtime: string | number | Date,
) => void

type CypressSpecsWithOptions = {
specs: Cypress.Cypress['spec'][]
options: { neededForJustInTimeCompile?: boolean }
}

export interface CypressCTRspackPluginOptions {
files: Cypress.Cypress['spec'][]
projectRoot: string
Expand All @@ -21,10 +26,7 @@ export interface CypressCTRspackPluginOptions {
indexHtmlFile: string
}

export type CypressCTContextOptions = Omit<
CypressCTRspackPluginOptions,
'devServerEvents' | 'rspack'
>
export type CypressCTContextOptions = Omit<CypressCTRspackPluginOptions, 'devServerEvents'>

export interface CypressCTRspackContext {
_cypress: CypressCTContextOptions
Expand Down Expand Up @@ -76,7 +78,7 @@ export class CypressCTRspackPlugin {
}
}

private beforeCompile = async (compilationParams: object, callback: Function) => {
private beforeCompile = async (_compilationParams: object, callback: Function) => {
if (!this.compilation) {
callback()

Expand Down Expand Up @@ -115,12 +117,12 @@ export class CypressCTRspackPlugin {
*
* See https://github.com/cypress-io/cypress/issues/24398
*/
private onSpecsChange = async (specs: Cypress.Cypress['spec'][]) => {
if (!this.compilation || isEqual(specs, this.files)) {
private onSpecsChange = async (specs: CypressSpecsWithOptions) => {
if (!this.compilation || isEqual(specs.specs, this.files)) {
return
}

this.files = specs
this.files = specs.specs
const inputFileSystem = this.compilation.inputFileSystem
// TODO: don't use a sync fs method here
const utimesSync: UtimesSync = inputFileSystem.fileSystem.utimesSync ?? fs.utimesSync
Expand Down
8 changes: 0 additions & 8 deletions src/devServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@ async function getPreset(

switch (devServerConfig.framework) {
// todo - add support for other frameworks
case 'create-react-app':
// return createReactAppHandler(devServerConfig);
case 'nuxt':
// return await nuxtHandler(devServerConfig)

case 'vue-cli':
// return await vueCliHandler(devServerConfig)

case 'next':
// return await nextHandler(devServerConfig)

Expand Down
3 changes: 0 additions & 3 deletions src/helpers/sourceRelativeRspackModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ const originalModuleResolveFilename = (Module as ModuleClass)._resolveFilename
type FrameworkRspackMapper = { [Property in Frameworks]: string | undefined }

const frameworkRspackMapper: FrameworkRspackMapper = {
'create-react-app': 'react-scripts',
'vue-cli': '@vue/cli-service',
nuxt: '@nuxt/rspack',
react: 'react',
vue: undefined,
next: 'next',
Expand Down
Loading
Loading