Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit 3bee1e2

Browse files
committed
feat: support lazy-loaded components by forcing all into 1 chunk
1 parent 5bbcc69 commit 3bee1e2

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"@cypress/webpack-preprocessor": "4.1.3",
101101
"babel-plugin-istanbul": "6.0.0",
102102
"debug": "4.1.1",
103-
"find-webpack": "1.2.0"
103+
"find-webpack": "1.4.0"
104104
},
105105
"release": {
106106
"branches": [

plugins/cra-v3/file-preprocessor.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
// @ts-check
12
const debug = require('debug')('cypress-react-unit-test')
23
const findWebpack = require('find-webpack')
3-
const webpack = require('@cypress/webpack-preprocessor')
4+
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
45

56
const getWebpackOptions = opts => {
67
debug('top level opts %o', opts)
@@ -9,7 +10,7 @@ const getWebpackOptions = opts => {
910
if (!webpackOptions) {
1011
console.error('⚠️ Could not find Webpack options, using defaults')
1112
return {
12-
webpackOptions: webpack.defaultOptions,
13+
webpackOptions: webpackPreprocessor.defaultOptions,
1314
watchOptions: {},
1415
}
1516
}
@@ -33,8 +34,9 @@ module.exports = config => {
3334
debug('coverage is disabled? %o', { coverageIsDisabled })
3435

3536
const opts = {
37+
reactScripts: true,
3638
coverage: !coverageIsDisabled,
3739
}
3840
const options = getWebpackOptions(opts)
39-
return webpack(options)
41+
return webpackPreprocessor(options)
4042
}

plugins/load-webpack/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22
const path = require('path')
33
const debug = require('debug')('cypress-react-unit-test')
4-
const webpack = require('@cypress/webpack-preprocessor')
4+
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
55
const findWebpack = require('find-webpack')
66

77
module.exports = (on, config) => {
@@ -10,8 +10,7 @@ module.exports = (on, config) => {
1010
const webpackFilename = config.env && config.env.webpackFilename
1111
if (!webpackFilename) {
1212
throw new Error(
13-
'Could not find "webpackFilename" option in Cypress env variables %o',
14-
config.env,
13+
'Could not find "webpackFilename" option in Cypress env variables',
1514
)
1615
}
1716
debug('got webpack config filename %s', webpackFilename)
@@ -26,6 +25,7 @@ module.exports = (on, config) => {
2625
debug('coverage is disabled? %o', { coverageIsDisabled })
2726

2827
const opts = {
28+
reactScripts: true,
2929
coverage: !coverageIsDisabled,
3030
}
3131

@@ -37,7 +37,7 @@ module.exports = (on, config) => {
3737
watchOptions: {},
3838
}
3939

40-
on('file:preprocessor', webpack(options))
40+
on('file:preprocessor', webpackPreprocessor(options))
4141

4242
// IMPORTANT to return the config object
4343
// with the any changed environment variables

0 commit comments

Comments
 (0)