12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- const d = (object, property, defaultValue) => {
- if (typeof object[property] === 'undefined' && typeof defaultValue !== 'undefined') {
- object[property] = defaultValue;
- }
- return object[property];
- };
- const nestedOption = (object, property, fn) => {
- object[property] = fn(object[property]);
- return object[property];
- };
- const normalizeOptions = (options) => {
-
- if (typeof options.disableRefreshCheck !== 'undefined') {
- delete options.disableRefreshCheck;
- console.warn(
- [
- 'The "disableRefreshCheck" option has been deprecated and will not have any effect on how the plugin parses files.',
- 'Please remove it from your configuration.',
- ].join(' ')
- );
- }
- d(options, 'exclude', /node_modules/i);
- d(options, 'include', /\.([jt]sx?|flow)$/i);
- d(options, 'forceEnable');
- nestedOption(options, 'overlay', (overlay) => {
-
- const defaults = {
- entry: require.resolve('../../client/ErrorOverlayEntry'),
- module: require.resolve('../../overlay'),
- sockIntegration: 'wds',
- };
- if (overlay === false) {
- return false;
- }
- if (typeof overlay === 'undefined' || overlay === true) {
- return defaults;
- }
- d(overlay, 'entry', defaults.entry);
- d(overlay, 'module', defaults.module);
- d(overlay, 'sockIntegration', defaults.sockIntegration);
- d(overlay, 'sockHost');
- d(overlay, 'sockPath');
- d(overlay, 'sockPort');
- d(options, 'useLegacyWDSSockets');
- return overlay;
- });
- return options;
- };
- module.exports = normalizeOptions;
|