@cypress/vite-dev-server 6.0.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -56,8 +56,9 @@ We then merge the sourced config with the user's vite config, and layer on our o
56
56
  | <= v2 | <= v9 |
57
57
  | >= v3 <= v5 | >= v10 <= v13 |
58
58
  | >= v6 | >= v14 |
59
+ | >= v7 (esm only) | >= v15 |
59
60
 
60
- #### `devServerPublicPathRoute` for Vite v5
61
+ #### `devServerPublicPathRoute` for Vite v5+
61
62
 
62
63
  If using Vite version 5, setting `devServerPublicPathRoute` may be needed if directly referencing public path url assets in components under test. This is due to Cypress using its own public path, `/__cypress/src`, when running component tests. This can be configured within the `component` namespace below if you wish you set your public path to be the same as your app:
63
64
 
package/dist/constants.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configFiles = void 0;
4
- exports.configFiles = [
1
+ export const configFiles = [
5
2
  'vite.config.ts',
6
3
  'vite.config.js',
7
4
  'vite.config.mjs',
@@ -1,6 +1,6 @@
1
- /// <reference types="cypress" />
2
- /// <reference types="node" />
3
- import type { UserConfig } from 'vite-6';
1
+ /// <reference types="cypress" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { UserConfig } from 'vite-7';
4
4
  declare const ALL_FRAMEWORKS: readonly ["react", "vue"];
5
5
  type ConfigHandler = UserConfig | (() => UserConfig | Promise<UserConfig>);
6
6
  export type ViteDevServerConfig = {
@@ -14,6 +14,6 @@ export type ViteDevServerConfig = {
14
14
  };
15
15
  export declare function devServer(config: ViteDevServerConfig): Promise<Cypress.ResolvedDevServerConfig>;
16
16
  export declare namespace devServer {
17
- var create: (devServerConfig: ViteDevServerConfig, vite: typeof import("vite-6")) => Promise<import("vite-6").ViteDevServer>;
17
+ var create: (devServerConfig: ViteDevServerConfig, vite: typeof import("vite-7")) => Promise<import("vite-7").ViteDevServer>;
18
18
  }
19
19
  export {};
package/dist/devServer.js CHANGED
@@ -1,19 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.devServer = void 0;
4
- const tslib_1 = require("tslib");
5
- const debug_1 = tslib_1.__importDefault(require("debug"));
6
- const major_1 = tslib_1.__importDefault(require("semver/functions/major"));
7
- const getVite_1 = require("./getVite");
8
- const resolveConfig_1 = require("./resolveConfig");
9
- const debug = (0, debug_1.default)('cypress:vite-dev-server:devServer');
1
+ import debugFn from 'debug';
2
+ import semverMajor from 'semver/functions/major.js';
3
+ import { getVite } from './getVite.js';
4
+ import { createViteDevServerConfig } from './resolveConfig.js';
5
+ const debug = debugFn('cypress:vite-dev-server:devServer');
10
6
  const ALL_FRAMEWORKS = ['react', 'vue'];
11
- async function devServer(config) {
7
+ export async function devServer(config) {
12
8
  // This has to be the first thing we do as we need to source vite from their project's dependencies
13
- const vite = (0, getVite_1.getVite)(config);
9
+ const vite = await getVite(config);
14
10
  let majorVersion = undefined;
15
11
  if (vite.version) {
16
- majorVersion = (0, major_1.default)(vite.version);
12
+ majorVersion = semverMajor(vite.version);
17
13
  debug(`Found vite version v${majorVersion}`);
18
14
  }
19
15
  else {
@@ -35,15 +31,14 @@ async function devServer(config) {
35
31
  debug('closing dev server');
36
32
  return server.close().then(() => {
37
33
  debug('closed dev server');
38
- cb === null || cb === void 0 ? void 0 : cb();
34
+ cb?.();
39
35
  }).catch(cb);
40
36
  },
41
37
  };
42
38
  }
43
- exports.devServer = devServer;
44
39
  devServer.create = async function createDevServer(devServerConfig, vite) {
45
40
  try {
46
- const config = await (0, resolveConfig_1.createViteDevServerConfig)(devServerConfig, vite);
41
+ const config = await createViteDevServerConfig(devServerConfig, vite);
47
42
  return await vite.createServer(config);
48
43
  }
49
44
  catch (err) {
package/dist/getVite.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { ViteDevServerConfig } from './devServer';
2
- export type Vite = typeof import('vite-6');
3
- export declare function getVite(config: ViteDevServerConfig): Vite;
1
+ import type { ViteDevServerConfig } from './devServer.js';
2
+ export type Vite = typeof import('vite-7');
3
+ export declare function getVite(config: ViteDevServerConfig): Promise<Vite>;
package/dist/getVite.js CHANGED
@@ -1,20 +1,75 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVite = void 0;
4
- const tslib_1 = require("tslib");
5
- const debug_1 = tslib_1.__importDefault(require("debug"));
6
- const debug = (0, debug_1.default)('cypress:vite-dev-server:getVite');
1
+ import debugFn from 'debug';
2
+ import { createRequire } from 'module';
3
+ import path from 'path';
4
+ import os from 'os';
5
+ import majorVersion from 'semver/functions/major.js';
6
+ const debug = debugFn('cypress:vite-dev-server:getVite');
7
+ class CJSNotSupportedError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'CJSNotSupportedError';
11
+ }
12
+ }
7
13
  // "vite-dev-server" is bundled in the binary, so we need to require.resolve "vite"
8
14
  // from root of the active project since we don't bundle vite internally but rather
9
15
  // use the version the user has installed
10
- function getVite(config) {
16
+ export async function getVite(config) {
17
+ const filePrefix = os.platform() === 'win32' ? 'file://' : '';
11
18
  try {
12
- const viteImportPath = require.resolve('vite', { paths: [config.cypressConfig.projectRoot] });
13
- debug('resolved viteImportPath as %s', viteImportPath);
14
- return require(viteImportPath);
19
+ const require = createRequire(import.meta.url);
20
+ const vitePackageJsonPath = require.resolve('vite/package.json', { paths: [config.cypressConfig.projectRoot] });
21
+ const vitePackageJson = (await import(`${filePrefix}${vitePackageJsonPath}`, {
22
+ with: {
23
+ type: 'json',
24
+ },
25
+ })).default;
26
+ const viteExports = vitePackageJson.exports['.'];
27
+ let esmPath = null;
28
+ let cjsPath = null;
29
+ // In Node 20, require.resolve in the ESM context returns the CJS path as if we were in a CJS context.
30
+ // In Node 22, this is not the case and the ESM context is returned correctly.
31
+ // In order to work around this, we need to check where the ESM path is so we can import the correct path.
32
+ // In Vite 7, the CJS build was removed so there is only a single string entry in the export.
33
+ // Otherwise, both builds exists in Vite 6 and under and we only want to get the ESM path.
34
+ const majorVersionNumber = majorVersion(vitePackageJson.version);
35
+ if (majorVersionNumber >= 7) {
36
+ esmPath = viteExports;
37
+ }
38
+ else if (majorVersionNumber === 5) {
39
+ esmPath = viteExports.import.default;
40
+ cjsPath = viteExports.require.default;
41
+ }
42
+ else {
43
+ esmPath = viteExports.import;
44
+ cjsPath = viteExports.require;
45
+ }
46
+ debug('vite ESM build path: %s', esmPath);
47
+ debug('vite CJS build path: %s', cjsPath);
48
+ try {
49
+ // try to import the ESM build of Vite
50
+ const esmViteImportPath = path.resolve(vitePackageJsonPath, '../', esmPath);
51
+ debug('resolved esmViteImportPath as %s', esmViteImportPath);
52
+ const viteImport = await import(`${filePrefix}${esmViteImportPath}`);
53
+ return viteImport;
54
+ }
55
+ catch (err) {
56
+ if (majorVersionNumber >= 7) {
57
+ throw new CJSNotSupportedError(`CJS builds of vite ${majorVersionNumber} are not supported`);
58
+ }
59
+ // if the ESM build import fails, try to import the CJS build
60
+ debug('importing vite as ESM failed:', err);
61
+ debug('importing vite as CJS');
62
+ // Vite 4-6 both include the CJS distribution of Vite
63
+ const cjsViteImportPath = path.resolve(vitePackageJsonPath, '../', cjsPath);
64
+ debug('resolved cjsViteImportPath as %s', cjsViteImportPath);
65
+ const viteImport = await import(`${filePrefix}${cjsViteImportPath}`);
66
+ return viteImport.default;
67
+ }
15
68
  }
16
69
  catch (err) {
70
+ if (err instanceof CJSNotSupportedError) {
71
+ throw err;
72
+ }
17
73
  throw new Error(`Could not find "vite" in your project's dependencies. Please install "vite" to fix this error.\n\n${err}`);
18
74
  }
19
75
  }
20
- exports.getVite = getVite;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- import { devServer } from './devServer';
1
+ import { devServer } from './devServer.js';
2
2
  export { devServer };
3
- export default devServer;
3
+ declare const _default: {
4
+ devServer: typeof devServer;
5
+ };
6
+ export default _default;
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.devServer = void 0;
4
- const devServer_1 = require("./devServer");
5
- Object.defineProperty(exports, "devServer", { enumerable: true, get: function () { return devServer_1.devServer; } });
6
- exports.default = devServer_1.devServer;
1
+ import { devServer } from './devServer.js';
2
+ export { devServer };
3
+ export default { devServer };
@@ -1,4 +1,4 @@
1
- import type { PluginOption } from 'vite-6';
2
- import type { Vite } from '../getVite';
3
- import type { ViteDevServerConfig } from '../devServer';
1
+ import type { PluginOption } from 'vite-7';
2
+ import type { Vite } from '../getVite.js';
3
+ import type { ViteDevServerConfig } from '../devServer.js';
4
4
  export declare const Cypress: (options: ViteDevServerConfig, vite: Vite) => PluginOption;
@@ -1,30 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Cypress = void 0;
4
- const tslib_1 = require("tslib");
5
- const debug_1 = tslib_1.__importDefault(require("debug"));
6
- const node_html_parser_1 = require("node-html-parser");
7
- const fs_1 = tslib_1.__importDefault(require("fs"));
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:cypress');
10
- const INIT_FILEPATH = path_1.default.resolve(__dirname, '../../client/initCypressTests.js');
1
+ import debugFn from 'debug';
2
+ import { parse, HTMLElement } from 'node-html-parser';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath } from 'url';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ const debug = debugFn('cypress:vite-dev-server:plugins:cypress');
9
+ const INIT_FILEPATH = path.resolve(__dirname, '../../client/initCypressTests.js');
11
10
  const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50;
12
11
  function getSpecsPathsSet(specs) {
13
12
  return new Set(specs.map((spec) => spec.absolute));
14
13
  }
15
- const Cypress = (options, vite) => {
14
+ export const Cypress = (options, vite) => {
16
15
  let base = '/';
17
16
  const projectRoot = options.cypressConfig.projectRoot;
18
- const supportFilePath = options.cypressConfig.supportFile ? path_1.default.resolve(projectRoot, options.cypressConfig.supportFile) : false;
17
+ const supportFilePath = options.cypressConfig.supportFile ? path.resolve(projectRoot, options.cypressConfig.supportFile) : false;
19
18
  const devServerEvents = options.devServerEvents;
20
19
  const specs = options.specs;
21
20
  const indexHtmlFile = options.cypressConfig.indexHtmlFile;
22
21
  let specsPathsSet = getSpecsPathsSet(specs);
23
22
  // TODO: use async fs methods here
24
23
  // eslint-disable-next-line no-restricted-syntax
25
- let loader = fs_1.default.readFileSync(INIT_FILEPATH, 'utf8');
24
+ let loader = fs.readFileSync(INIT_FILEPATH, 'utf8');
26
25
  devServerEvents.on('dev-server:specs:changed', ({ specs, options }) => {
27
- if (options === null || options === void 0 ? void 0 : options.neededForJustInTimeCompile) {
26
+ if (options?.neededForJustInTimeCompile) {
28
27
  // if an option is needed for just in time compile, no-op as this isn't supported in vite
29
28
  return;
30
29
  }
@@ -44,13 +43,13 @@ const Cypress = (options, vite) => {
44
43
  // receive and inject it.
45
44
  // For now we just grab any `<script>` tags and inject them to <head>.
46
45
  // We will add more handling as we learn the use cases.
47
- const root = (0, node_html_parser_1.parse)(html);
46
+ const root = parse(html);
48
47
  const scriptTagsToInject = root.childNodes.filter((node) => {
49
- return node instanceof node_html_parser_1.HTMLElement && node.rawTagName === 'script';
48
+ return node instanceof HTMLElement && node.rawTagName === 'script';
50
49
  });
51
- const indexHtmlPath = path_1.default.resolve(projectRoot, indexHtmlFile);
50
+ const indexHtmlPath = path.resolve(projectRoot, indexHtmlFile);
52
51
  debug('resolved the indexHtmlPath as', indexHtmlPath, 'from', indexHtmlFile);
53
- let indexHtmlContent = await fs_1.default.promises.readFile(indexHtmlPath, { encoding: 'utf8' });
52
+ let indexHtmlContent = await fs.promises.readFile(indexHtmlPath, { encoding: 'utf8' });
54
53
  // Inject the script tags
55
54
  indexHtmlContent = indexHtmlContent.replace('<head>', `<head>
56
55
  ${scriptTagsToInject.join('')}
@@ -74,7 +73,7 @@ const Cypress = (options, vite) => {
74
73
  handleHotUpdate: ({ server, file }) => {
75
74
  debug('handleHotUpdate - file', file);
76
75
  // If the user provided IndexHtml is changed, do a full-reload
77
- if (vite.normalizePath(file) === path_1.default.resolve(projectRoot, indexHtmlFile)) {
76
+ if (vite.normalizePath(file) === path.resolve(projectRoot, indexHtmlFile)) {
78
77
  server.ws.send({
79
78
  type: 'full-reload',
80
79
  });
@@ -85,7 +84,7 @@ const Cypress = (options, vite) => {
85
84
  let iterationNumber = 0;
86
85
  const exploredFiles = new Set();
87
86
  // until we reached a point where the current module is imported by no other
88
- while (moduleImporters === null || moduleImporters === void 0 ? void 0 : moduleImporters.size) {
87
+ while (moduleImporters?.size) {
89
88
  if (iterationNumber > HMR_DEPENDENCY_LOOKUP_MAX_ITERATION) {
90
89
  debug(`max hmr iteration reached: ${HMR_DEPENDENCY_LOOKUP_MAX_ITERATION}; Rerun will not happen on this file change.`);
91
90
  return;
@@ -116,7 +115,6 @@ const Cypress = (options, vite) => {
116
115
  },
117
116
  };
118
117
  };
119
- exports.Cypress = Cypress;
120
118
  /**
121
119
  * Gets all the modules that import the set of modules passed in parameters
122
120
  * @param modules the set of module whose dependents to return
@@ -1,2 +1,2 @@
1
- export * from './cypress';
2
- export * from './sourcemap';
1
+ export * from './cypress.js';
2
+ export * from './sourcemap.js';
@@ -1,5 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./cypress"), exports);
5
- tslib_1.__exportStar(require("./sourcemap"), exports);
1
+ export * from './cypress.js';
2
+ export * from './sourcemap.js';
@@ -1,4 +1,4 @@
1
- import type { PluginOption } from 'vite-6';
2
- import type { Vite } from '../getVite';
3
- import type { ViteDevServerConfig } from '../devServer';
1
+ import type { PluginOption } from 'vite-7';
2
+ import type { Vite } from '../getVite.js';
3
+ import type { ViteDevServerConfig } from '../devServer.js';
4
4
  export declare const CypressSourcemap: (options: ViteDevServerConfig, vite: Vite) => PluginOption;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CypressSourcemap = void 0;
4
- const tslib_1 = require("tslib");
5
- const debug_1 = tslib_1.__importDefault(require("debug"));
6
- const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:sourcemap');
7
- const CypressSourcemap = (options, vite) => {
1
+ import debugFn from 'debug';
2
+ const debug = debugFn('cypress:vite-dev-server:plugins:sourcemap');
3
+ export const CypressSourcemap = (options, vite) => {
8
4
  return {
9
5
  name: 'cypress:sourcemap',
10
6
  enforce: 'post',
@@ -47,4 +43,3 @@ const CypressSourcemap = (options, vite) => {
47
43
  },
48
44
  };
49
45
  };
50
- exports.CypressSourcemap = CypressSourcemap;
@@ -1,4 +1,4 @@
1
- import type { InlineConfig } from 'vite-6';
2
- import type { ViteDevServerConfig } from './devServer';
3
- import type { Vite } from './getVite';
1
+ import type { InlineConfig } from 'vite-7';
2
+ import type { ViteDevServerConfig } from './devServer.js';
3
+ import type { Vite } from './getVite.js';
4
4
  export declare const createViteDevServerConfig: (config: ViteDevServerConfig, vite: Vite) => Promise<InlineConfig>;
@@ -1,20 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createViteDevServerConfig = void 0;
4
- const tslib_1 = require("tslib");
5
1
  /**
6
2
  * The logic inside of this file is heavily reused from
7
3
  * Vitest's own config resolution logic.
8
4
  * You can find it here https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/create.ts
9
5
  */
10
- const debug_1 = tslib_1.__importDefault(require("debug"));
11
- const path_1 = tslib_1.__importDefault(require("path"));
12
- const gte_1 = tslib_1.__importDefault(require("semver/functions/gte"));
13
- const constants_1 = require("./constants");
14
- const index_1 = require("./plugins/index");
15
- const dynamic_import_1 = require("./dynamic-import");
16
- const debug = (0, debug_1.default)('cypress:vite-dev-server:resolve-config');
17
- const createViteDevServerConfig = async (config, vite) => {
6
+ import debugFn from 'debug';
7
+ import path from 'path';
8
+ import { createRequire } from 'module';
9
+ import semverGte from 'semver/functions/gte.js';
10
+ import { configFiles } from './constants.js';
11
+ import { Cypress, CypressSourcemap } from './plugins/index.js';
12
+ const debug = debugFn('cypress:vite-dev-server:resolve-config');
13
+ export const createViteDevServerConfig = async (config, vite) => {
18
14
  const { viteConfig: inlineViteConfig, cypressConfig: { projectRoot } } = config;
19
15
  let resolvedOverrides = {};
20
16
  if (inlineViteConfig) {
@@ -26,14 +22,14 @@ const createViteDevServerConfig = async (config, vite) => {
26
22
  resolvedOverrides = inlineViteConfig;
27
23
  }
28
24
  // Set "configFile: false" to disable auto resolution of <project-root>/vite.config.js
29
- resolvedOverrides = Object.assign({ configFile: false }, resolvedOverrides);
25
+ resolvedOverrides = { configFile: false, ...resolvedOverrides };
30
26
  }
31
27
  else {
32
- const { findUp } = await (0, dynamic_import_1.dynamicImport)('find-up');
33
- const configFile = await findUp(constants_1.configFiles, { cwd: projectRoot });
28
+ const { findUp } = await import('find-up');
29
+ const configFile = await findUp(configFiles, { cwd: projectRoot });
34
30
  if (!configFile) {
35
31
  if (config.onConfigNotFound) {
36
- config.onConfigNotFound('vite', projectRoot, constants_1.configFiles);
32
+ config.onConfigNotFound('vite', projectRoot, configFiles);
37
33
  // The config process will be killed from the parent, but we want to early exit so we don't get
38
34
  // any additional errors related to not having a config
39
35
  process.exit(0);
@@ -49,14 +45,13 @@ const createViteDevServerConfig = async (config, vite) => {
49
45
  debug('The resolved server config is', JSON.stringify(finalConfig, null, 2));
50
46
  return finalConfig;
51
47
  };
52
- exports.createViteDevServerConfig = createViteDevServerConfig;
53
48
  function makeCypressViteConfig(config, vite) {
54
- var _a, _b, _c;
55
49
  const { cypressConfig: { port, projectRoot, devServerPublicPathRoute, supportFile, cypressBinaryRoot, isTextTerminal, }, specs, } = config;
56
- const vitePort = port !== null && port !== void 0 ? port : undefined;
50
+ const vitePort = port ?? undefined;
51
+ const require = createRequire(import.meta.url);
57
52
  // Vite caches its output in the .vite directory in the node_modules where vite lives.
58
53
  // So we want to find that node_modules path and ensure it's added to the "allow" list
59
- const vitePathNodeModules = path_1.default.dirname(path_1.default.dirname(require.resolve(`vite/package.json`, {
54
+ const vitePathNodeModules = path.dirname(path.dirname(require.resolve(`vite/package.json`, {
60
55
  paths: [projectRoot],
61
56
  })));
62
57
  const viteConfig = {
@@ -82,29 +77,35 @@ function makeCypressViteConfig(config, vite) {
82
77
  ],
83
78
  },
84
79
  entries: [
85
- ...specs.map((s) => path_1.default.relative(projectRoot, s.relative)),
86
- ...(supportFile ? [path_1.default.resolve(projectRoot, supportFile)] : []),
80
+ ...specs.map((s) => path.relative(projectRoot, s.relative)),
81
+ ...(supportFile ? [path.resolve(projectRoot, supportFile)] : []),
87
82
  ].filter((v) => v != null),
88
83
  },
89
- server: Object.assign({ fs: {
84
+ server: {
85
+ fs: {
90
86
  allow: [
91
87
  projectRoot,
92
88
  vitePathNodeModules,
93
89
  cypressBinaryRoot,
94
90
  // Allow in monorepo: https://vitejs.dev/config/server-options.html#server-fs-allow
95
91
  // Supported from Vite v3 - add null check for v2 users.
96
- (_a = vite.searchForWorkspaceRoot) === null || _a === void 0 ? void 0 : _a.call(vite, process.cwd()),
92
+ vite.searchForWorkspaceRoot?.(process.cwd()),
97
93
  ],
98
- }, port: vitePort, host: '127.0.0.1' }, (isTextTerminal
99
- ? { watch: { ignored: '**/*' }, hmr: false }
100
- : {})),
94
+ },
95
+ port: vitePort,
96
+ host: '127.0.0.1',
97
+ // Disable file watching and HMR when executing tests in `run` mode
98
+ ...(isTextTerminal
99
+ ? { watch: { ignored: '**/*' }, hmr: false }
100
+ : {}),
101
+ },
101
102
  plugins: [
102
- (0, index_1.Cypress)(config, vite),
103
- (0, index_1.CypressSourcemap)(config, vite),
103
+ Cypress(config, vite),
104
+ CypressSourcemap(config, vite),
104
105
  ],
105
106
  };
106
- if (vite.version && (0, gte_1.default)(vite.version, '4.2.0')) {
107
- (_c = (_b = viteConfig.optimizeDeps) === null || _b === void 0 ? void 0 : _b.esbuildOptions) === null || _c === void 0 ? true : delete _c.incremental;
107
+ if (vite.version && semverGte(vite.version, '4.2.0')) {
108
+ delete viteConfig.optimizeDeps?.esbuildOptions?.incremental;
108
109
  }
109
110
  return viteConfig;
110
111
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@cypress/vite-dev-server",
3
- "version": "6.0.2",
3
+ "version": "7.0.0",
4
4
  "description": "Launches Vite Dev Server for Component Testing",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "build": "tsc || echo 'built, with type errors'",
8
8
  "check-ts": "tsc --noEmit",
@@ -10,30 +10,26 @@
10
10
  "cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome",
11
11
  "cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York",
12
12
  "lint": "eslint --ext .js,.ts,.json, .",
13
- "test": "yarn test-unit",
14
- "test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js",
13
+ "test": "vitest run --no-file-parallelism",
15
14
  "watch": "tsc -w"
16
15
  },
17
16
  "dependencies": {
18
17
  "debug": "^4.3.4",
19
18
  "find-up": "6.3.0",
20
19
  "node-html-parser": "5.3.3",
21
- "semver": "^7.5.3"
20
+ "semver": "^7.7.1"
22
21
  },
23
22
  "devDependencies": {
24
- "chai": "^4.3.6",
25
- "decache": "^4.6.2",
23
+ "cross-env": "7.0.3",
26
24
  "dedent": "^0.7.0",
27
- "mocha": "^9.2.2",
28
- "sinon": "^13.0.1",
29
- "ts-node": "^10.9.2",
30
- "vite-4": "npm:vite@^4.5.3",
31
- "vite-5": "npm:vite@^5.2.8",
32
- "vite-6": "npm:vite@^6.0.0",
33
- "vite-plugin-inspect": "0.8.4"
25
+ "vite-5": "npm:vite@^5.4.18",
26
+ "vite-6": "npm:vite@^6.2.5",
27
+ "vite-7": "npm:vite@^7.0.0",
28
+ "vite-plugin-inspect": "0.8.4",
29
+ "vitest": "2.1.4"
34
30
  },
35
31
  "peerDependencies": {
36
- "cypress": ">=14.0.0"
32
+ "cypress": ">=15.0.0"
37
33
  },
38
34
  "files": [
39
35
  "dist",
@@ -48,6 +44,7 @@
48
44
  },
49
45
  "homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/vite-dev-server#readme",
50
46
  "bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
47
+ "type": "module",
51
48
  "module": "dist/index.js",
52
49
  "publishConfig": {
53
50
  "access": "public"
@@ -1 +0,0 @@
1
- export declare const dynamicImport: <T>(module: string) => Promise<T>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dynamicImport = void 0;
4
- // tsc will compile `import(...)` calls to require unless a different tsconfig.module value
5
- // is used (e.g. module=node16). To change this, we would also have to change the ts-node behavior when requiring the
6
- // Cypress config file. This hack for keeping dynamic imports from being converted works across all
7
- // of our supported node versions
8
- const _dynamicImport = new Function('specifier', 'return import(specifier)');
9
- const dynamicImport = (module) => _dynamicImport(module);
10
- exports.dynamicImport = dynamicImport;
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist')