@cypress/webpack-dev-server 2.1.0 → 2.2.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/dist/devServer.d.ts +1 -1
- package/dist/devServer.js +4 -4
- package/dist/helpers/createReactAppHandler.js +0 -1
- package/dist/helpers/nextHandler.js +0 -1
- package/dist/helpers/nuxtHandler.js +0 -1
- package/dist/helpers/sourceRelativeWebpackModules.js +1 -2
- package/dist/helpers/vueCliHandler.js +0 -1
- package/dist/makeDefaultWebpackConfig.js +1 -6
- package/dist/makeWebpackConfig.d.ts +1 -0
- package/dist/makeWebpackConfig.js +10 -23
- package/package.json +1 -1
package/dist/devServer.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare type WebpackDevServerConfig = {
|
|
|
11
11
|
framework?: typeof ALL_FRAMEWORKS[number];
|
|
12
12
|
webpackConfig?: unknown;
|
|
13
13
|
};
|
|
14
|
-
export declare const ALL_FRAMEWORKS: readonly ["create-react-app", "nuxt", "react", "vue-cli", "next", "vue"];
|
|
14
|
+
export declare const ALL_FRAMEWORKS: readonly ["create-react-app", "nuxt", "react", "vue-cli", "next", "vue", "angular"];
|
|
15
15
|
/**
|
|
16
16
|
* import { devServer } from '@cypress/webpack-dev-server'
|
|
17
17
|
*
|
package/dist/devServer.js
CHANGED
|
@@ -10,8 +10,9 @@ const nuxtHandler_1 = require("./helpers/nuxtHandler");
|
|
|
10
10
|
const createReactAppHandler_1 = require("./helpers/createReactAppHandler");
|
|
11
11
|
const nextHandler_1 = require("./helpers/nextHandler");
|
|
12
12
|
const sourceRelativeWebpackModules_1 = require("./helpers/sourceRelativeWebpackModules");
|
|
13
|
+
const angularHandler_1 = require("./helpers/angularHandler");
|
|
13
14
|
const debug = (0, debug_1.default)('cypress:webpack-dev-server:devServer');
|
|
14
|
-
exports.ALL_FRAMEWORKS = ['create-react-app', 'nuxt', 'react', 'vue-cli', 'next', 'vue'];
|
|
15
|
+
exports.ALL_FRAMEWORKS = ['create-react-app', 'nuxt', 'react', 'vue-cli', 'next', 'vue', 'angular'];
|
|
15
16
|
/**
|
|
16
17
|
* import { devServer } from '@cypress/webpack-dev-server'
|
|
17
18
|
*
|
|
@@ -72,9 +73,8 @@ async function getPreset(devServerConfig) {
|
|
|
72
73
|
return (0, vueCliHandler_1.vueCliHandler)(devServerConfig);
|
|
73
74
|
case 'next':
|
|
74
75
|
return await (0, nextHandler_1.nextHandler)(devServerConfig);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// return await angularHandler(devServerConfig)
|
|
76
|
+
case 'angular':
|
|
77
|
+
return await (0, angularHandler_1.angularHandler)(devServerConfig);
|
|
78
78
|
case 'react':
|
|
79
79
|
case 'vue':
|
|
80
80
|
case undefined:
|
|
@@ -16,7 +16,6 @@ async function nuxtHandler(devServerConfig) {
|
|
|
16
16
|
// Nuxt has asset size warnings configured by default which will cause webpack overlays to appear
|
|
17
17
|
// in the browser which we don't want.
|
|
18
18
|
delete webpackConfig.performance;
|
|
19
|
-
delete webpackConfig.entry;
|
|
20
19
|
debug('webpack config %o', webpackConfig);
|
|
21
20
|
return { frameworkConfig: webpackConfig, sourceWebpackModulesResult };
|
|
22
21
|
}
|
|
@@ -23,8 +23,7 @@ const frameworkWebpackMapper = {
|
|
|
23
23
|
react: undefined,
|
|
24
24
|
vue: undefined,
|
|
25
25
|
next: 'next',
|
|
26
|
-
|
|
27
|
-
// 'angular': '@angular-devkit/build-angular',
|
|
26
|
+
'angular': '@angular-devkit/build-angular',
|
|
28
27
|
};
|
|
29
28
|
// Source the users framework from the provided projectRoot. The framework, if available, will serve
|
|
30
29
|
// as the resolve base for webpack dependency resolution.
|
|
@@ -27,12 +27,7 @@ function makeDefaultWebpackConfig(config) {
|
|
|
27
27
|
path: OUTPUT_PATH,
|
|
28
28
|
},
|
|
29
29
|
plugins: [
|
|
30
|
-
new HtmlWebpackPlugin({
|
|
31
|
-
template: indexHtmlFile,
|
|
32
|
-
// TODO: revert once Angular is slated for release
|
|
33
|
-
// Angular generates all of it's scripts with <script type="module">. Live-reloading breaks without this option.
|
|
34
|
-
// ...(config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module' } : {}),
|
|
35
|
-
}),
|
|
30
|
+
new HtmlWebpackPlugin(Object.assign({ template: indexHtmlFile }, (config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module' } : {}))),
|
|
36
31
|
],
|
|
37
32
|
};
|
|
38
33
|
if (config.sourceWebpackModulesResult.webpackDevServer.majorVersion === 4) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeWebpackConfig = void 0;
|
|
3
|
+
exports.makeWebpackConfig = exports.CYPRESS_WEBPACK_ENTRYPOINT = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const debug_1 = require("debug");
|
|
6
6
|
const path = (0, tslib_1.__importStar)(require("path"));
|
|
@@ -35,7 +35,7 @@ if (process.platform === 'linux') {
|
|
|
35
35
|
}
|
|
36
36
|
const OsSeparatorRE = RegExp(`\\${path.sep}`, 'g');
|
|
37
37
|
const posixSeparator = '/';
|
|
38
|
-
|
|
38
|
+
exports.CYPRESS_WEBPACK_ENTRYPOINT = path.resolve(__dirname, 'browser.js');
|
|
39
39
|
/**
|
|
40
40
|
* Removes and/or modifies certain plugins known to conflict
|
|
41
41
|
* when used with cypress/webpack-dev-server.
|
|
@@ -60,25 +60,6 @@ function modifyWebpackConfigForCypress(webpackConfig) {
|
|
|
60
60
|
}
|
|
61
61
|
return webpackConfig;
|
|
62
62
|
}
|
|
63
|
-
async function addEntryPoint(webpackConfig) {
|
|
64
|
-
let entry = webpackConfig.entry;
|
|
65
|
-
if (typeof entry === 'function') {
|
|
66
|
-
entry = await entry();
|
|
67
|
-
}
|
|
68
|
-
if (typeof entry === 'string') {
|
|
69
|
-
entry = [entry, CYPRESS_WEBPACK_ENTRYPOINT];
|
|
70
|
-
}
|
|
71
|
-
else if (Array.isArray(entry)) {
|
|
72
|
-
entry.push(CYPRESS_WEBPACK_ENTRYPOINT);
|
|
73
|
-
}
|
|
74
|
-
else if (typeof entry === 'object') {
|
|
75
|
-
entry = Object.assign(Object.assign({}, entry), { ['cypress-entry']: CYPRESS_WEBPACK_ENTRYPOINT });
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
entry = CYPRESS_WEBPACK_ENTRYPOINT;
|
|
79
|
-
}
|
|
80
|
-
webpackConfig.entry = entry;
|
|
81
|
-
}
|
|
82
63
|
/**
|
|
83
64
|
* Creates a webpack 4/5 compatible webpack "configuration"
|
|
84
65
|
* to pass to the sourced webpack function
|
|
@@ -88,7 +69,7 @@ async function makeWebpackConfig(config) {
|
|
|
88
69
|
const { module: webpack } = config.sourceWebpackModulesResult.webpack;
|
|
89
70
|
let userWebpackConfig = config.devServerConfig.webpackConfig;
|
|
90
71
|
const frameworkWebpackConfig = config.frameworkConfig;
|
|
91
|
-
const { cypressConfig: { projectRoot, devServerPublicPathRoute, supportFile, }, specs: files, devServerEvents, } = config.devServerConfig;
|
|
72
|
+
const { cypressConfig: { projectRoot, devServerPublicPathRoute, supportFile, }, specs: files, devServerEvents, framework, } = config.devServerConfig;
|
|
92
73
|
let configFile = undefined;
|
|
93
74
|
if (!userWebpackConfig && !frameworkWebpackConfig) {
|
|
94
75
|
debug('Not user or framework webpack config received. Trying to automatically source it');
|
|
@@ -141,7 +122,13 @@ async function makeWebpackConfig(config) {
|
|
|
141
122
|
],
|
|
142
123
|
};
|
|
143
124
|
const mergedConfig = (0, webpack_merge_1.merge)(userAndFrameworkWebpackConfig, (0, makeDefaultWebpackConfig_1.makeDefaultWebpackConfig)(config), dynamicWebpackConfig);
|
|
144
|
-
|
|
125
|
+
// Angular loads global styles and polyfills via script injection in the index.html
|
|
126
|
+
if (framework === 'angular') {
|
|
127
|
+
mergedConfig.entry = Object.assign(Object.assign({}, mergedConfig.entry || {}), { 'cypress-entry': exports.CYPRESS_WEBPACK_ENTRYPOINT });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
mergedConfig.entry = exports.CYPRESS_WEBPACK_ENTRYPOINT;
|
|
131
|
+
}
|
|
145
132
|
debug('Merged webpack config %o', mergedConfig);
|
|
146
133
|
if (process.env.WEBPACK_PERF_MEASURE) {
|
|
147
134
|
// only for debugging
|