How to use the react-cosmos-utils/lib/module-exists function in react-cosmos-utils

To help you get started, we’ve selected a few react-cosmos-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github react-cosmos / react-cosmos / packages / react-cosmos-webpack / src / module-loader.js View on Github external
const { components, fixtures } = getFilePaths(cosmosConfig);
  const { proxiesPath } = cosmosConfig;
  const contexts = getUniqueDirsOfUserModules(components, fixtures);

  contexts.forEach(dirPath => {
    // This ensures this loader is invalidated whenever a new component/fixture
    // file is created or renamed, which leads succesfully uda ...

  return source
    .replace(/COMPONENTS/g, convertPathMapToRequireCalls(components))
    .replace(/FIXTURES/g, convertPathMapToRequireCalls(fixtures))
      moduleExists(proxiesPath) ? convertPathToRequireCall(proxiesPath) : '[]'
    .replace(/CONTEXTS/g, convertDirPathsToContextCalls(contexts));