How to use the babel-plugin-module-resolver.resolvePath function in babel-plugin-module-resolver

To help you get started, we’ve selected a few babel-plugin-module-resolver 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 TallerWebSolutions / next-on-drupal / config / babel / babel.common.js View on Github external
const resolveComponentPath = (sourcePath, currentFile, opts) => {
  const defaultPath = resolvePath(sourcePath, currentFile, opts)

  try {
    const resolved = resolve(dirname(currentFile), defaultPath)

    if (statSync(resolved).isDirectory()) {
      const ext = extname(sourcePath) || '.js'
      const index = join(resolved, 'index' + ext)
      const component = join(resolved, basename(resolved) + ext)

      if (!existsSync(index) && existsSync(component)) {
        return component
      }
    }
  } catch (err) {
    // ignore errors, simply return default resolved path.
  }
github tleunen / eslint-import-resolver-babel-module / src / index.js View on Github external
// e.g. in .eslintrc file
        // "import/resolver": {
        //   "babel-module": {
        //     "root": ["./src"],
        //     "extensions": [".js", ".jsx"]
        //   }
        // }
        cwd: options.cwd || projectRootDir,
        root: options.root || [],
        alias: options.alias || {},
        extensions: options.extensions || defaultExtensions,
      },
    );

    const finalSource = stripWebpack(source, pluginOptions.alias);
    const src = resolvePath(finalSource, file, pluginOptions);

    const extensions = options.extensions || pluginOptions.extensions;

    return {
      found: true,
      path: resolve.sync(src || source, {
        ...options,
        extensions,
        basedir: path.dirname(file),
      }),
    };
  } catch (e) {
    return { found: false };
  }
};
github mui-org / material-ui / docs / babel.config.js View on Github external
function resolvePath(sourcePath, currentFile, opts) {
  if (sourcePath === 'markdown') {
    const base = currentFile.substring(__dirname.length).slice(0, -3);
    return `${__dirname}/docs/src/${base}/`;
  }

  return bpmr.resolvePath(sourcePath, currentFile, opts);
}
github Beven91 / react-native-on-web / packages / react-native-on-web-bundler / src / webpack / webpack.server.js View on Github external
resolvePath(sourcePath, currentFile, opts) {
      let name = ModuleResolver.resolvePath(sourcePath, currentFile, opts);
      if (name) {
        let full = path.join(path.dirname(currentFile), name);
        let name2 = path.relative(config.projectRoot, full);
        return name2.indexOf('..' + path.sep) > -1 ? name.replace('../', '') : name;
      }
    },
    'alias': Options.merge({

babel-plugin-module-resolver

Module resolver plugin for Babel

MIT
Latest version published 8 months ago

Package Health Score

83 / 100
Full package analysis