Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
const { d, n } = require('../../options');
|
|
|
|
/**
|
|
* Normalizes the options for the plugin.
|
|
* @param {import('../types').ReactRefreshPluginOptions} options Non-normalized plugin options.
|
|
* @returns {import('../types').NormalizedPluginOptions} Normalized plugin options.
|
|
*/
|
|
const normalizeOptions = (options) => {
|
|
d(options, 'exclude', /node_modules/i);
|
|
d(options, 'include', /\.([cm]js|[jt]sx?|flow)$/i);
|
|
d(options, 'forceEnable');
|
|
d(options, 'library');
|
|
|
|
n(options, 'overlay', (overlay) => {
|
|
/** @type {import('../types').NormalizedErrorOverlayOptions} */
|
|
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(overlay, 'sockProtocol');
|
|
d(options, 'useURLPolyfill');
|
|
|
|
return overlay;
|
|
});
|
|
|
|
return options;
|
|
};
|
|
|
|
module.exports = normalizeOptions;
|