is-static-require.js 343 B

1234567891011121314
  1. 'use strict';
  2. const {isStringLiteral} = require('./literal.js');
  3. const isStaticRequire = node => Boolean(
  4. node?.type === 'CallExpression'
  5. && node.callee.type === 'Identifier'
  6. && node.callee.name === 'require'
  7. && !node.optional
  8. && node.arguments.length === 1
  9. && isStringLiteral(node.arguments[0]),
  10. );
  11. module.exports = isStaticRequire;