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 ...
    this.addDependency(dirPath);
  });

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

react-cosmos-utils

Libs shared between React Cosmos modules

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis

Similar packages