@cypress/webpack-dev-server 4.1.1 → 5.1.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.
|
@@ -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
|
-
}
|
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs-extra"));
|
|
6
6
|
const os_1 = require("os");
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
|
-
const semver_1 = require("semver");
|
|
9
8
|
const dynamic_import_1 = require("../dynamic-import");
|
|
10
9
|
const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
|
|
11
10
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -82,19 +81,11 @@ async function getTempDir(projectName) {
|
|
|
82
81
|
}
|
|
83
82
|
exports.getTempDir = getTempDir;
|
|
84
83
|
async function getAngularCliModules(projectRoot) {
|
|
85
|
-
let angularVersion;
|
|
86
|
-
try {
|
|
87
|
-
angularVersion = await getInstalledPackageVersion('@angular-devkit/core', projectRoot);
|
|
88
|
-
}
|
|
89
|
-
catch (_a) {
|
|
90
|
-
throw new Error(`Could not resolve "@angular-devkit/core". Do you have it installed?`);
|
|
91
|
-
}
|
|
92
84
|
const angularCLiModules = [
|
|
93
85
|
'@angular-devkit/build-angular/src/utils/webpack-browser-config.js',
|
|
94
86
|
// in Angular 16.1 the locations of these files below were changed
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: ['@angular-devkit/build-angular/src/webpack/configs/common.js', '@angular-devkit/build-angular/src/webpack/configs/styles.js']),
|
|
87
|
+
'@angular-devkit/build-angular/src/tools/webpack/configs/common.js',
|
|
88
|
+
'@angular-devkit/build-angular/src/tools/webpack/configs/styles.js',
|
|
98
89
|
'@angular-devkit/core/src/index.js',
|
|
99
90
|
];
|
|
100
91
|
const [{ generateBrowserWebpackConfigFromContext }, { getCommonConfig }, { getStylesConfig }, { logging },] = await Promise.all(angularCLiModules.map((dep) => {
|
|
@@ -114,11 +105,6 @@ async function getAngularCliModules(projectRoot) {
|
|
|
114
105
|
};
|
|
115
106
|
}
|
|
116
107
|
exports.getAngularCliModules = getAngularCliModules;
|
|
117
|
-
async function getInstalledPackageVersion(pkgName, projectRoot) {
|
|
118
|
-
const packageJsonPath = require.resolve(`${pkgName}/package.json`, { paths: [projectRoot] });
|
|
119
|
-
const { version } = JSON.parse(await fs.readFile(packageJsonPath, { encoding: 'utf-8' }));
|
|
120
|
-
return version;
|
|
121
|
-
}
|
|
122
108
|
async function getAngularJson(projectRoot) {
|
|
123
109
|
const { findUp } = await (0, dynamic_import_1.dynamicImport)('find-up');
|
|
124
110
|
const angularJsonPath = await findUp('angular.json', { cwd: projectRoot });
|
|
@@ -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.1.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",
|
|
@@ -42,12 +41,10 @@
|
|
|
42
41
|
"sinon": "^13.0.1",
|
|
43
42
|
"snap-shot-it": "^7.9.10",
|
|
44
43
|
"ts-node": "^10.9.2",
|
|
45
|
-
"webpack": "npm:webpack@^5"
|
|
46
|
-
"webpack-4": "npm:webpack@^4",
|
|
47
|
-
"webpack-dev-server-4": "npm:webpack-dev-server@^4"
|
|
44
|
+
"webpack": "npm:webpack@^5"
|
|
48
45
|
},
|
|
49
46
|
"peerDependencies": {
|
|
50
|
-
"cypress": ">=
|
|
47
|
+
"cypress": ">=15.0.0"
|
|
51
48
|
},
|
|
52
49
|
"files": [
|
|
53
50
|
"dist"
|