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>
61 lines
2.2 KiB
JavaScript
61 lines
2.2 KiB
JavaScript
/**
|
|
* NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
|
* you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
|
*/
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var env_1 = require("./env");
|
|
/**
|
|
* Checks whether we're in the Node.js or Browser environment
|
|
*
|
|
* @returns Answer to given question
|
|
*/
|
|
function isNodeEnv() {
|
|
// explicitly check for browser bundles as those can be optimized statically
|
|
// by terser/rollup.
|
|
return (!env_1.isBrowserBundle() &&
|
|
Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]');
|
|
}
|
|
exports.isNodeEnv = isNodeEnv;
|
|
/**
|
|
* Requires a module which is protected against bundler minification.
|
|
*
|
|
* @param request The module path to resolve
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
function dynamicRequire(mod, request) {
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
return mod.require(request);
|
|
}
|
|
exports.dynamicRequire = dynamicRequire;
|
|
/**
|
|
* Helper for dynamically loading module that should work with linked dependencies.
|
|
* The problem is that we _should_ be using `require(require.resolve(moduleName, { paths: [cwd()] }))`
|
|
* However it's _not possible_ to do that with Webpack, as it has to know all the dependencies during
|
|
* build time. `require.resolve` is also not available in any other way, so we cannot create,
|
|
* a fake helper like we do with `dynamicRequire`.
|
|
*
|
|
* We always prefer to use local package, thus the value is not returned early from each `try/catch` block.
|
|
* That is to mimic the behavior of `require.resolve` exactly.
|
|
*
|
|
* @param moduleName module name to require
|
|
* @returns possibly required module
|
|
*/
|
|
function loadModule(moduleName) {
|
|
var mod;
|
|
try {
|
|
mod = dynamicRequire(module, moduleName);
|
|
}
|
|
catch (e) {
|
|
// no-empty
|
|
}
|
|
try {
|
|
var cwd = dynamicRequire(module, 'process').cwd;
|
|
mod = dynamicRequire(module, cwd() + "/node_modules/" + moduleName);
|
|
}
|
|
catch (e) {
|
|
// no-empty
|
|
}
|
|
return mod;
|
|
}
|
|
exports.loadModule = loadModule;
|
|
//# sourceMappingURL=node.js.map
|