-
Notifications
You must be signed in to change notification settings - Fork 22
Webpack compilation error with defaultOptions #40
Description
- Operating System: MacOS 10.13.6
- Cypress Version: 3.1.1 (cypress-webpack-preprocessor 4.0.0)
- Browser Version: N/A
- Other: react-scripts 2.0.4 (which provides webpack 4 and babel 7)
Is this a Feature or Bug?
Bug, fails to run cypress tests
Current behavior:
When using the defaultOptions for webpack the presets is set to a string, but babel validates this as an array:
Error: Webpack Compilation Error at assertArray (/node_modules/@babel/core/lib/config/validation/option-assertions.js:150:11) at assertPluginList (/node_modules/@babel/core/lib/config/validation/option-assertions.js:219:15) at Object.keys.forEach.key (/node_modules/@babel/core/lib/config/validation/options.js:107:5) at Array.forEach (<anonymous>) at validateNested (/node_modules/@babel/core/lib/config/validation/options.js:83:21) at validate (/node_modules/@babel/core/lib/config/validation/options.js:74:10) at loadPrivatePartialConfig (/node_modules/@babel/core/lib/config/partial.js:66:50) at Object.loadPartialConfig (/node_modules/@babel/core/lib/config/partial.js:110:18)
Desired behavior:
The presets should be set to an array in defaultOptions, my current workaround is to fix this in plugins/index.js:
const webpack = require('@cypress/webpack-preprocessor');
module.exports = (on) => {
const options = webpack.defaultOptions;
options.webpackOptions.module.rules[0].use[0].options.presets = [options.webpackOptions.module.rules[0].use[0].options.presets];
on('file:preprocessor', webpack(options))
};
How to reproduce:
Add webpack-preprocessor as a dependency version 4.0.0, and use with CRA2 (create-react-app V2). CRA2 uses webpack 4.x and babel 7.x
Additional Info (images, stack traces, etc)
Commit where presets was changed from array to string:
22db72da03943f9e28237033935e1bf4d8dddf25