@cypress/vite-dev-server 3.1.1 → 3.2.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 +1 -1
- package/client/initCypressTests.js +12 -2
- package/dist/devServer.d.ts +4 -1
- package/dist/devServer.js +1 -1
- package/dist/getVite.js +1 -1
- package/dist/plugins/cypress.js +24 -3
- package/dist/plugins/index.js +2 -2
- package/dist/plugins/inspect.js +1 -1
- package/dist/resolveConfig.js +10 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ We then merge the sourced config with the user's vite config, and layer on our o
|
|
|
58
58
|
|
|
59
59
|
## License
|
|
60
60
|
|
|
61
|
-
[](https://github.com/cypress-io/cypress/blob/
|
|
61
|
+
[](https://github.com/cypress-io/cypress/blob/develop/LICENSE)
|
|
62
62
|
|
|
63
63
|
This project is licensed under the terms of the [MIT license](/LICENSE).
|
|
64
64
|
|
|
@@ -24,12 +24,22 @@ if (supportFile) {
|
|
|
24
24
|
|
|
25
25
|
// We need a slash before /cypress/supportFile.js, this happens by default
|
|
26
26
|
// with the current string replacement logic.
|
|
27
|
-
importsToLoad.push(
|
|
27
|
+
importsToLoad.push({
|
|
28
|
+
load: () => import(`${devServerPublicPathRoute}${supportRelativeToProjectRoot}`),
|
|
29
|
+
absolute: supportFile,
|
|
30
|
+
relative: supportRelativeToProjectRoot,
|
|
31
|
+
relativeUrl: `${devServerPublicPathRoute}${supportRelativeToProjectRoot}`,
|
|
32
|
+
})
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
/* Spec file import logic */
|
|
31
36
|
// We need a slash before /src/my-spec.js, this does not happen by default.
|
|
32
|
-
importsToLoad.push(
|
|
37
|
+
importsToLoad.push({
|
|
38
|
+
load: () => import(`${devServerPublicPathRoute}/${CypressInstance.spec.relative}`),
|
|
39
|
+
absolute: CypressInstance.spec.absolute,
|
|
40
|
+
relative: CypressInstance.spec.relative,
|
|
41
|
+
relativeUrl: `${devServerPublicPathRoute}/${CypressInstance.spec.relative}`,
|
|
42
|
+
})
|
|
33
43
|
|
|
34
44
|
if (!CypressInstance) {
|
|
35
45
|
throw new Error('Tests cannot run without a reference to Cypress!')
|
package/dist/devServer.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="cypress" />
|
|
2
3
|
/// <reference types="node" />
|
|
4
|
+
import type { UserConfig } from 'vite';
|
|
3
5
|
declare const ALL_FRAMEWORKS: readonly ["react", "vue"];
|
|
6
|
+
declare type ConfigHandler = UserConfig | (() => UserConfig | Promise<UserConfig>);
|
|
4
7
|
export declare type ViteDevServerConfig = {
|
|
5
8
|
specs: Cypress.Spec[];
|
|
6
9
|
cypressConfig: Cypress.PluginConfigOptions;
|
|
@@ -8,7 +11,7 @@ export declare type ViteDevServerConfig = {
|
|
|
8
11
|
onConfigNotFound?: (devServer: 'vite', cwd: string, lookedIn: string[]) => void;
|
|
9
12
|
} & {
|
|
10
13
|
framework?: typeof ALL_FRAMEWORKS[number];
|
|
11
|
-
viteConfig?:
|
|
14
|
+
viteConfig?: ConfigHandler;
|
|
12
15
|
};
|
|
13
16
|
export declare function devServer(config: ViteDevServerConfig): Promise<Cypress.ResolvedDevServerConfig>;
|
|
14
17
|
export declare namespace devServer {
|
package/dist/devServer.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.devServer = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const debug_1 =
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const getVite_1 = require("./getVite");
|
|
7
7
|
const resolveConfig_1 = require("./resolveConfig");
|
|
8
8
|
const debug = (0, debug_1.default)('cypress:vite-dev-server:devServer');
|
package/dist/getVite.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const debug_1 =
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const debug = (0, debug_1.default)('cypress:vite-dev-server:getVite');
|
|
7
7
|
// "vite-dev-server" is bundled in the binary, so we need to require.resolve "vite"
|
|
8
8
|
// from root of the active project since we don't bundle vite internally but rather
|
package/dist/plugins/cypress.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cypress = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const debug_1 =
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const pathe_1 = require("pathe");
|
|
7
7
|
const node_html_parser_1 = require("node-html-parser");
|
|
8
|
-
const fs_1 =
|
|
9
|
-
const path_1 =
|
|
8
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
9
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
10
|
const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:cypress');
|
|
11
11
|
const INIT_FILEPATH = (0, pathe_1.resolve)(__dirname, '../../client/initCypressTests.js');
|
|
12
12
|
const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50;
|
|
@@ -72,6 +72,27 @@ const Cypress = (options, vite) => {
|
|
|
72
72
|
return res.end(transformedIndexHtml);
|
|
73
73
|
});
|
|
74
74
|
},
|
|
75
|
+
transform(code, id, options) {
|
|
76
|
+
try {
|
|
77
|
+
if (/\.js$/i.test(id) && !/\/\/# sourceMappingURL=/i.test(code)) {
|
|
78
|
+
// The Vite dev server and plugins automatically transpile TS and JSX files, which results in sourcemaps being generated
|
|
79
|
+
// and included in output. However, Vite serves up `esnext`-compliant Javascript which means many JS files won't be
|
|
80
|
+
// transpiled and won't supply a sourcemap - this prevents Cypress from providing codeFrames in the event of an error.
|
|
81
|
+
//
|
|
82
|
+
// A sourcemap is generated by Vite for JS files (just not included) which is in effect an "identity" sourcemap mapping
|
|
83
|
+
// 1-to-1 to the output file. We can grab this and pass it along as a sourcemap we want Vite to embed into the output,
|
|
84
|
+
// giving Cypress a sourcemap to use for codeFrame lookups.
|
|
85
|
+
// @see https://rollupjs.org/guide/en/#thisgetcombinedsourcemap
|
|
86
|
+
return {
|
|
87
|
+
code,
|
|
88
|
+
map: this.getCombinedSourcemap(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (_err) {
|
|
93
|
+
debug('Failed to propagate sourcemap for %s: %o', id, _err);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
75
96
|
handleHotUpdate: ({ server, file }) => {
|
|
76
97
|
debug('handleHotUpdate - file', file);
|
|
77
98
|
// If the user provided IndexHtml is changed, do a full-reload
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./inspect"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./cypress"), exports);
|
package/dist/plugins/inspect.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CypressInspect = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const debug_1 =
|
|
5
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
6
|
const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:inspect');
|
|
7
7
|
const CypressInspect = (config) => {
|
|
8
8
|
var _a;
|
package/dist/resolveConfig.js
CHANGED
|
@@ -7,10 +7,10 @@ const tslib_1 = require("tslib");
|
|
|
7
7
|
* Vitest's own config resolution logic.
|
|
8
8
|
* You can find it here https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/create.ts
|
|
9
9
|
*/
|
|
10
|
-
const debug_1 =
|
|
10
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
11
11
|
const local_pkg_1 = require("local-pkg");
|
|
12
12
|
const pathe_1 = require("pathe");
|
|
13
|
-
const path_1 =
|
|
13
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const index_1 = require("./plugins/index");
|
|
16
16
|
const debug = (0, debug_1.default)('cypress:vite-dev-server:resolve-config');
|
|
@@ -86,7 +86,14 @@ const createViteDevServerConfig = async (config, vite) => {
|
|
|
86
86
|
(0, index_1.CypressInspect)(config),
|
|
87
87
|
].filter((p) => p != null),
|
|
88
88
|
};
|
|
89
|
-
|
|
89
|
+
let resolvedOverrides = {};
|
|
90
|
+
if (typeof viteOverrides === 'function') {
|
|
91
|
+
resolvedOverrides = await viteOverrides();
|
|
92
|
+
}
|
|
93
|
+
else if (typeof viteOverrides === 'object') {
|
|
94
|
+
resolvedOverrides = viteOverrides;
|
|
95
|
+
}
|
|
96
|
+
const finalConfig = vite.mergeConfig(viteBaseConfig, resolvedOverrides);
|
|
90
97
|
debug('The resolved server config is', JSON.stringify(finalConfig, null, 2));
|
|
91
98
|
return finalConfig;
|
|
92
99
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/vite-dev-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Launches Vite Dev Server for Component Testing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dedent": "^0.7.0",
|
|
27
27
|
"mocha": "^9.2.2",
|
|
28
28
|
"sinon": "^13.0.1",
|
|
29
|
-
"ts-node": "^10.
|
|
30
|
-
"vite": "3.0
|
|
29
|
+
"ts-node": "^10.9.1",
|
|
30
|
+
"vite": "3.1.0",
|
|
31
31
|
"vite-plugin-inspect": "0.4.3"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"type": "git",
|
|
42
42
|
"url": "https://github.com/cypress-io/cypress.git"
|
|
43
43
|
},
|
|
44
|
-
"homepage": "https://github.com/cypress-io/cypress/tree/
|
|
44
|
+
"homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/vite-dev-server#readme",
|
|
45
45
|
"bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
|
|
46
46
|
"module": "dist/index.js",
|
|
47
47
|
"publishConfig": {
|