@cypress/vite-dev-server 5.0.3 → 5.0.5

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.
@@ -34,7 +34,9 @@ if (supportFile) {
34
34
 
35
35
  // Using relative path wouldn't allow to load tests outside Vite project root folder
36
36
  // So we use the "@fs" bit to load the test file using its absolute path
37
- const testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs${CypressInstance.spec.absolute}`
37
+ // Normalize path to not include a leading slash (different on Win32 vs Unix)
38
+ const normalizedAbsolutePath = CypressInstance.spec.absolute.replace(/^\//, '')
39
+ const testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${normalizedAbsolutePath}`
38
40
 
39
41
  /* Spec file import logic */
40
42
  // We need a slash before /src/my-spec.js, this does not happen by default.
@@ -9,6 +9,7 @@ const tslib_1 = require("tslib");
9
9
  */
10
10
  const debug_1 = tslib_1.__importDefault(require("debug"));
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
+ const gte_1 = tslib_1.__importDefault(require("semver/functions/gte"));
12
13
  const constants_1 = require("./constants");
13
14
  const index_1 = require("./plugins/index");
14
15
  const dynamic_import_1 = require("./dynamic-import");
@@ -50,17 +51,20 @@ const createViteDevServerConfig = async (config, vite) => {
50
51
  };
51
52
  exports.createViteDevServerConfig = createViteDevServerConfig;
52
53
  function makeCypressViteConfig(config, vite) {
54
+ var _a, _b, _c;
53
55
  const { cypressConfig: { projectRoot, devServerPublicPathRoute, supportFile, cypressBinaryRoot, isTextTerminal, }, specs, } = config;
54
56
  // Vite caches its output in the .vite directory in the node_modules where vite lives.
55
57
  // So we want to find that node_modules path and ensure it's added to the "allow" list
56
58
  const vitePathNodeModules = path_1.default.dirname(path_1.default.dirname(require.resolve(`vite/package.json`, {
57
59
  paths: [projectRoot],
58
60
  })));
59
- return {
61
+ const viteConfig = {
60
62
  root: projectRoot,
61
63
  base: `${devServerPublicPathRoute}/`,
62
64
  optimizeDeps: {
63
65
  esbuildOptions: {
66
+ // We are using Vite 4.2.0+, so `incremental` doesn't exist in the types
67
+ // @ts-expect-error
64
68
  incremental: true,
65
69
  plugins: [
66
70
  {
@@ -88,6 +92,9 @@ function makeCypressViteConfig(config, vite) {
88
92
  projectRoot,
89
93
  vitePathNodeModules,
90
94
  cypressBinaryRoot,
95
+ // Allow in monorepo: https://vitejs.dev/config/server-options.html#server-fs-allow
96
+ // Supported from Vite v3 - add null check for v2 users.
97
+ (_a = vite.searchForWorkspaceRoot) === null || _a === void 0 ? void 0 : _a.call(vite, process.cwd()),
91
98
  ],
92
99
  }, host: '127.0.0.1' }, (isTextTerminal
93
100
  ? { watch: { ignored: '**/*' }, hmr: false }
@@ -97,4 +104,10 @@ function makeCypressViteConfig(config, vite) {
97
104
  (0, index_1.CypressSourcemap)(config, vite),
98
105
  ],
99
106
  };
107
+ if (vite.version && (0, gte_1.default)(vite.version, '4.2.0')) {
108
+ // We are using Vite 4.2.0+, so `incremental` doesn't exist in the types
109
+ // @ts-expect-error
110
+ (_c = (_b = viteConfig.optimizeDeps) === null || _b === void 0 ? void 0 : _b.esbuildOptions) === null || _c === void 0 ? true : delete _c.incremental;
111
+ }
112
+ return viteConfig;
100
113
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/vite-dev-server",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "Launches Vite Dev Server for Component Testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,7 +18,8 @@
18
18
  "dependencies": {
19
19
  "debug": "^4.3.4",
20
20
  "find-up": "6.3.0",
21
- "node-html-parser": "5.3.3"
21
+ "node-html-parser": "5.3.3",
22
+ "semver": "^7.3.2"
22
23
  },
23
24
  "devDependencies": {
24
25
  "chai": "^4.3.6",
@@ -26,7 +27,7 @@
26
27
  "mocha": "^9.2.2",
27
28
  "sinon": "^13.0.1",
28
29
  "ts-node": "^10.9.1",
29
- "vite": "4.0.1",
30
+ "vite": "4.2.0",
30
31
  "vite-plugin-inspect": "0.4.3"
31
32
  },
32
33
  "files": [