@cypress/vite-dev-server 5.1.1 → 5.2.1
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/dist/devServer.js +5 -1
- package/dist/plugins/cypress.js +1 -0
- package/dist/plugins/sourcemap.js +18 -13
- package/dist/resolveConfig.js +2 -2
- package/package.json +1 -1
package/dist/devServer.js
CHANGED
|
@@ -32,7 +32,11 @@ async function devServer(config) {
|
|
|
32
32
|
port,
|
|
33
33
|
// Close is for unit testing only. We kill this child process which will handle the closing of the server
|
|
34
34
|
close(cb) {
|
|
35
|
-
|
|
35
|
+
debug('closing dev server');
|
|
36
|
+
return server.close().then(() => {
|
|
37
|
+
debug('closed dev server');
|
|
38
|
+
cb === null || cb === void 0 ? void 0 : cb();
|
|
39
|
+
}).catch(cb);
|
|
36
40
|
},
|
|
37
41
|
};
|
|
38
42
|
}
|
package/dist/plugins/cypress.js
CHANGED
|
@@ -24,6 +24,7 @@ const Cypress = (options, vite) => {
|
|
|
24
24
|
// eslint-disable-next-line no-restricted-syntax
|
|
25
25
|
let loader = fs_1.default.readFileSync(INIT_FILEPATH, 'utf8');
|
|
26
26
|
devServerEvents.on('dev-server:specs:changed', (specs) => {
|
|
27
|
+
debug(`dev-server:secs:changed: ${specs.map((spec) => spec.relative)}`);
|
|
27
28
|
specsPathsSet = getSpecsPathsSet(specs);
|
|
28
29
|
});
|
|
29
30
|
return {
|
|
@@ -10,26 +10,31 @@ const CypressSourcemap = (options, vite) => {
|
|
|
10
10
|
enforce: 'post',
|
|
11
11
|
transform(code, id, options) {
|
|
12
12
|
try {
|
|
13
|
-
|
|
13
|
+
// Remove query parameters from the id. This is necessary because some files
|
|
14
|
+
// have a cache buster query parameter (e.g. `?v=12345`)
|
|
15
|
+
const queryParameterLessId = id.split('?')[0];
|
|
16
|
+
// Check if the file has a JavaScript extension and does not have an inlined sourcemap
|
|
17
|
+
if (/\.(js|jsx|ts|tsx|vue|svelte|mjs|cjs)$/i.test(queryParameterLessId) && !/\/\/# sourceMappingURL=data/i.test(code)) {
|
|
14
18
|
/*
|
|
15
|
-
The Vite dev server and plugins automatically generate sourcemaps for most files, but
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
transpilation won't get code frames in the runner.
|
|
19
|
-
|
|
20
|
-
A sourcemap for these files is generated (just not served) which is in effect an "identity"
|
|
21
|
-
sourcemap mapping 1-to-1 to the output file. We can grab this and pass it along as a sourcemap
|
|
22
|
-
we want Vite to embed into the output, giving Cypress a sourcemap to use for codeFrame lookups.
|
|
23
|
-
@see https://rollupjs.org/guide/en/#thisgetcombinedsourcemap
|
|
24
|
-
|
|
25
|
-
We utilize a 'post' plugin here and manually append the sourcemap content to the code. We *should*
|
|
19
|
+
The Vite dev server and plugins automatically generate sourcemaps for most files, but there are
|
|
20
|
+
some files that don't have sourcemaps generated for them or are not inlined. We utilize a 'post' plugin
|
|
21
|
+
here and manually append the sourcemap content to the code in these cases. We *should*
|
|
26
22
|
be able to pass the sourcemap along using the `map` attribute in the return value, but Babel-based
|
|
27
23
|
plugins don't work with this which causes sourcemaps to break for files that go through common
|
|
28
24
|
plugins like `@vitejs/plugin-react`. By manually appending the sourcemap at this point in time
|
|
29
25
|
Babel-transformed files end up with correct sourcemaps.
|
|
30
26
|
*/
|
|
31
27
|
const sourcemap = this.getCombinedSourcemap();
|
|
32
|
-
|
|
28
|
+
const sourcemapUrl = sourcemap.toUrl();
|
|
29
|
+
if (/\/\/# sourceMappingURL=/i.test(code)) {
|
|
30
|
+
// If the code already has a sourceMappingURL, it is not an inlined sourcemap
|
|
31
|
+
// and we should replace it with the new sourcemap
|
|
32
|
+
code = code.replace(/\/\/# sourceMappingURL=(.*)$/m, `//# sourceMappingURL=${sourcemapUrl}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// If the code does not have a sourceMappingURL, we should append the new sourcemap
|
|
36
|
+
code += `\n//# sourceMappingURL=${sourcemapUrl}`;
|
|
37
|
+
}
|
|
33
38
|
return {
|
|
34
39
|
code,
|
|
35
40
|
map: { mappings: '' },
|
package/dist/resolveConfig.js
CHANGED
|
@@ -52,7 +52,7 @@ const createViteDevServerConfig = async (config, vite) => {
|
|
|
52
52
|
exports.createViteDevServerConfig = createViteDevServerConfig;
|
|
53
53
|
function makeCypressViteConfig(config, vite) {
|
|
54
54
|
var _a, _b, _c;
|
|
55
|
-
const { cypressConfig: { port, projectRoot, devServerPublicPathRoute, supportFile, cypressBinaryRoot, isTextTerminal, }, specs, } = config;
|
|
55
|
+
const { cypressConfig: { experimentalJustInTimeCompile, port, projectRoot, devServerPublicPathRoute, supportFile, cypressBinaryRoot, isTextTerminal, }, specs, } = config;
|
|
56
56
|
const vitePort = port !== null && port !== void 0 ? port : undefined;
|
|
57
57
|
// Vite caches its output in the .vite directory in the node_modules where vite lives.
|
|
58
58
|
// So we want to find that node_modules path and ensure it's added to the "allow" list
|
|
@@ -95,7 +95,7 @@ function makeCypressViteConfig(config, vite) {
|
|
|
95
95
|
// Supported from Vite v3 - add null check for v2 users.
|
|
96
96
|
(_a = vite.searchForWorkspaceRoot) === null || _a === void 0 ? void 0 : _a.call(vite, process.cwd()),
|
|
97
97
|
],
|
|
98
|
-
}, port: vitePort, host: '127.0.0.1' }, (isTextTerminal
|
|
98
|
+
}, port: vitePort, host: '127.0.0.1' }, (isTextTerminal && !experimentalJustInTimeCompile
|
|
99
99
|
? { watch: { ignored: '**/*' }, hmr: false }
|
|
100
100
|
: {})),
|
|
101
101
|
plugins: [
|