@cypress/webpack-dev-server 3.3.1 → 3.4.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.
|
@@ -41,9 +41,10 @@ async function generateTsConfig(devServerConfig, buildOptions) {
|
|
|
41
41
|
var _a;
|
|
42
42
|
const { cypressConfig } = devServerConfig;
|
|
43
43
|
const { projectRoot } = cypressConfig;
|
|
44
|
+
const { workspaceRoot = projectRoot } = buildOptions;
|
|
44
45
|
const specPattern = Array.isArray(cypressConfig.specPattern) ? cypressConfig.specPattern : [cypressConfig.specPattern];
|
|
45
|
-
const getProjectFilePath = (...fileParts) => (0, exports.toPosix)(path.join(
|
|
46
|
-
const includePaths = [...specPattern.map((pattern) => getProjectFilePath(pattern))];
|
|
46
|
+
const getProjectFilePath = (...fileParts) => (0, exports.toPosix)(path.join(...fileParts));
|
|
47
|
+
const includePaths = [...specPattern.map((pattern) => getProjectFilePath(projectRoot, pattern))];
|
|
47
48
|
if (cypressConfig.supportFile) {
|
|
48
49
|
includePaths.push((0, exports.toPosix)(cypressConfig.supportFile));
|
|
49
50
|
}
|
|
@@ -51,14 +52,14 @@ async function generateTsConfig(devServerConfig, buildOptions) {
|
|
|
51
52
|
const polyfills = Array.isArray(buildOptions.polyfills)
|
|
52
53
|
? buildOptions.polyfills.filter((p) => { var _a, _b; return ((_a = devServerConfig.options) === null || _a === void 0 ? void 0 : _a.projectConfig.sourceRoot) && p.startsWith((_b = devServerConfig.options) === null || _b === void 0 ? void 0 : _b.projectConfig.sourceRoot); })
|
|
53
54
|
: [buildOptions.polyfills];
|
|
54
|
-
includePaths.push(...polyfills.map((p) => getProjectFilePath(p)));
|
|
55
|
+
includePaths.push(...polyfills.map((p) => getProjectFilePath(workspaceRoot, p)));
|
|
55
56
|
}
|
|
56
|
-
const cypressTypes = getProjectFilePath('node_modules', 'cypress', 'types', 'index.d.ts');
|
|
57
|
+
const cypressTypes = getProjectFilePath(workspaceRoot, 'node_modules', 'cypress', 'types', 'index.d.ts');
|
|
57
58
|
includePaths.push(cypressTypes);
|
|
58
59
|
const tsConfigContent = JSON.stringify({
|
|
59
|
-
extends: getProjectFilePath((_a = buildOptions.tsConfig) !== null && _a !== void 0 ? _a : 'tsconfig.json'),
|
|
60
|
+
extends: getProjectFilePath(projectRoot, (_a = buildOptions.tsConfig) !== null && _a !== void 0 ? _a : 'tsconfig.json'),
|
|
60
61
|
compilerOptions: {
|
|
61
|
-
outDir: getProjectFilePath('out-tsc/cy'),
|
|
62
|
+
outDir: getProjectFilePath(projectRoot, 'out-tsc/cy'),
|
|
62
63
|
allowSyntheticDefaultImports: true,
|
|
63
64
|
skipLibCheck: true,
|
|
64
65
|
},
|
|
@@ -141,7 +142,7 @@ async function getAngularCliWebpackConfig(devServerConfig) {
|
|
|
141
142
|
const projectConfig = ((_a = devServerConfig.options) === null || _a === void 0 ? void 0 : _a.projectConfig) || await getProjectConfig(projectRoot);
|
|
142
143
|
const tsConfig = await generateTsConfig(devServerConfig, projectConfig.buildOptions);
|
|
143
144
|
const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig);
|
|
144
|
-
const context = createFakeContext(projectRoot, projectConfig, logging);
|
|
145
|
+
const context = createFakeContext(projectConfig.buildOptions.workspaceRoot || projectRoot, projectConfig, logging);
|
|
145
146
|
const { config } = await generateBrowserWebpackConfigFromContext(buildOptions, context, (wco) => {
|
|
146
147
|
const stylesConfig = getStylesConfig(wco);
|
|
147
148
|
// We modify resolve-url-loader and set `root` to be `projectRoot` + `sourceRoot` to ensure
|
|
@@ -158,9 +159,9 @@ async function getAngularCliWebpackConfig(devServerConfig) {
|
|
|
158
159
|
if (typeof loader !== 'object' || typeof loader.options !== 'object' || !((_a = loader.loader) === null || _a === void 0 ? void 0 : _a.includes('resolve-url-loader'))) {
|
|
159
160
|
return;
|
|
160
161
|
}
|
|
161
|
-
const root = path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot);
|
|
162
|
+
const root = projectConfig.buildOptions.workspaceRoot || path.join(devServerConfig.cypressConfig.projectRoot, projectConfig.sourceRoot);
|
|
162
163
|
debug('Adding root %s to resolve-url-loader options', root);
|
|
163
|
-
loader.options.root =
|
|
164
|
+
loader.options.root = root;
|
|
164
165
|
});
|
|
165
166
|
});
|
|
166
167
|
});
|
|
@@ -25,7 +25,7 @@ exports.nextHandler = nextHandler;
|
|
|
25
25
|
* `getNextJsBaseWebpackConfig` acquires the webpackConfig dependent on the next.config.js
|
|
26
26
|
*/
|
|
27
27
|
function getNextJsPackages(devServerConfig) {
|
|
28
|
-
var _a, _b, _c;
|
|
28
|
+
var _a, _b, _c, _d, _e;
|
|
29
29
|
const resolvePaths = { paths: [devServerConfig.cypressConfig.projectRoot] };
|
|
30
30
|
const packages = {};
|
|
31
31
|
try {
|
|
@@ -49,6 +49,14 @@ function getNextJsPackages(devServerConfig) {
|
|
|
49
49
|
catch (e) {
|
|
50
50
|
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${(_c = e.message) !== null && _c !== void 0 ? _c : e}`);
|
|
51
51
|
}
|
|
52
|
+
// Does not exist prior to Next 13.
|
|
53
|
+
try {
|
|
54
|
+
const getUtilsPath = require.resolve('next/dist/build/utils', resolvePaths);
|
|
55
|
+
packages.getSupportedBrowsers = (_d = require(getUtilsPath).getSupportedBrowsers) !== null && _d !== void 0 ? _d : (() => Promise.resolve([]));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
throw new Error(`Failed to load "next/dist/build/utils" with error: ${(_e = e.message) !== null && _e !== void 0 ? _e : e}`);
|
|
59
|
+
}
|
|
52
60
|
return packages;
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
@@ -166,11 +174,12 @@ function getNextJsPackages(devServerConfig) {
|
|
|
166
174
|
]
|
|
167
175
|
*/
|
|
168
176
|
async function loadWebpackConfig(devServerConfig) {
|
|
169
|
-
const { loadConfig, getNextJsBaseWebpackConfig, nextLoadJsConfig } = getNextJsPackages(devServerConfig);
|
|
177
|
+
const { loadConfig, getNextJsBaseWebpackConfig, nextLoadJsConfig, getSupportedBrowsers } = getNextJsPackages(devServerConfig);
|
|
170
178
|
const nextConfig = await loadConfig('development', devServerConfig.cypressConfig.projectRoot);
|
|
171
179
|
const runWebpackSpan = getRunWebpackSpan(devServerConfig);
|
|
172
180
|
const reactVersion = getReactVersion(devServerConfig.cypressConfig.projectRoot);
|
|
173
181
|
const jsConfigResult = await (nextLoadJsConfig === null || nextLoadJsConfig === void 0 ? void 0 : nextLoadJsConfig(devServerConfig.cypressConfig.projectRoot, nextConfig));
|
|
182
|
+
const supportedBrowsers = await getSupportedBrowsers(devServerConfig.cypressConfig.projectRoot, true, nextConfig);
|
|
174
183
|
const webpackConfig = await getNextJsBaseWebpackConfig(devServerConfig.cypressConfig.projectRoot, Object.assign(Object.assign({ buildId: `@cypress/react-${Math.random().toString()}`, config: nextConfig, dev: true, pagesDir: await findPagesDir(devServerConfig.cypressConfig.projectRoot), entrypoints: {}, rewrites: { fallback: [], afterFiles: [], beforeFiles: [] } }, runWebpackSpan), {
|
|
175
184
|
// Client webpack config for Next.js <= 12.1.5
|
|
176
185
|
isServer: false,
|
|
@@ -178,8 +187,12 @@ async function loadWebpackConfig(devServerConfig) {
|
|
|
178
187
|
compilerType: 'client',
|
|
179
188
|
// Required for Next.js > 13
|
|
180
189
|
hasReactRoot: reactVersion === 18,
|
|
181
|
-
// Required for Next.js > 13.2.
|
|
182
|
-
jsConfig: jsConfigResult.jsConfig
|
|
190
|
+
// Required for Next.js > 13.2.0 to respect TS/JS config
|
|
191
|
+
jsConfig: jsConfigResult.jsConfig,
|
|
192
|
+
// Required for Next.js > 13.2.0 to respect tsconfig.compilerOptions.baseUrl
|
|
193
|
+
resolvedBaseUrl: jsConfigResult.resolvedBaseUrl,
|
|
194
|
+
// Added in Next.js 13, passed via `...info`: https://github.com/vercel/next.js/pull/45637/files
|
|
195
|
+
supportedBrowsers }));
|
|
183
196
|
return webpackConfig;
|
|
184
197
|
}
|
|
185
198
|
/**
|