| Server IP : 74.208.250.37 / Your IP : 216.73.216.233 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ubuntu 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : miferval ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /usr/share/nodejs/@isaacs/import-jsx/ |
Upload File : |
'use strict';
const path = require('path');
const resolveFrom = require('resolve-from');
const callerPath = require('caller-path');
const cache = require('./cache');
const {version} = require('./package.json');
const importJsx = (moduleId, options) => {
if (typeof moduleId !== 'string') {
throw new TypeError('Expected a string');
}
options = {
pragma: 'h',
pragmaFrag: 'Fragment',
cache: true,
...options
};
const modulePath = resolveFrom(path.dirname(callerPath()), moduleId);
if (!options.cache) {
delete require.cache[modulePath];
}
// If they used .jsx, and there's already a .jsx, then hook there
// Otherwise, hook node's default .js
const ext = path.extname(modulePath);
const hookExt = require.extensions[ext] ? ext : '.js';
const oldExtension = require.extensions[hookExt];
require.extensions[hookExt] = module => {
const oldCompile = module._compile;
module._compile = source => {
const result = cache({
modulePath,
options,
source,
version
});
module._compile = oldCompile;
module._compile(result, modulePath);
};
require.extensions[hookExt] = oldExtension;
oldExtension(module, modulePath);
};
const m = require(modulePath);
require.extensions[hookExt] = oldExtension;
if (!options.cache) {
delete require.cache[modulePath];
}
return m;
};
module.exports = importJsx;
module.exports.default = importJsx;
module.exports.create = options => {
return moduleId => importJsx(moduleId, options);
};