is_builtin_module.js 770 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = isBuiltinModule;
  6. var _module;
  7. function _load_module() {
  8. return (_module = require('module'));
  9. }
  10. // https://github.com/facebook/flow/pull/5160
  11. const BUILTIN_MODULES =
  12. (_module || _load_module()).builtinModules ||
  13. Object.keys(process.binding('natives')).filter(
  14. module => !/^internal\//.test(module)
  15. );
  16. /**
  17. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  18. *
  19. * This source code is licensed under the MIT license found in the
  20. * LICENSE file in the root directory of this source tree.
  21. *
  22. *
  23. */
  24. // $FlowFixMe: Flow doesn't know about the `module` module
  25. function isBuiltinModule(module) {
  26. return BUILTIN_MODULES.indexOf(module) !== -1;
  27. }