@cypress/webpack-dev-server 3.3.0 → 3.4.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.
|
@@ -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;
|
|
28
|
+
var _a, _b, _c;
|
|
29
29
|
const resolvePaths = { paths: [devServerConfig.cypressConfig.projectRoot] };
|
|
30
30
|
const packages = {};
|
|
31
31
|
try {
|
|
@@ -42,6 +42,13 @@ function getNextJsPackages(devServerConfig) {
|
|
|
42
42
|
catch (e) {
|
|
43
43
|
throw new Error(`Failed to load "next/dist/build/webpack-config" with error: ${(_b = e.message) !== null && _b !== void 0 ? _b : e}`);
|
|
44
44
|
}
|
|
45
|
+
try {
|
|
46
|
+
const loadJsConfigPath = require.resolve('next/dist/build/load-jsconfig', resolvePaths);
|
|
47
|
+
packages.nextLoadJsConfig = require(loadJsConfigPath).default;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new Error(`Failed to load "next/dist/build/load-jsconfig" with error: ${(_c = e.message) !== null && _c !== void 0 ? _c : e}`);
|
|
51
|
+
}
|
|
45
52
|
return packages;
|
|
46
53
|
}
|
|
47
54
|
/**
|
|
@@ -125,19 +132,54 @@ function getNextJsPackages(devServerConfig) {
|
|
|
125
132
|
middlewareMatchers?: MiddlewareMatcher[]
|
|
126
133
|
}
|
|
127
134
|
]
|
|
135
|
+
|
|
136
|
+
* - v13.2.1
|
|
137
|
+
[
|
|
138
|
+
dir: string,
|
|
139
|
+
options: {
|
|
140
|
+
buildId: string
|
|
141
|
+
config: NextConfigComplete
|
|
142
|
+
compilerType: CompilerNameValues
|
|
143
|
+
dev?: boolean
|
|
144
|
+
entrypoints: webpack.EntryObject
|
|
145
|
+
isDevFallback?: boolean
|
|
146
|
+
pagesDir?: string
|
|
147
|
+
reactProductionProfiling?: boolean
|
|
148
|
+
rewrites: CustomRoutes['rewrites']
|
|
149
|
+
runWebpackSpan: Span
|
|
150
|
+
target?: string
|
|
151
|
+
appDir?: string
|
|
152
|
+
middlewareMatchers?: MiddlewareMatcher[]
|
|
153
|
+
noMangling?: boolean
|
|
154
|
+
jsConfig: any
|
|
155
|
+
resolvedBaseUrl: string | undefined
|
|
156
|
+
supportedBrowsers: string[] | undefined
|
|
157
|
+
clientRouterFilters?: {
|
|
158
|
+
staticFilter: ReturnType<
|
|
159
|
+
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
160
|
+
>
|
|
161
|
+
dynamicFilter: ReturnType<
|
|
162
|
+
import('../shared/lib/bloom-filter').BloomFilter['export']
|
|
163
|
+
>
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
128
167
|
*/
|
|
129
168
|
async function loadWebpackConfig(devServerConfig) {
|
|
130
|
-
const { loadConfig, getNextJsBaseWebpackConfig } = getNextJsPackages(devServerConfig);
|
|
169
|
+
const { loadConfig, getNextJsBaseWebpackConfig, nextLoadJsConfig } = getNextJsPackages(devServerConfig);
|
|
131
170
|
const nextConfig = await loadConfig('development', devServerConfig.cypressConfig.projectRoot);
|
|
132
171
|
const runWebpackSpan = getRunWebpackSpan(devServerConfig);
|
|
133
172
|
const reactVersion = getReactVersion(devServerConfig.cypressConfig.projectRoot);
|
|
173
|
+
const jsConfigResult = await (nextLoadJsConfig === null || nextLoadJsConfig === void 0 ? void 0 : nextLoadJsConfig(devServerConfig.cypressConfig.projectRoot, nextConfig));
|
|
134
174
|
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), {
|
|
135
175
|
// Client webpack config for Next.js <= 12.1.5
|
|
136
176
|
isServer: false,
|
|
137
177
|
// Client webpack config for Next.js > 12.1.5
|
|
138
178
|
compilerType: 'client',
|
|
139
179
|
// Required for Next.js > 13
|
|
140
|
-
hasReactRoot: reactVersion === 18
|
|
180
|
+
hasReactRoot: reactVersion === 18,
|
|
181
|
+
// Required for Next.js > 13.2.1 to respect TS/JS config
|
|
182
|
+
jsConfig: jsConfigResult.jsConfig }));
|
|
141
183
|
return webpackConfig;
|
|
142
184
|
}
|
|
143
185
|
/**
|