@cypress/webpack-dev-server 3.2.3 → 3.3.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.
|
@@ -7,6 +7,7 @@ export interface CypressCTWebpackPluginOptions {
|
|
|
7
7
|
supportFile: string | false;
|
|
8
8
|
devServerEvents: EventEmitter;
|
|
9
9
|
webpack: Function;
|
|
10
|
+
indexHtmlFile: string;
|
|
10
11
|
}
|
|
11
12
|
export declare type CypressCTContextOptions = Omit<CypressCTWebpackPluginOptions, 'devServerEvents' | 'webpack'>;
|
|
12
13
|
export interface CypressCTWebpackContext {
|
|
@@ -23,6 +23,7 @@ class CypressCTWebpackPlugin {
|
|
|
23
23
|
files: this.files,
|
|
24
24
|
projectRoot: this.projectRoot,
|
|
25
25
|
supportFile: this.supportFile,
|
|
26
|
+
indexHtmlFile: this.indexHtmlFile,
|
|
26
27
|
};
|
|
27
28
|
};
|
|
28
29
|
this.beforeCompile = async (compilationParams, callback) => {
|
|
@@ -45,11 +46,16 @@ class CypressCTWebpackPlugin {
|
|
|
45
46
|
callback();
|
|
46
47
|
};
|
|
47
48
|
/*
|
|
48
|
-
* `webpack --watch` watches the existing specs and their dependencies for changes
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* `webpack --watch` watches the existing specs and their dependencies for changes.
|
|
50
|
+
* When new specs are created, we need to trigger a recompilation to add the new specs
|
|
51
|
+
* as dependencies. This hook informs webpack that `component-index.html` has been "updated on disk",
|
|
52
|
+
* causing a recompilation (and pulling the new specs in as dependencies). We use the component
|
|
53
|
+
* index file because we know that it will be there since the project is using Component Testing.
|
|
54
|
+
*
|
|
55
|
+
* We were using `browser.js` before to cause a recompilation but we ran into an
|
|
56
|
+
* issue with MacOS Ventura that will not allow us to write to files inside of our application bundle.
|
|
57
|
+
*
|
|
58
|
+
* See https://github.com/cypress-io/cypress/issues/24398
|
|
53
59
|
*/
|
|
54
60
|
this.onSpecsChange = async (specs) => {
|
|
55
61
|
var _a;
|
|
@@ -61,7 +67,7 @@ class CypressCTWebpackPlugin {
|
|
|
61
67
|
// TODO: don't use a sync fs method here
|
|
62
68
|
// eslint-disable-next-line no-restricted-syntax
|
|
63
69
|
const utimesSync = (_a = inputFileSystem.fileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
|
|
64
|
-
utimesSync(path_1.default.
|
|
70
|
+
utimesSync(path_1.default.join(this.projectRoot, this.indexHtmlFile), new Date(), new Date());
|
|
65
71
|
};
|
|
66
72
|
/**
|
|
67
73
|
* The webpack compiler generates a new `compilation` each time it compiles, so
|
|
@@ -88,6 +94,7 @@ class CypressCTWebpackPlugin {
|
|
|
88
94
|
this.projectRoot = options.projectRoot;
|
|
89
95
|
this.devServerEvents = options.devServerEvents;
|
|
90
96
|
this.webpack = options.webpack;
|
|
97
|
+
this.indexHtmlFile = options.indexHtmlFile;
|
|
91
98
|
}
|
|
92
99
|
/**
|
|
93
100
|
* The plugin's entrypoint, called once by webpack when the compiler is initialized.
|
package/dist/devServer.d.ts
CHANGED
package/dist/devServer.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/// <reference types="cypress" />
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.devServer = void 0;
|
|
4
|
+
exports.isThirdPartyDefinition = exports.devServer = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const createWebpackDevServer_1 = require("./createWebpackDevServer");
|
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -62,7 +62,22 @@ function devServer(devServerConfig) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
exports.devServer = devServer;
|
|
65
|
+
const thirdPartyDefinitionPrefixes = {
|
|
66
|
+
// matches @org/cypress-ct-*
|
|
67
|
+
namespacedPrefixRe: /^@.+?\/cypress-ct-.+/,
|
|
68
|
+
globalPrefix: 'cypress-ct-',
|
|
69
|
+
};
|
|
70
|
+
function isThirdPartyDefinition(framework) {
|
|
71
|
+
return framework.startsWith(thirdPartyDefinitionPrefixes.globalPrefix) ||
|
|
72
|
+
thirdPartyDefinitionPrefixes.namespacedPrefixRe.test(framework);
|
|
73
|
+
}
|
|
74
|
+
exports.isThirdPartyDefinition = isThirdPartyDefinition;
|
|
65
75
|
async function getPreset(devServerConfig) {
|
|
76
|
+
const defaultWebpackModules = () => ({ sourceWebpackModulesResult: (0, sourceRelativeWebpackModules_1.sourceDefaultWebpackDependencies)(devServerConfig) });
|
|
77
|
+
// Third party library (eg solid-js, lit, etc)
|
|
78
|
+
if (devServerConfig.framework && isThirdPartyDefinition(devServerConfig.framework)) {
|
|
79
|
+
return defaultWebpackModules();
|
|
80
|
+
}
|
|
66
81
|
switch (devServerConfig.framework) {
|
|
67
82
|
case 'create-react-app':
|
|
68
83
|
return (0, createReactAppHandler_1.createReactAppHandler)(devServerConfig);
|
|
@@ -78,7 +93,7 @@ async function getPreset(devServerConfig) {
|
|
|
78
93
|
case 'vue':
|
|
79
94
|
case 'svelte':
|
|
80
95
|
case undefined:
|
|
81
|
-
return
|
|
96
|
+
return defaultWebpackModules();
|
|
82
97
|
default:
|
|
83
98
|
throw new Error(`Unexpected framework ${devServerConfig.framework}, please visit https://on.cypress.io/component-framework-configuration to see a list of supported frameworks`);
|
|
84
99
|
}
|