@cypress/webpack-dev-server 3.5.2 → 3.6.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/README.md
CHANGED
package/dist/devServer.js
CHANGED
|
@@ -22,9 +22,12 @@ const debug = (0, debug_1.default)('cypress:webpack-dev-server:devServer');
|
|
|
22
22
|
*/
|
|
23
23
|
function devServer(devServerConfig) {
|
|
24
24
|
return new Promise(async (resolve, reject) => {
|
|
25
|
+
var _a;
|
|
25
26
|
const result = await devServer.create(devServerConfig);
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
const { port } = (_a = result.server) === null || _a === void 0 ? void 0 : _a.options;
|
|
26
29
|
if (result.version === 3) {
|
|
27
|
-
const srv = result.server.listen(0, '127.0.0.1', () => {
|
|
30
|
+
const srv = result.server.listen(port || 0, '127.0.0.1', () => {
|
|
28
31
|
const port = srv.address().port;
|
|
29
32
|
debug('Component testing webpack server 3 started on port %s', port);
|
|
30
33
|
resolve({
|
|
@@ -69,7 +69,7 @@ export declare function getAngularBuildOptions(buildOptions: BuildOptions, tsCon
|
|
|
69
69
|
namedChunks: boolean;
|
|
70
70
|
};
|
|
71
71
|
export declare function generateTsConfig(devServerConfig: AngularWebpackDevServerConfig, buildOptions: BuildOptions): Promise<string>;
|
|
72
|
-
export declare function getTempDir(): Promise<string>;
|
|
72
|
+
export declare function getTempDir(projectName: string): Promise<string>;
|
|
73
73
|
export declare function getAngularCliModules(projectRoot: string): Promise<{
|
|
74
74
|
generateBrowserWebpackConfigFromContext: any;
|
|
75
75
|
getCommonConfig: any;
|
|
@@ -70,13 +70,13 @@ async function generateTsConfig(devServerConfig, buildOptions) {
|
|
|
70
70
|
},
|
|
71
71
|
include: includePaths,
|
|
72
72
|
}, null, 2);
|
|
73
|
-
const tsConfigPath = path.join(await getTempDir(), 'tsconfig.json');
|
|
73
|
+
const tsConfigPath = path.join(await getTempDir(path.basename(projectRoot)), 'tsconfig.json');
|
|
74
74
|
await fs.writeFile(tsConfigPath, tsConfigContent);
|
|
75
75
|
return tsConfigPath;
|
|
76
76
|
}
|
|
77
77
|
exports.generateTsConfig = generateTsConfig;
|
|
78
|
-
async function getTempDir() {
|
|
79
|
-
const cypressTempDir = path.join((0, os_1.tmpdir)(), 'cypress-angular-ct');
|
|
78
|
+
async function getTempDir(projectName) {
|
|
79
|
+
const cypressTempDir = path.join((0, os_1.tmpdir)(), 'cypress-angular-ct', projectName);
|
|
80
80
|
await fs.ensureDir(cypressTempDir);
|
|
81
81
|
return cypressTempDir;
|
|
82
82
|
}
|
|
@@ -207,6 +207,7 @@ function checkSWC(webpackConfig, cypressConfig) {
|
|
|
207
207
|
});
|
|
208
208
|
// "resolvedNodePath" is only set when using the user's Node.js, which is required to compile Next.js with SWC optimizations
|
|
209
209
|
// If it is not set, they have either explicitly set "nodeVersion" to "bundled" or are are using Cypress < 9.0.0 where it was set to "bundled" by default
|
|
210
|
+
// @ts-expect-error nodeVersion has been removed as of 13.0.0 however this plugin can be used with many versions of cypress
|
|
210
211
|
if (hasSWCLoader && cypressConfig.nodeVersion === 'bundled') {
|
|
211
212
|
throw new Error(`Cypress cannot compile your Next.js application when "nodeVersion" is set to "bundled". Please remove this option from your Cypress configuration file.`);
|
|
212
213
|
}
|
package/dist/loader.js
CHANGED
|
@@ -16,7 +16,7 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
|
|
|
16
16
|
// If we want to rename the chunks, we can use this
|
|
17
17
|
const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : '';
|
|
18
18
|
return `"${filename}": {
|
|
19
|
-
shouldLoad: () =>
|
|
19
|
+
shouldLoad: () => new URLSearchParams(document.location.search).get("specPath") === "${file.absolute}",
|
|
20
20
|
load: () => import("${file.absolute}" ${magicComments}),
|
|
21
21
|
absolute: "${file.absolute.split(path.sep).join(path.posix.sep)}",
|
|
22
22
|
relative: "${file.relative.split(path.sep).join(path.posix.sep)}",
|
|
@@ -30,7 +30,7 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
|
|
|
30
30
|
* @returns {Record<string, ReturnType<makeImport>}
|
|
31
31
|
* {
|
|
32
32
|
* "App.spec.js": {
|
|
33
|
-
* shouldLoad: () => document.location.
|
|
33
|
+
* shouldLoad: () => (new URL(document.location)).searchParams.get("specPath") === "cypress/component/App.spec.js",
|
|
34
34
|
* load: () => {
|
|
35
35
|
* return import("/Users/projects/my-app/cypress/component/App.spec.js" \/* webpackChunkName: "spec-0" *\/)
|
|
36
36
|
* },
|
|
@@ -10,7 +10,8 @@ const OUTPUT_PATH = path_1.default.join(__dirname, 'dist');
|
|
|
10
10
|
const OsSeparatorRE = RegExp(`\\${path_1.default.sep}`, 'g');
|
|
11
11
|
const posixSeparator = '/';
|
|
12
12
|
function makeCypressWebpackConfig(config) {
|
|
13
|
-
const { devServerConfig: { cypressConfig: { projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, framework, }, sourceWebpackModulesResult: { webpack: { module: webpack, majorVersion: webpackMajorVersion, }, htmlWebpackPlugin: { module: HtmlWebpackPlugin, majorVersion: htmlWebpackPluginVersion, importPath: htmlWebpackPluginImportPath, }, webpackDevServer: { majorVersion: webpackDevServerMajorVersion, }, }, } = config;
|
|
13
|
+
const { devServerConfig: { cypressConfig: { port, projectRoot, devServerPublicPathRoute, supportFile, indexHtmlFile, isTextTerminal: isRunMode, }, specs: files, devServerEvents, framework, }, sourceWebpackModulesResult: { webpack: { module: webpack, majorVersion: webpackMajorVersion, }, htmlWebpackPlugin: { module: HtmlWebpackPlugin, majorVersion: htmlWebpackPluginVersion, importPath: htmlWebpackPluginImportPath, }, webpackDevServer: { majorVersion: webpackDevServerMajorVersion, }, }, } = config;
|
|
14
|
+
const webpackDevServerPort = port !== null && port !== void 0 ? port : undefined;
|
|
14
15
|
debug(`Using HtmlWebpackPlugin version ${htmlWebpackPluginVersion} from ${htmlWebpackPluginImportPath}`);
|
|
15
16
|
const optimization = {
|
|
16
17
|
// To prevent files from being tree shaken by webpack, we set optimization.sideEffects: false ensuring that
|
|
@@ -62,6 +63,7 @@ function makeCypressWebpackConfig(config) {
|
|
|
62
63
|
}
|
|
63
64
|
if (webpackDevServerMajorVersion === 4) {
|
|
64
65
|
return Object.assign(Object.assign({}, finalConfig), { devServer: {
|
|
66
|
+
port: webpackDevServerPort,
|
|
65
67
|
client: {
|
|
66
68
|
overlay: false,
|
|
67
69
|
},
|
|
@@ -69,6 +71,7 @@ function makeCypressWebpackConfig(config) {
|
|
|
69
71
|
}
|
|
70
72
|
// @ts-ignore
|
|
71
73
|
return Object.assign(Object.assign({}, finalConfig), { devServer: {
|
|
74
|
+
port: webpackDevServerPort,
|
|
72
75
|
overlay: false,
|
|
73
76
|
} });
|
|
74
77
|
}
|