is_builtin_module.js 1.8 KB

123456789101112131415161718192021222324252627
  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 = (_module || _load_module()).builtinModules || Object.keys(process.binding('natives')).filter(module => !/^internal\//.test(module)); /**
  12. * Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  13. *
  14. * This source code is licensed under the MIT license found in the
  15. * LICENSE file in the root directory of this source tree.
  16. *
  17. *
  18. */
  19. // $FlowFixMe: Flow doesn't know about the `module` module
  20. function isBuiltinModule(module) {
  21. return BUILTIN_MODULES.indexOf(module) !== -1;
  22. }