@cypress/webpack-dev-server 3.4.1 → 3.5.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/dist/helpers/angularHandler.js +38 -18
- package/package.json +2 -1
|
@@ -5,6 +5,7 @@ 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");
|
|
8
9
|
const dynamic_import_1 = require("../dynamic-import");
|
|
9
10
|
const sourceRelativeWebpackModules_1 = require("./sourceRelativeWebpackModules");
|
|
10
11
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
@@ -77,10 +78,19 @@ async function getTempDir() {
|
|
|
77
78
|
}
|
|
78
79
|
exports.getTempDir = getTempDir;
|
|
79
80
|
async function getAngularCliModules(projectRoot) {
|
|
81
|
+
let angularVersion;
|
|
82
|
+
try {
|
|
83
|
+
angularVersion = await getInstalledPackageVersion('@angular-devkit/core', projectRoot);
|
|
84
|
+
}
|
|
85
|
+
catch (_a) {
|
|
86
|
+
throw new Error(`Could not resolve "@angular-devkit/core". Do you have it installed?`);
|
|
87
|
+
}
|
|
80
88
|
const angularCLiModules = [
|
|
81
89
|
'@angular-devkit/build-angular/src/utils/webpack-browser-config.js',
|
|
82
|
-
|
|
83
|
-
'
|
|
90
|
+
// in Angular 16.1 the locations of these files below were changed
|
|
91
|
+
...((0, semver_1.gte)(angularVersion, '16.1.0')
|
|
92
|
+
? ['@angular-devkit/build-angular/src/tools/webpack/configs/common.js', '@angular-devkit/build-angular/src/tools/webpack/configs/styles.js']
|
|
93
|
+
: ['@angular-devkit/build-angular/src/webpack/configs/common.js', '@angular-devkit/build-angular/src/webpack/configs/styles.js']),
|
|
84
94
|
'@angular-devkit/core/src/index.js',
|
|
85
95
|
];
|
|
86
96
|
const [{ generateBrowserWebpackConfigFromContext }, { getCommonConfig }, { getStylesConfig }, { logging },] = await Promise.all(angularCLiModules.map((dep) => {
|
|
@@ -100,6 +110,11 @@ async function getAngularCliModules(projectRoot) {
|
|
|
100
110
|
};
|
|
101
111
|
}
|
|
102
112
|
exports.getAngularCliModules = getAngularCliModules;
|
|
113
|
+
async function getInstalledPackageVersion(pkgName, projectRoot) {
|
|
114
|
+
const packageJsonPath = require.resolve(`${pkgName}/package.json`, { paths: [projectRoot] });
|
|
115
|
+
const { version } = JSON.parse(await fs.readFile(packageJsonPath, { encoding: 'utf-8' }));
|
|
116
|
+
return version;
|
|
117
|
+
}
|
|
103
118
|
async function getAngularJson(projectRoot) {
|
|
104
119
|
const { findUp } = await (0, dynamic_import_1.dynamicImport)('find-up');
|
|
105
120
|
const angularJsonPath = await findUp('angular.json', { cwd: projectRoot });
|
|
@@ -144,26 +159,31 @@ async function getAngularCliWebpackConfig(devServerConfig) {
|
|
|
144
159
|
const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig);
|
|
145
160
|
const context = createFakeContext(projectConfig.buildOptions.workspaceRoot || projectRoot, projectConfig, logging);
|
|
146
161
|
const { config } = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
|
|
147
|
-
|
|
148
|
-
// We
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var _a;
|
|
159
|
-
if (typeof loader !== 'object' || typeof loader.options !== 'object' || !((_a = loader.loader) === null || _a === void 0 ? void 0 : _a.includes('resolve-url-loader'))) {
|
|
162
|
+
// Starting in Angular 16, the `getStylesConfig` function returns a `Promise`.
|
|
163
|
+
// We wrap it with `Promise.resolve` so we support older version of Angular
|
|
164
|
+
// returning a non-Promise result.
|
|
165
|
+
const stylesConfig = Promise.resolve(getStylesConfig(wco)).then((config) => {
|
|
166
|
+
// We modify resolve-url-loader and set `root` to be `projectRoot` + `sourceRoot` to ensure
|
|
167
|
+
// imports in scss, sass, etc are correctly resolved.
|
|
168
|
+
// https://github.com/cypress-io/cypress/issues/24272
|
|
169
|
+
config.module.rules.forEach((rule) => {
|
|
170
|
+
var _a;
|
|
171
|
+
(_a = rule.rules) === null || _a === void 0 ? void 0 : _a.forEach((ruleSet) => {
|
|
172
|
+
if (!Array.isArray(ruleSet.use)) {
|
|
160
173
|
return;
|
|
161
174
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
175
|
+
ruleSet.use.map((loader) => {
|
|
176
|
+
var _a;
|
|
177
|
+
if (typeof loader !== 'object' || typeof loader.options !== 'object' || !((_a = loader.loader) === null || _a === void 0 ? void 0 : _a.includes('resolve-url-loader'))) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const root = projectConfig.buildOptions.workspaceRoot || path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot);
|
|
181
|
+
debug('Adding root %s to resolve-url-loader options', root);
|
|
182
|
+
loader.options.root = root;
|
|
183
|
+
});
|
|
165
184
|
});
|
|
166
185
|
});
|
|
186
|
+
return config;
|
|
167
187
|
});
|
|
168
188
|
return [getCommonConfig(wco), stylesConfig];
|
|
169
189
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
|
|
24
24
|
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
|
|
25
25
|
"local-pkg": "0.4.1",
|
|
26
|
+
"semver": "^7.3.2",
|
|
26
27
|
"speed-measure-webpack-plugin": "1.4.2",
|
|
27
28
|
"tslib": "^2.3.1",
|
|
28
29
|
"webpack-dev-server": "^4.7.4",
|