Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function generateInfra(
config: InfraConfig,
diagnostics: Diagnostics = new Diagnostics()
): {
resolver: StylableResolver;
requireModule: RequireType;
fileProcessor: FileProcessor;
} {
const { fs, requireModule } = createMinimalFS(config);
const fileProcessor = cachedProcessFile(
(from, content) => {
const meta = process(postcss.parse(content, { from }), diagnostics);
meta.namespace = config.files[from].namespace || meta.namespace;
return meta;
},
fs,
x => x
);
const resolver = new StylableResolver(fileProcessor, requireModule);
return { resolver, requireModule, fileProcessor };
}
export function createStylableInstance(config: Config) {
config.trimWS = true;
const { fs, requireModule } = createMinimalFS(config);
const stylable = new Stylable(
'/',
fs as any,
requireModule,
'__',
(meta, path) => {
meta.namespace = config.files[path].namespace || meta.namespace;
return meta;
},
undefined,
undefined,
config.resolve
);
return stylable;