@cypress/webpack-dev-server 4.1.0 → 5.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.
|
@@ -67,7 +67,8 @@ class CypressCTWebpackPlugin {
|
|
|
67
67
|
// TODO: don't use a sync fs method here
|
|
68
68
|
// eslint-disable-next-line no-restricted-syntax
|
|
69
69
|
const utimesSync = (_a = inputFileSystem.fileSystem.utimesSync) !== null && _a !== void 0 ? _a : fs_extra_1.default.utimesSync;
|
|
70
|
-
|
|
70
|
+
const indexHtmlFilePath = path_1.default.isAbsolute(this.indexHtmlFile) ? this.indexHtmlFile : path_1.default.join(this.projectRoot, this.indexHtmlFile);
|
|
71
|
+
utimesSync(indexHtmlFilePath, new Date(), new Date());
|
|
71
72
|
};
|
|
72
73
|
/**
|
|
73
74
|
* The webpack compiler generates a new `compilation` each time it compiles, so
|
|
@@ -14,10 +14,6 @@ async function createWebpackDevServer(config) {
|
|
|
14
14
|
debug('using webpack-dev-server v5');
|
|
15
15
|
return webpackDevServer5(config, webpackCompiler, finalWebpackConfig);
|
|
16
16
|
}
|
|
17
|
-
if (webpackDevServerMajorVersion === 4) {
|
|
18
|
-
debug('using webpack-dev-server v4');
|
|
19
|
-
return webpackDevServer4(config, webpackCompiler, finalWebpackConfig);
|
|
20
|
-
}
|
|
21
17
|
throw new Error(`Unsupported webpackDevServer version ${webpackDevServerMajorVersion}`);
|
|
22
18
|
}
|
|
23
19
|
exports.createWebpackDevServer = createWebpackDevServer;
|
|
@@ -41,20 +37,3 @@ function webpackDevServer5(config, compiler, finalWebpackConfig) {
|
|
|
41
37
|
compiler,
|
|
42
38
|
};
|
|
43
39
|
}
|
|
44
|
-
function webpackDevServer4(config, compiler, finalWebpackConfig) {
|
|
45
|
-
var _a;
|
|
46
|
-
const { devServerConfig: { cypressConfig: { devServerPublicPathRoute } } } = config;
|
|
47
|
-
const isOpenMode = !config.devServerConfig.cypressConfig.isTextTerminal;
|
|
48
|
-
const WebpackDevServer = config.sourceWebpackModulesResult.webpackDevServer.module;
|
|
49
|
-
const webpackDevServerConfig = Object.assign(Object.assign({ host: '127.0.0.1', port: 'auto' }, finalWebpackConfig === null || finalWebpackConfig === void 0 ? void 0 : finalWebpackConfig.devServer), { devMiddleware: Object.assign({ publicPath: devServerPublicPathRoute, stats: (_a = finalWebpackConfig.stats) !== null && _a !== void 0 ? _a : 'minimal' }, ((0, util_1.isWebpackBundleAnalyzerEnabled)() ? {
|
|
50
|
-
// the bundle needs to be written to disk in order to determine source map sizes
|
|
51
|
-
writeToDisk: true,
|
|
52
|
-
} : {})), hot: false,
|
|
53
|
-
// Only enable file watching & reload when executing tests in `open` mode
|
|
54
|
-
liveReload: isOpenMode });
|
|
55
|
-
const server = new WebpackDevServer(webpackDevServerConfig, compiler);
|
|
56
|
-
return {
|
|
57
|
-
server,
|
|
58
|
-
compiler,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
@@ -6,12 +6,6 @@ const module_1 = tslib_1.__importDefault(require("module"));
|
|
|
6
6
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
7
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
8
8
|
const debug = (0, debug_1.default)('cypress:webpack-dev-server:sourceRelativeWebpackModules');
|
|
9
|
-
class CypressWebpackDevServerError extends Error {
|
|
10
|
-
constructor(message) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = 'CypressWebpackDevServerError';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
9
|
const originalModuleLoad = module_1.default._load;
|
|
16
10
|
const originalModuleResolveFilename = module_1.default._resolveFilename;
|
|
17
11
|
// We ship webpack@4 as part of '@cypress/webpack-batteries-included-preprocessor'. The path to this module
|
|
@@ -89,7 +83,7 @@ function sourceWebpack(config, framework) {
|
|
|
89
83
|
webpack.importPath = path_1.default.dirname(webpackJsonPath);
|
|
90
84
|
webpack.packageJson = require(webpackJsonPath);
|
|
91
85
|
webpack.module = require(webpack.importPath);
|
|
92
|
-
webpack.majorVersion = getMajorVersion(webpack.packageJson, [
|
|
86
|
+
webpack.majorVersion = getMajorVersion(webpack.packageJson, [5]);
|
|
93
87
|
debug('Webpack: Successfully sourced webpack - %o', webpack);
|
|
94
88
|
module_1.default._load = function (request, parent, isMain) {
|
|
95
89
|
if (request === 'webpack' || request.startsWith('webpack/')) {
|
|
@@ -140,20 +134,15 @@ function sourceWebpackDevServer(config, webpackMajorVersion, framework) {
|
|
|
140
134
|
webpackDevServer.importPath = path_1.default.dirname(webpackDevServerJsonPath);
|
|
141
135
|
webpackDevServer.packageJson = require(webpackDevServerJsonPath);
|
|
142
136
|
webpackDevServer.module = require(webpackDevServer.importPath);
|
|
143
|
-
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [
|
|
137
|
+
webpackDevServer.majorVersion = getMajorVersion(webpackDevServer.packageJson, [5]);
|
|
144
138
|
debug('WebpackDevServer: Successfully sourced webpack-dev-server - %o', webpackDevServer);
|
|
145
|
-
if (webpackMajorVersion < 5 && webpackDevServer.majorVersion === 5) {
|
|
146
|
-
const json = webpackDevServer.packageJson;
|
|
147
|
-
throw new CypressWebpackDevServerError(`Incompatible major versions of webpack and webpack-dev-server!
|
|
148
|
-
webpack-dev-server major version ${webpackDevServer.majorVersion} only works with major versions of webpack 5 - saw webpack-dev-server version ${json.version}.
|
|
149
|
-
If using webpack major version 4, please install webpack-dev-server version 4 to be used with @cypress/webpack-dev-server or upgrade to webpack 5.`);
|
|
150
|
-
}
|
|
151
139
|
return webpackDevServer;
|
|
152
140
|
}
|
|
153
141
|
exports.sourceWebpackDevServer = sourceWebpackDevServer;
|
|
154
142
|
// Source the html-webpack-plugin module from the provided framework or projectRoot.
|
|
155
143
|
// If none is found, we fallback to the version bundled with this package dependent on the major version of webpack.
|
|
156
|
-
// We ship
|
|
144
|
+
// We ship v5 of 'html-webpack-plugin' by aliasing the package with the major version (check package.json). This allows
|
|
145
|
+
// us to support newer major versions of 'html-webpack-plugin' easily'.
|
|
157
146
|
function sourceHtmlWebpackPlugin(config, framework, webpack) {
|
|
158
147
|
var _a;
|
|
159
148
|
const searchRoot = (_a = framework === null || framework === void 0 ? void 0 : framework.importPath) !== null && _a !== void 0 ? _a : config.cypressConfig.projectRoot;
|
|
@@ -165,9 +154,9 @@ function sourceHtmlWebpackPlugin(config, framework, webpack) {
|
|
|
165
154
|
paths: [searchRoot],
|
|
166
155
|
});
|
|
167
156
|
htmlWebpackPlugin.packageJson = require(htmlWebpackPluginJsonPath);
|
|
168
|
-
// Check that they're not using v3 of html-webpack-plugin. Since we should be the only consumer of it,
|
|
157
|
+
// Check that they're not using v3 or v4 of html-webpack-plugin. Since we should be the only consumer of it,
|
|
169
158
|
// we shouldn't be concerned with using our own copy if they've shipped w/ an earlier version
|
|
170
|
-
htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [
|
|
159
|
+
htmlWebpackPlugin.majorVersion = getMajorVersion(htmlWebpackPlugin.packageJson, [5]);
|
|
171
160
|
}
|
|
172
161
|
catch (e) {
|
|
173
162
|
const err = e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"find-up": "6.3.0",
|
|
21
21
|
"fs-extra": "9.1.0",
|
|
22
|
-
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
|
|
23
22
|
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
|
|
24
23
|
"local-pkg": "0.4.1",
|
|
25
24
|
"semver": "^7.7.1",
|
|
@@ -35,18 +34,17 @@
|
|
|
35
34
|
"@types/speed-measure-webpack-plugin": "^1.3.4",
|
|
36
35
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
37
36
|
"chai": "^4.3.6",
|
|
37
|
+
"cross-env": "7.0.3",
|
|
38
38
|
"dedent": "^0.7.0",
|
|
39
39
|
"mocha": "^9.2.2",
|
|
40
40
|
"proxyquire": "2.1.3",
|
|
41
41
|
"sinon": "^13.0.1",
|
|
42
42
|
"snap-shot-it": "^7.9.10",
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
|
-
"webpack": "npm:webpack@^5"
|
|
45
|
-
"webpack-4": "npm:webpack@^4",
|
|
46
|
-
"webpack-dev-server-4": "npm:webpack-dev-server@^4"
|
|
44
|
+
"webpack": "npm:webpack@^5"
|
|
47
45
|
},
|
|
48
46
|
"peerDependencies": {
|
|
49
|
-
"cypress": ">=
|
|
47
|
+
"cypress": ">=15.0.0"
|
|
50
48
|
},
|
|
51
49
|
"files": [
|
|
52
50
|
"dist"
|