@cypress/webpack-dev-server 3.3.0 → 3.3.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.
- package/dist/helpers/nextHandler.js +45 -3
- package/package.json +1 -1
|
@@ -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
|
/**
|