main.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. import * as builtinHandlers from './handlers/index.js';
  2. import parse from './parse.js';
  3. import * as builtinResolvers from './resolver/index.js';
  4. import { fsImporter, ignoreImporter, makeFsImporter, } from './importer/index.js';
  5. import * as utils from './utils/index.js';
  6. import { createConfig, defaultHandlers } from './config.js';
  7. import { ERROR_CODES } from './error.js';
  8. const builtinImporters = {
  9. fsImporter,
  10. ignoreImporter,
  11. };
  12. /**
  13. * Parse the *src* and scan for react components based on the config
  14. * that gets supplied.
  15. *
  16. * The default resolvers look for *exported* react components.
  17. *
  18. * By default all handlers are applied, so that all possible
  19. * different use cases are covered.
  20. *
  21. * The default importer is the fs-importer that tries to resolve
  22. * files based on the nodejs resolve algorithm.
  23. */
  24. function defaultParse(src, config = {}) {
  25. const defaultConfig = createConfig(config);
  26. return parse(String(src), defaultConfig);
  27. }
  28. export { builtinHandlers, builtinResolvers, builtinImporters, defaultHandlers, makeFsImporter, defaultParse as parse, utils, ERROR_CODES, };