How to use the enhanced-resolve/lib/ResolverFactory.createResolver function in enhanced-resolve

To help you get started, we’ve selected a few enhanced-resolve 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 connectivedx / fuzzy-chainsaw / build / webpack / lib / postcss-plugins.js View on Github external
// dev
const cssImport = require('postcss-import');
const colorsExport = require('./colors-export');

// setup resolver for postcss-import
const ResolverFactory = require('enhanced-resolve/lib/ResolverFactory');
const NodeJsInputFileSystem = require('enhanced-resolve/lib/NodeJsInputFileSystem');
const CachedInputFileSystem = require('enhanced-resolve/lib/CachedInputFileSystem');

const { source, styleguide } = require('../../lib/path-helpers');
const { resolve } = require('../workflow/shared');


const fileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
const resolver = ResolverFactory.createResolver({
  alias: resolve.alias,
  extensions: ['.css'],
  modules: [source(), 'node_modules'],
  useSyncFileSystemCalls: true,
  fileSystem
});


module.exports.linting = [
  stylelint(),
  reporter()
];


const standard = [
  mixins(),
github wix / stylable / src / create-infra-structure.ts View on Github external
export function createInfrastructure(
    projectRoot: string,
    fileSystem: MinimalFS,
    onProcess: (meta: StylableMeta, path: string) => StylableMeta = x => x
): StylableInfrastructure {
    const eResolver = ResolverFactory.createResolver({
        useSyncFileSystemCalls: true,
        fileSystem
    });

    const fileProcessor = cachedProcessFile((from, content) => {
        if (!path.isAbsolute(from)) {
            from = eResolver.resolveSync({}, projectRoot, from);
        }
        return onProcess(process(safeParse(content, {from})), from);
    }, {
            readFileSync(moduleId: string) {
                if (!path.isAbsolute(moduleId)) {
                    moduleId = eResolver.resolveSync({}, projectRoot, moduleId);
                }
                return fileSystem.readFileSync(moduleId, 'utf8');
            },
github wix / stylable / packages / stylable / src / create-infra-structure.ts View on Github external
export function createInfrastructure(
    projectRoot: string,
    fileSystem: MinimalFS,
    onProcess?: (meta: StylableMeta, path: string) => StylableMeta,
    resolveOptions: any = {},
    resolveNamespace?: typeof processNamespace
): StylableInfrastructure {
    const eResolver = ResolverFactory.createResolver({
        useSyncFileSystemCalls: true,
        fileSystem,
        ...resolveOptions
    });

    const resolvePath = (context: string | undefined = projectRoot, moduleId: string) => {
        if (!path.isAbsolute(moduleId) && moduleId.charAt(0) !== '.') {
            moduleId = eResolver.resolveSync({}, context, moduleId);
        }
        return moduleId;
    };

    const fileProcessor = cachedProcessFile(
        (from, content) => {
            return process(safeParse(content, { from: resolvePath(projectRoot, from) }), undefined, resolveNamespace);
        },