@cypress/webpack-dev-server 1.1.6 → 1.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.
- package/CHANGELOG.md +29 -0
- package/README.md +4 -0
- package/dist/aut-runner.d.ts +1 -1
- package/dist/browser.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -9
- package/dist/loader.js +1 -1
- package/dist/makeWebpackConfig.d.ts +2 -2
- package/dist/makeWebpackConfig.js +1 -1
- package/dist/measureWebpackPerformance.d.ts +2 -2
- package/dist/measureWebpackPerformance.js +1 -0
- package/dist/plugin.d.ts +16 -1
- package/dist/plugin.js +15 -5
- package/dist/startServer.d.ts +1 -1
- package/dist/startServer.js +13 -1
- package/dist/webpack.config.d.ts +1 -1
- package/dist/webpack.config.js +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
# [@cypress/webpack-dev-server-v1.4.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.3.1...@cypress/webpack-dev-server-v1.4.0) (2021-06-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **npm/webpack-dev-server,runner-ct:** Normalize webpack errors + general React/TS improvements ([#16613](https://github.com/cypress-io/cypress/issues/16613)) ([c0fc23a](https://github.com/cypress-io/cypress/commit/c0fc23a052e53354a8300dd3f783cb161ae161e1))
|
|
7
|
+
|
|
8
|
+
# [@cypress/webpack-dev-server-v1.3.1](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.3.0...@cypress/webpack-dev-server-v1.3.1) (2021-05-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* encodeURI to correctly load specs with white space ([#16416](https://github.com/cypress-io/cypress/issues/16416)) ([116fe64](https://github.com/cypress-io/cypress/commit/116fe649d74e54da9dd84bf126f08f4b9162c5d3))
|
|
14
|
+
* Properly typecheck webpack-dev-server and fix several undefined issues ([#16503](https://github.com/cypress-io/cypress/issues/16503)) ([4bb1ecd](https://github.com/cypress-io/cypress/commit/4bb1ecd077fc3724e6c127982f98e1e6b0f1bb98))
|
|
15
|
+
|
|
16
|
+
# [@cypress/webpack-dev-server-v1.3.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.2.0...@cypress/webpack-dev-server-v1.3.0) (2021-05-13)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* support webpack dev server v4 ([#16414](https://github.com/cypress-io/cypress/issues/16414)) ([0cea625](https://github.com/cypress-io/cypress/commit/0cea625f359ef554e87600ef7e7c3afa4e36da4d))
|
|
22
|
+
|
|
23
|
+
# [@cypress/webpack-dev-server-v1.2.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.1.6...@cypress/webpack-dev-server-v1.2.0) (2021-05-11)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* exclude html pwa plugin in webpack dev server ([#16388](https://github.com/cypress-io/cypress/issues/16388)) ([14c2292](https://github.com/cypress-io/cypress/commit/14c22929badfe56385260a49336cf29e10902470))
|
|
29
|
+
|
|
1
30
|
# [@cypress/webpack-dev-server-v1.1.6](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.1.5...@cypress/webpack-dev-server-v1.1.6) (2021-04-30)
|
|
2
31
|
|
|
3
32
|
|
package/README.md
CHANGED
|
@@ -93,3 +93,7 @@ In order to update the `{name-of-project}.json` file and use new stats as a base
|
|
|
93
93
|
```sh
|
|
94
94
|
WEBPACK_PERF_MEASURE=true WEBPACK_PERF_MEASURE_UPDATE=true WEBPACK_PERF_MEASURE_COMPARE={name-of-project} yarn cypress run-ct
|
|
95
95
|
```
|
|
96
|
+
|
|
97
|
+
## Changelog
|
|
98
|
+
|
|
99
|
+
[Changelog](./CHANGELOG.md)
|
package/dist/aut-runner.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function init(importPromises:
|
|
1
|
+
export declare function init(importPromises: Array<() => Promise<void>>, parent?: Window): void;
|
package/dist/browser.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export interface ResolvedDevServerConfig {
|
|
|
5
5
|
close: (done?: DoneCallback) => void;
|
|
6
6
|
}
|
|
7
7
|
export { StartDevServer };
|
|
8
|
-
export declare function startDevServer(startDevServerArgs: StartDevServer, exitProcess?: (code?: number) => never): Promise<ResolvedDevServerConfig>;
|
|
8
|
+
export declare function startDevServer(startDevServerArgs: StartDevServer, exitProcess?: (code?: number | undefined) => never): Promise<ResolvedDevServerConfig>;
|
package/dist/index.js
CHANGED
|
@@ -18,15 +18,21 @@ function startDevServer(startDevServerArgs, exitProcess = process.exit) {
|
|
|
18
18
|
const webpackDevServer = yield startServer_1.start(startDevServerArgs, exitProcess);
|
|
19
19
|
return new Promise((resolve) => {
|
|
20
20
|
const httpSvr = webpackDevServer.listen(0, '127.0.0.1', () => {
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
// webpack-dev-server v3 returns `http.Server`.
|
|
22
|
+
// v4 returns a Promise that resolves `http.Server`.
|
|
23
|
+
// use Promise.resolve to make sure we get the `http.Server`,
|
|
24
|
+
// regardless of webpack-dev-server version.
|
|
25
|
+
Promise.resolve(httpSvr).then((server) => {
|
|
26
|
+
// FIXME: handle address returning a string
|
|
27
|
+
const port = server.address().port;
|
|
28
|
+
debug('Component testing webpack server started on port', port);
|
|
29
|
+
return resolve({
|
|
30
|
+
port,
|
|
31
|
+
close: (done) => {
|
|
32
|
+
httpSvr.close();
|
|
33
|
+
done === null || done === void 0 ? void 0 : done();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
30
36
|
});
|
|
31
37
|
});
|
|
32
38
|
});
|
package/dist/loader.js
CHANGED
|
@@ -37,7 +37,7 @@ const makeImport = (file, filename, chunkName, projectRoot) => {
|
|
|
37
37
|
// If we want to rename the chunks, we can use this
|
|
38
38
|
const magicComments = chunkName ? `/* webpackChunkName: "${chunkName}" */` : '';
|
|
39
39
|
return `"${filename}": {
|
|
40
|
-
shouldLoad: () => document.location.pathname.includes("${file.absolute}"),
|
|
40
|
+
shouldLoad: () => document.location.pathname.includes("${encodeURI(file.absolute)}"),
|
|
41
41
|
load: () => import("${file.absolute}" ${magicComments}),
|
|
42
42
|
chunkName: "${chunkName}",
|
|
43
43
|
}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import {
|
|
2
|
+
import { CypressCTOptionsPluginOptionsWithEmitter } from './plugin';
|
|
3
3
|
export interface UserWebpackDevServerOptions {
|
|
4
4
|
/**
|
|
5
5
|
* if `true` will compile all the specs together when the first one is request and can slow up initial build time.
|
|
@@ -7,7 +7,7 @@ export interface UserWebpackDevServerOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
disableLazyCompilation?: boolean;
|
|
9
9
|
}
|
|
10
|
-
interface MakeWebpackConfigOptions extends
|
|
10
|
+
interface MakeWebpackConfigOptions extends CypressCTOptionsPluginOptionsWithEmitter, UserWebpackDevServerOptions {
|
|
11
11
|
devServerPublicPathRoute: string;
|
|
12
12
|
isOpenMode: boolean;
|
|
13
13
|
template?: string;
|
|
@@ -38,7 +38,7 @@ const webpack_merge_1 = require("webpack-merge");
|
|
|
38
38
|
const webpack_config_1 = __importDefault(require("./webpack.config"));
|
|
39
39
|
const plugin_1 = __importDefault(require("./plugin"));
|
|
40
40
|
const debug = debug_1.debug('cypress:webpack-dev-server:makeWebpackConfig');
|
|
41
|
-
const removeList = ['HtmlWebpackPlugin', 'PreloadPlugin'];
|
|
41
|
+
const removeList = ['HtmlWebpackPlugin', 'PreloadPlugin', 'HtmlPwaPlugin'];
|
|
42
42
|
const OsSeparatorRE = RegExp(`\\${path.sep}`, 'g');
|
|
43
43
|
const posixSeparator = '/';
|
|
44
44
|
function makeWebpackConfig(userWebpackConfig, options) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare function measureWebpackPerformance(webpackConfig:
|
|
1
|
+
import type { Configuration } from 'webpack';
|
|
2
|
+
export declare function measureWebpackPerformance(webpackConfig: Configuration): Configuration;
|
|
@@ -7,6 +7,7 @@ exports.measureWebpackPerformance = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
// @ts-ignore
|
|
10
11
|
const speed_measure_webpack_plugin_1 = __importDefault(require("speed-measure-webpack-plugin"));
|
|
11
12
|
function measureWebpackPerformance(webpackConfig) {
|
|
12
13
|
if (!process.env.WEBPACK_PERF_MEASURE) {
|
package/dist/plugin.d.ts
CHANGED
|
@@ -2,22 +2,36 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Compiler } from 'webpack';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
+
import { PathLike } from 'fs';
|
|
6
|
+
import type { Compilation } from 'webpack';
|
|
7
|
+
declare type UtimesSync = (path: PathLike, atime: string | number | Date, mtime: string | number | Date) => void;
|
|
5
8
|
export interface CypressCTOptionsPluginOptions {
|
|
6
9
|
files: Cypress.Cypress['spec'][];
|
|
7
10
|
projectRoot: string;
|
|
8
11
|
supportFile: string;
|
|
9
12
|
devServerEvents?: EventEmitter;
|
|
10
13
|
}
|
|
14
|
+
export declare type CypressCTOptionsPluginOptionsWithEmitter = CypressCTOptionsPluginOptions & {
|
|
15
|
+
devServerEvents: EventEmitter;
|
|
16
|
+
};
|
|
11
17
|
export interface CypressCTWebpackContext {
|
|
12
18
|
_cypress: CypressCTOptionsPluginOptions;
|
|
13
19
|
}
|
|
20
|
+
export declare type Webpack45Compilation = Compilation & {
|
|
21
|
+
inputFileSystem: {
|
|
22
|
+
fileSystem: {
|
|
23
|
+
utimesSync: UtimesSync;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const normalizeError: (error: Error | string) => string;
|
|
14
28
|
export default class CypressCTOptionsPlugin {
|
|
15
29
|
private files;
|
|
16
30
|
private supportFile;
|
|
17
31
|
private errorEmitted;
|
|
18
32
|
private readonly projectRoot;
|
|
19
33
|
private readonly devServerEvents;
|
|
20
|
-
constructor(options:
|
|
34
|
+
constructor(options: CypressCTOptionsPluginOptionsWithEmitter);
|
|
21
35
|
private pluginFunc;
|
|
22
36
|
private setupCustomHMR;
|
|
23
37
|
/**
|
|
@@ -28,3 +42,4 @@ export default class CypressCTOptionsPlugin {
|
|
|
28
42
|
private plugin;
|
|
29
43
|
apply(compiler: Compiler): void;
|
|
30
44
|
}
|
|
45
|
+
export {};
|
package/dist/plugin.js
CHANGED
|
@@ -3,11 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeError = void 0;
|
|
6
7
|
const webpack_1 = __importDefault(require("webpack"));
|
|
7
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
9
|
const semver_1 = __importDefault(require("semver"));
|
|
9
10
|
const fs_1 = __importDefault(require("fs"));
|
|
10
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const normalizeError = (error) => {
|
|
13
|
+
return typeof error === 'string' ? error : error.message;
|
|
14
|
+
};
|
|
15
|
+
exports.normalizeError = normalizeError;
|
|
11
16
|
class CypressCTOptionsPlugin {
|
|
12
17
|
constructor(options) {
|
|
13
18
|
this.files = [];
|
|
@@ -24,7 +29,13 @@ class CypressCTOptionsPlugin {
|
|
|
24
29
|
const stats = compilation.getStats();
|
|
25
30
|
if (stats.hasErrors()) {
|
|
26
31
|
this.errorEmitted = true;
|
|
27
|
-
|
|
32
|
+
// webpack 4: string[]
|
|
33
|
+
// webpack 5: Error[]
|
|
34
|
+
const errors = stats.toJson().errors;
|
|
35
|
+
if (!errors || !errors.length) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.devServerEvents.emit('dev-server:compile:error', exports.normalizeError(errors[0]));
|
|
28
39
|
}
|
|
29
40
|
else if (this.errorEmitted) {
|
|
30
41
|
// compilation succeed but assets haven't emitted to the output yet
|
|
@@ -54,12 +65,11 @@ class CypressCTOptionsPlugin {
|
|
|
54
65
|
// Webpack 5
|
|
55
66
|
/* istanbul ignore next */
|
|
56
67
|
if ('NormalModule' in webpack_1.default) {
|
|
57
|
-
|
|
58
|
-
webpack_1.default.NormalModule.getCompilationHooks(compilation).loader.tap('CypressCTOptionsPlugin', this.pluginFunc);
|
|
68
|
+
webpack_1.default.NormalModule.getCompilationHooks(compilation).loader.tap('CypressCTOptionsPlugin', (context) => this.pluginFunc(context));
|
|
59
69
|
return;
|
|
60
70
|
}
|
|
61
71
|
// Webpack 4
|
|
62
|
-
compilation.hooks.normalModuleLoader.tap('CypressCTOptionsPlugin', this.pluginFunc);
|
|
72
|
+
compilation.hooks.normalModuleLoader.tap('CypressCTOptionsPlugin', (context) => this.pluginFunc(context));
|
|
63
73
|
};
|
|
64
74
|
this.files = options.files;
|
|
65
75
|
this.supportFile = options.supportFile;
|
|
@@ -68,7 +78,7 @@ class CypressCTOptionsPlugin {
|
|
|
68
78
|
}
|
|
69
79
|
apply(compiler) {
|
|
70
80
|
this.setupCustomHMR(compiler);
|
|
71
|
-
compiler.hooks.compilation.tap('CypressCTOptionsPlugin', this.plugin);
|
|
81
|
+
compiler.hooks.compilation.tap('CypressCTOptionsPlugin', (compilation) => this.plugin(compilation));
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
exports.default = CypressCTOptionsPlugin;
|
package/dist/startServer.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export interface StartDevServer extends UserWebpackDevServerOptions {
|
|
|
6
6
|
webpackConfig?: Record<string, any>;
|
|
7
7
|
template?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare function start({ webpackConfig: userWebpackConfig, template, options, ...userOptions }: StartDevServer, exitProcess?: (code?: number) => never): Promise<WebpackDevServer>;
|
|
9
|
+
export declare function start({ webpackConfig: userWebpackConfig, template, options, ...userOptions }: StartDevServer, exitProcess?: (code?: number | undefined) => never): Promise<WebpackDevServer>;
|
package/dist/startServer.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.start = void 0;
|
|
|
27
27
|
const debug_1 = __importDefault(require("debug"));
|
|
28
28
|
const webpack_1 = __importDefault(require("webpack"));
|
|
29
29
|
const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
|
|
30
|
+
const package_json_1 = __importDefault(require("webpack-dev-server/package.json"));
|
|
30
31
|
const makeWebpackConfig_1 = require("./makeWebpackConfig");
|
|
31
32
|
const debug = debug_1.default('cypress:webpack-dev-server:start');
|
|
32
33
|
function start(_a, exitProcess = process.exit) {
|
|
@@ -52,7 +53,18 @@ function start(_a, exitProcess = process.exit) {
|
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
debug('starting webpack dev server');
|
|
55
|
-
|
|
56
|
+
let webpackDevServerConfig = Object.assign(Object.assign({}, userWebpackConfig === null || userWebpackConfig === void 0 ? void 0 : userWebpackConfig.devServer), { hot: false });
|
|
57
|
+
if (package_json_1.default.version.match(/3\./)) {
|
|
58
|
+
webpackDevServerConfig = Object.assign(Object.assign({}, webpackDevServerConfig), { inline: false, publicPath: devServerPublicPathRoute, noInfo: false });
|
|
59
|
+
}
|
|
60
|
+
else if (package_json_1.default.version.match(/4\./)) {
|
|
61
|
+
webpackDevServerConfig = Object.assign(Object.assign({}, userWebpackConfig === null || userWebpackConfig === void 0 ? void 0 : userWebpackConfig.devServer), { devMiddleware: {
|
|
62
|
+
publicPath: devServerPublicPathRoute,
|
|
63
|
+
}, hot: false });
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw Error(`@cypress/webpack-dev-server only supports webpack-dev-server v3 and v4. Found: ${package_json_1.default.version}.`);
|
|
67
|
+
}
|
|
56
68
|
// @ts-ignore types for webpack v5 are incorrect?
|
|
57
69
|
return new webpack_dev_server_1.default(compiler, webpackDevServerConfig);
|
|
58
70
|
});
|
package/dist/webpack.config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function _exports(template?: string): import('webpack').Configuration;
|
|
1
|
+
declare function _exports(template?: string | undefined): import('webpack').Configuration;
|
|
2
2
|
export = _exports;
|
package/dist/webpack.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/webpack-dev-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Launches Webpack Dev Server for Component Testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc",
|
|
8
8
|
"build-prod": "tsc",
|
|
9
|
-
"test": "tsc && mocha -r @packages/ts/register test/**/*.spec.ts --exit",
|
|
9
|
+
"test": "tsc && mocha -r @packages/ts/register test/**/*.spec.ts test/*.spec.ts --exit",
|
|
10
10
|
"watch": "tsc -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"html-webpack-plugin": ">=4",
|
|
31
31
|
"webpack": ">=4",
|
|
32
|
-
"webpack-dev-server": "
|
|
32
|
+
"webpack-dev-server": ">=3.0.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|